Uh oh!
There was an error while loading. Please reload this page.
typescript-axios string date format - #3423
Conversation
macjohnny
commented
Jul 23, 2019
@tsiq-jeremy thanks for your PR! can you please re-generate the samples?
|
macjohnny
commented
Jul 23, 2019
cc @nicokoenig |
tsiq-jeremy
commented
Jul 23, 2019
Hey I just ran |
macjohnny
commented
Jul 23, 2019
@tsiq-jeremy ok, that's probably because there is no Date-query parameter in the petstore example, so everything is fine. |
macjohnny
commented
Jul 23, 2019
@tsiq-jeremy would you like to fix the same problem in the |
tsiq-jeremy
commented
Jul 23, 2019
Hey, let me look into that one. I'm not sure if there is a problem with |
macjohnny
commented
Jul 23, 2019
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 |
tsiq-jeremy
commented
Jul 23, 2019
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: exportinterfaceGetOrderByIdRequest{date: Date;}
....asyncgetOrderByIdRaw(requestParameters: GetOrderByIdRequest): Promise<runtime.ApiResponse<Order>>{
....constqueryParameters: runtime.HTTPQuery={};if(requestParameters.date!==undefined){queryParameters['date']=(requestParameters.dateasany).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 |
macjohnny
commented
Jul 23, 2019
Ok, alright, thanks for checking! |
wing328
commented
Aug 10, 2019
@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