-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[Typescript Fetch] Handle date parameters in the URL path #19313
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
Merged
macjohnny
merged 8 commits into
OpenAPITools:master
from
scottaj:bugfix/typescript-fetch/dates-in-path-params
Jun 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7747522
Handle date parameters in the URL path
scottaj 2c3501c
Reformat template and add cast for date fields
scottaj ffa3354
Change code structure by moving path tranformations to assignment
scottaj 78b74c2
Merge remote-tracking branch 'upstream/master' into bugfix/typescript…
scottaj 244190e
Regenerate samples after merge
scottaj 373a34c
Updated param checking
scottaj 9dbfa08
Merge remote-tracking branch 'upstream/master' into bugfix/typescript…
scottaj b24c0be
Try a new commit after manually re-logging into CircleCI
scottaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
how about
to simplify the template?
moreover,
encodeURIComponent(requestParameters['{{paramName}}'].toISOString().substring(0,10))is problematic because devs might be using a local date, and this converts the date to be in UTC. But at least this matchesopenapi-generator/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache
Line 114 in f8a5051
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.
I can do the expanded style. I wasn't sure what the standards (if any are for the generated code, so I was trying to maintain the style of that. But your version makes the template more readable.
Regarding the iso string handling, I pretty much just copied the code above that is handling query params (line 140 of this file). So while I don't disagree about the UTC thing, I think if that is an issue it might need to be addressed as part of a larger change
I can add the null handling stuff you have, but are path params allowed to be nullable? I'll admit I don't know the spec well enough to be sure but that seems really weird. I suppose in that case though that putting in null as the path value is the correct behavior?
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.
Regarding the nullable bit, my reading of the spec (both version 2 and version 3.1.0) is that a path parameter can't be null because the
requiredproperty must be set to true: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-10There 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.
We can also just add the null-safe operator „.?“ to be cautious