-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeScript][Fetch] only call toISOString() if date object #9594
[TypeScript][Fetch] only call toISOString() if date object #9594
Conversation
Is there a technical committee to review this? |
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. |
@@ -164,7 +164,9 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur | |||
{{/isDateTime}} | |||
{{^isDateTime}} | |||
{{#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.sh
and./bin/security/{LANG}-petstore.sh
if 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.0
branch 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.