Repository navigation
fix: updated parseRequestUnion for union requests - #1055
Merged
shenbenson merged 2 commits intoSep 24, 2025
Merged
shenbenson merged 2 commits into
shenbenson merged 2 commits into
Conversation
yanxue-22
force-pushed
the
DX-1437-openapi-generator-keep-params-when-requests-are-unioned
branch
from
September 23, 2025 19:48
22d4ff2 to
b2731e4
Compare
Path parameters were being dropped when the first schema in a union request didn't contain params. Now it iterates through all schemas to find the first one with path parameters.
yanxue-22
force-pushed
the
DX-1437-openapi-generator-keep-params-when-requests-are-unioned
branch
from
September 23, 2025 20:45
8651c8c to
9396a0e
Compare
shenbenson
reviewed
Sep 24, 2025
shenbenson
left a comment
Contributor
There was a problem hiding this comment.
A few small comments, but looks good overall
| path: '/internal/api/policy/v1/{applicationName}/touchpoints/{touchpoint}/rules/evaluation', | ||
| method: 'POST', | ||
| request: t.union([ | ||
| // First schema has NO path parameters - this was causing the bug |
Contributor
There was a problem hiding this comment.
Do we want to keep these comments around? It doesn't mean anything without context
Contributor
Author
There was a problem hiding this comment.
I noticed parts of the code base had comments that pointed out small things, so I didn't know if it was better or worse to leave tidbits. Your comment makes sense though, I'll delete the comment
| }, | ||
| ); | ||
|
|
||
| const REAL_WORLD_POLICY_EVALUATION_ROUTE = ` |
Contributor
There was a problem hiding this comment.
I think this variable name can be better
yanxue-22
force-pushed
the
DX-1437-openapi-generator-keep-params-when-requests-are-unioned
branch
2 times, most recently
from
September 24, 2025 17:09
226e512 to
d64cd6a
Compare
yanxue-22
force-pushed
the
DX-1437-openapi-generator-keep-params-when-requests-are-unioned
branch
from
September 24, 2025 17:12
d64cd6a to
d2836f4
Compare
shenbenson
approved these changes
Sep 24, 2025
shenbenson
deleted the
DX-1437-openapi-generator-keep-params-when-requests-are-unioned
branch
September 24, 2025 18:27
|
🎉 This PR is included in version @api-ts/openapi-generator@5.10.2 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
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.
Ticket: DX-1437
The error happened in this case:
If Type A didn't have the params defined (due to inconsistency in source code), the generator would immediately stop looking without checking for param specifications in the other types.
With the changes it iterates through all types in the union (Type A, then Type B, etc.) until it finds the first one that contains the params definition. Once it finds the parameter, it uses it for the route and stops searching, since the URL parameters should be the same for the entire route.
I also made a few new test cases that now pass. One of them were if the first schema in a union did not have params, but the rest did, it now looks through the rest of them instead of breaking after the first.