Uh oh!
There was an error while loading. Please reload this page.
[TypeScript][Fetch] only call toISOString() if date object - #9594
Conversation
tsiq-jeremy
commented
Jul 29, 2019
Is there a technical committee to review this? |
fasunna
commented
Apr 10, 2020
Is there any chance that this PR would be merged any time soon? I would contribute myself if I had not seen this PR, but since it is already created I would like to see this feature in production. I'm still getting this error from the editor.swagger.io client generator. |
| {{#isDate}} | ||
| localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString(); | ||
| localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ? | ||
| ({{paramName}} as any).toISOString().substr(0,10) : |
There was a problem hiding this comment.
Just a notice, if the param type is "datetime" the string length should surpass 10 characters since it contains the timestamp as well.
For instance: "2014-01-01T23:28:56.782Z" or even "2014-02-01T09:28:56.321-10:00"
I suggest checking the type for date if you want to keep the substr(0,10) or else this would be problematic for datetime types.
HugoMario
commented
May 8, 2020
hey guys, thanks for PR, please ping me once this is ready to be merged |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{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\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR
@mhardorf@leonyu@roni-frantchi@bherila
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. Same issue on swagger-codegen.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.