Repository navigation
fix: make it possible to have the same path parameter twice in URL - #2175
Closed
juniorrantila wants to merge 1 commit into
Closed
juniorrantila wants to merge 1 commit into
juniorrantila wants to merge 1 commit into
Conversation
This makes it possible to parse the keycloak openapi spec, which for one
API has a URL of '/admin/realms/{realm}/clients/{client-uuid}/roles/{role-name}/composites/clients/{client-uuid}'.
Member
|
Related: #1574 |
mromaszewicz
added a commit
to mromaszewicz/oapi-codegen
that referenced
this pull request
Feb 14, 2026
Some real-world OpenAPI specs (e.g. Keycloak) reuse the same path
parameter more than once in a single URI, such as:
/clients/{client-uuid}/roles/{role-name}/composites/clients/{client-uuid}
Previously this caused a "has 4 positional parameters, but spec has 3
declared" error because SortParamsByPath compared raw URI placeholder
count against unique declared parameters.
Fix this by deduplicating the path parameters extracted from the URI
(preserving first-occurrence order) before matching them against the
spec declared parameters. This is the right level to fix the issue
rather than scattering dedup logic across template helpers.
Fixes oapi-codegen#1574
Supersedes oapi-codegen#2175
Co-Authored-By: Junior Rantila <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Member
|
Thanks for doing this, @juniorrantila , however, this isn't the right fix for the problem. The problem needs to be fixed at the time the schemas for the parameters are gathered for each path. I'm closing this commit, and added you as a Co-Author on a new one, so you get some credit for finding this. |
mromaszewicz
added a commit
that referenced
this pull request
Feb 15, 2026
Some real-world OpenAPI specs (e.g. Keycloak) reuse the same path
parameter more than once in a single URI, such as:
/clients/{client-uuid}/roles/{role-name}/composites/clients/{client-uuid}
Previously this caused a "has 4 positional parameters, but spec has 3
declared" error because SortParamsByPath compared raw URI placeholder
count against unique declared parameters.
Fix this by deduplicating the path parameters extracted from the URI
(preserving first-occurrence order) before matching them against the
spec declared parameters. This is the right level to fix the issue
rather than scattering dedup logic across template helpers.
Fixes #1574
Supersedes #2175
Co-authored-by: Junior Rantila <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
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.
This makes it possible to parse the keycloak openapi spec, which for one API has a URL of '/admin/realms/{realm}/clients/{client-uuid}/roles/{role-name}/composites/clients/{client-uuid}'.