-
-
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-fetch] Dates in request body are not ISO formatted #13841
Comments
danmichaelo
changed the title
[typescript-fetch] Dates in request body not formatted correctly
[typescript-fetch] Dates in request body are not ISO formatted
Oct 27, 2022
Trolldemorted
added a commit
to Trolldemorted/openapi-generator
that referenced
this issue
Jun 10, 2024
As mentioned in OpenAPITools#13841, date-time parameters in request bodies are not ISO formatted, which breaks with certain webservers. This commit invokes `toISOString()` for date-time body parameters like it is done for queryParameters. Fixes OpenAPITools#13841.
Trolldemorted
added a commit
to Trolldemorted/openapi-generator
that referenced
this issue
Jun 10, 2024
As mentioned in OpenAPITools#13841, date-time parameters in request bodies are not ISO formatted, which breaks with certain webservers. This commit invokes `toISOString()` for date-time body parameters like it is done for queryParameters. Fixes OpenAPITools#13841.
Trolldemorted
added a commit
to Trolldemorted/openapi-generator
that referenced
this issue
Jun 10, 2024
As mentioned in OpenAPITools#13841, date-time parameters in request bodies are not ISO formatted, which breaks with certain webservers. This commit invokes `toISOString()` for date-time body parameters like it is done for queryParameters. Fixes OpenAPITools#13841.
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
If the schema contains a date-time field in a request body, and I pass a
Date
object to one of the generated methods, the date is not ISO formatted, but encoded using the default string representation of the Date (i.e.Thu Oct 27 2022 14:04:50 GMT+0200 (Central European Summer Time)
).openapi-generator version
6.2.0, not a regression
OpenAPI declaration file content or url
Here's a minimal declaration:
Command line used for generation
(
--skip-validate-spec
because I tried to keep the example minimal, so I didn't include responses, info, etc.)Steps to reproduce
Related issues/PRs
Couldn't find any issue related to this particular problem. The closest I found was this other typescript-fetch serialization issue: #11613
Suggest a fix/enhancement
This seems to be happening because the
Date
object is passed directly toURLSearchParams
atopenapi-generator/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache
Line 247 in 2e6cdb5
Basically this is what happens:
If I add
.toISOString()
to the relevant line in the generatedapis.ts
, it works:So I guess perhaps a new helper method could be introduced? Something like this?
Do you think this would be a good approach?
The text was updated successfully, but these errors were encountered: