typescript-axios string date format#3423
Conversation
|
@tsiq-jeremy thanks for your PR! can you please re-generate the samples?
|
|
cc @nicokoenig |
|
Hey I just ran |
|
@tsiq-jeremy ok, that's probably because there is no Date-query parameter in the petstore example, so everything is fine. |
|
@tsiq-jeremy would you like to fix the same problem in the |
|
Hey, let me look into that one. I'm not sure if there is a problem with |
|
yes, but I think the From/ToJson functions are used for the body, not for the query parameters, so it should be the same situation |
|
Hey I have not tested this out fully, but I think this should not be a problem with "parameters": [
{
"name": "date",
"in": "query",
"type": "string",
"format": "date"
}
]Produced: export interface GetOrderByIdRequest {
date: Date;
}
....
async getOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise<runtime.ApiResponse<Order>> {
....
const queryParameters: runtime.HTTPQuery = {};
if (requestParameters.date !== undefined) {
queryParameters['date'] = (requestParameters.date as any).toISOString().substr(0,10);
}
...
}So it looks like that a Date object is getting passed in so that it should not produce an error when calling |
|
Ok, alright, thanks for checking! |
|
@tsiq-jeremy thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553 |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master,4.1.x,5.0.x. Default:master.Description of the PR
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny
Fair warning that I tested this out more thoroughly using swagger-codegen for this PR - swagger-api/swagger-codegen#9594 - but it looks like the same exact issue.
Related to this issue. When using TypeScript Fetch and passing parameters to a "Date" field, they expect a type of "string", but then
toISOString()is called on it, which causes the function to fail.Example json swagger:
in In `AbstractTypeScriptClientCodegen.java the Typings map:
template issue:
requestParameters.{{paramName}}can never be a Date, since it has to be a string.fixes #2745