-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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-axios] toIsoString() with type string #2745
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
maybe you have a type mapping in your configuration? e.g. <typeMappings>
<typeMapping>DateTime=string</typeMapping>
</typeMappings> the generated code should be improved to something like if (startDate !== undefined && startDate instanceof Date) {...} would you like to open a PR to fix this? |
Hey, I see the same issue occurring with typescript/fetch using {
...
"type": "string",
"format": "date",
} Since the parameter getting passed in is ALWAYS going to be a string, it should never be calling localVarQueryParameter['{{baseName}}'] = {{paramName}}; |
in order not to break existing code, it would be simpler to check for both if (startDate !== undefined && startDate instanceof Date) {...} |
@macjohnny works for me! Im going to open up a PR with an update to do this. So I also did a bit more digging into the issue on why this is occurring. If the format is "date", then the parameter type is a In `AbstractTypeScriptClientCodegen.java: typeMapping.put("date", "string");
typeMapping.put("DateTime", "Date"); While in {{#isDate}}
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString();
{{/isDate}} Which is causing the type mismatch. |
@tsiq-jeremy could you please open the PR here in openapi generator? |
This seems to be affecting the typescript fetch client too. Looks like there was a pull against the swagger-gen fetch client, but not the openapi generator fetch client. |
@fuzzerd would you like to port #3423 to the typrscript fetch client? |
Im using Docker to generate my OpenAPI
https://openapi-generator.tech/docs/installation#docker
This is one of my generate
Any idea why
startDate
for example, input asstring
but still has the linelocalVarQueryParameter['startDate'] = (startDate as any).toISOString();
It cause an error:
toIsoString() is not a function
The text was updated successfully, but these errors were encountered: