typescript-fetch: Fix model date crash#21821
Merged
macjohnny merged 2 commits intoOpenAPITools:masterfrom Aug 27, 2025
kradical:master
Merged
typescript-fetch: Fix model date crash#21821macjohnny merged 2 commits intoOpenAPITools:masterfrom kradical:master
macjohnny merged 2 commits intoOpenAPITools:masterfrom
kradical:master
Conversation
Fix a runtime crash converting to json when a date or datetime is both nullable AND required. There are 4 cases to account for: | required | nullable | values | |----------|----------|--------| | f | f | string OR undefined | | f | t | string OR null OR undefined | | t | f | string | | t | t | string OR null | And importantly when required and nullable code that would crash on null was being generated. additionally when required is false and nullable is true we still want to allow consumers to be able to pass in `undefined` OR `null` and pass that value to the server. Some servers treat null and undefined differently for some operations so having that ability is pretty reasonable. fix: #21820
./bin/generate-samples.sh ./bin/configs/*.yaml || exit
Contributor
Author
|
@macjohnny tagging you because you saw the change to this part of the template |
Contributor
Author
|
ty! and thanks for the quick turnaround. is this gonna have to wait till 7.16 to go out? I imagine so? I'll just push off version bumping until then if so. |
Member
|
@kradical you can also use the SNAPSHOT version to get the change immediately |
Contributor
|
Thank you for fixing the bug - and referencing my PR so I can learn from the issue! :) Appreciate it 🥳 |
Goopher
pushed a commit
to Goopher/openapi-generator
that referenced
this pull request
Sep 9, 2025
* typescript-fetch: Fix model date crash Fix a runtime crash converting to json when a date or datetime is both nullable AND required. There are 4 cases to account for: | required | nullable | values | |----------|----------|--------| | f | f | string OR undefined | | f | t | string OR null OR undefined | | t | f | string | | t | t | string OR null | And importantly when required and nullable code that would crash on null was being generated. additionally when required is false and nullable is true we still want to allow consumers to be able to pass in `undefined` OR `null` and pass that value to the server. Some servers treat null and undefined differently for some operations so having that ability is pretty reasonable. fix: OpenAPITools#21820 * Update typescript-fetch samples ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: #21820
Fix a runtime crash converting to json when a date or datetime is both nullable AND required. There are 4 cases to account for:
And importantly when required and nullable code that would crash on null was being generated. additionally when required is false and nullable is true we still want to allow consumers to be able to pass in
undefinedORnulland pass that value to the server. Some servers treat null and undefined differently for some operations so having that ability is pretty reasonable.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)