feat(parser): allow duplicate paths with different HTTP methods#1592
Merged
ernado merged 1 commit intoogen-go:mainfrom Nov 30, 2025
Merged
Conversation
Add DisallowDuplicateMethodPaths setting to control path duplication
behavior. When false (default), paths that normalize identically are
allowed if they use different HTTP methods. This enables specs with
paths like /pets/{petId} GET and /pets/{id} POST to coexist.
When true, the parser maintains strict mode and rejects all duplicate
normalized paths regardless of HTTP method. Paths with overlapping
methods (e.g., /pets/{petId} GET and /pets/{id} GET) are always
rejected to prevent routing ambiguity.
Implementation adds method tracking to parsePathItems() with helpers
getPathMethods() and methodsOverlap(). The setting is exposed through
gen.ParseOptions for YAML/JSON configuration.
Fixes ogen-go#1590
ernado
approved these changes
Nov 30, 2025
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.
Summary
Adds a new parser setting to allow duplicate normalized paths when they use different HTTP methods, resolving issues with real-world OpenAPI specs that technically violate the specification but can be safely handled.
Fixes #1590
Changes
DisallowDuplicateMethodPathssetting (default: false for lenient mode)gen.ParseOptionsfor YAML/JSON configurationAPI Example
Testing
Notes
Breaking Change: None - default behavior is lenient (allows different-method duplicates). Users wanting strict validation can opt-in via configuration.