Skip to content

fix: handle duplicate path parameters in OpenAPI specs#2220

Merged
mromaszewicz merged 1 commit intooapi-codegen:mainfrom
mromaszewicz:fix/deduplicate-path-params
Feb 15, 2026
Merged

fix: handle duplicate path parameters in OpenAPI specs#2220
mromaszewicz merged 1 commit intooapi-codegen:mainfrom
mromaszewicz:fix/deduplicate-path-params

Conversation

@mromaszewicz
Copy link
Member

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

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 <junior.rantila@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mromaszewicz mromaszewicz requested a review from a team as a code owner February 14, 2026 01:27
@jamietanna jamietanna added this to the v2.6.0 milestone Feb 15, 2026
@mromaszewicz mromaszewicz merged commit 1650807 into oapi-codegen:main Feb 15, 2026
26 checks passed
@jamietanna jamietanna added the bug Something isn't working label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator confused by duplicated path parameter

2 participants