-
Notifications
You must be signed in to change notification settings - Fork 161
feat(parser): allow duplicate paths when HTTP methods differ #1590
Copy link
Copy link
Closed
Description
Problem
When an OpenAPI spec contains paths that normalize to the same structure but have different parameter names and different HTTP methods, ogen errors with "duplicate path":
paths:
/pets/{petId}:
get:
# no operationId
/pets/{id}:
post:
# no operationIdPer OpenAPI spec, templated paths with the same hierarchy but different parameter names are technically invalid. However, these specs exist in the wild and could be handled gracefully when the HTTP methods differ.
Proposed Solution
Add a parser setting AllowDuplicatePathsWithDifferentMethods (enabled by default) that:
- Relaxes the duplicate path check when paths have different HTTP methods
- Allows the generator's existing naming logic to disambiguate operations using
path.String()(which includes parameter names) + method
Example generated names:
GET /pets/{petId}→GetPetsPetIdPOST /pets/{id}→PostPetsId
Behavior
- Default (enabled): Duplicate paths with different methods are allowed; operations are disambiguated by path + params + method
- Disabled: Current strict behavior; duplicate paths always error
Notes
- Same method on duplicate paths remains an error (true conflict)
- This is a parsing-level change with minimal generator impact
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels