Support multiple template paths and matching - #64
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves OpenAPI path matching when multiple templated paths could match the same request path, aiming to choose the most specific template match and making the result independent of path-definition order. It also expands the test OpenAPI documents and adds regression tests around literal-vs-templated ambiguity.
Changes:
- Add a scoring mechanism to select the “best” matching templated path when more than one template matches a request path.
- Extend existing OpenAPI test data with additional overlapping templated/literal paths and add a reversed-definition-order variant.
- Add new response validation tests to cover the new ambiguous path scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/OpenApiValidate.Tests/TestData/LiteralAndTemplatedPathReversed.yaml | New test OpenAPI document with reversed path definition order to validate deterministic matching. |
| test/OpenApiValidate.Tests/TestData/LiteralAndTemplatedPath.yaml | Extend test OpenAPI document with additional overlapping role paths to exercise template specificity. |
| test/OpenApiValidate.Tests/ResponseValidatorTests.cs | Add regression tests validating DELETE matching for overlapping literal/templated role paths (including reversed spec order). |
| src/OpenApiValidate/Helpers/OpenApiExtensions.cs | Implement template “best match” selection logic for TryMatchPath and refactor template-segment detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.