openapi3: fix validation of duplicated path templates#1189
Merged
Conversation
The conflicting-paths validation in Paths.Validate was unreachable. The lookup keyed on the *normalized* path (the template form with parameter names stripped) but the dedup map insertion keyed on the *literal* path. Two paths that conflict by template would each get their own literal entry, so neither would ever see the other on lookup. Change the insertion to key by the normalized path. The conflicting- paths emit() call now fires for the cases it was always meant to catch. Verified across testdata/APIs-guru-openapi-directory: 14 real-world specs that the validator was silently accepting are now reported as having conflicting paths (apigateway, backup, carbone, circuitsandbox, healthcare.gov, jellyfin, magento, reverb, signl4, trello, visma, and three vtex variants). Their __validate golden fixtures are new in this commit and pin the corrected behaviour. No other golden fixtures move; specs without conflicts are unaffected. Extracted from getkin#1187 per @fenollp review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Extracted from #1187 per @fenollp review.
Bug
Paths.Validatekeeps a dedup map to detect two paths that template to the same canonical form (/users/{id}vs/users/{name}). The lookup keys on the normalized path, but the insertion was keyed on the literal path:Each conflicting path got its own literal-keyed entry, so the lookup never matched. The check was unreachable.
Fix
One line: key the insertion on the normalized path, matching the lookup. Error text and types are unchanged; the path was just never being reached.
Impact
Across
testdata/APIs-guru-openapi-directory, 14 real-world specs are now correctly reported as having conflicting paths (their new__validategoldens pin the corrected behaviour). No other golden fixture moves.