Skip to content

Conversation

@halidovz
Copy link

Problem:
When OpenAPI servers are defined and there are multiple paths with the same number of segments—some dynamic and some static—the validator may incorrectly match both paths.

Example OpenAPI definition:

servers:
  - url: https://localhost/v1

paths:
  get /products/{product}/images/{image}
  get /products/{product}/images/thumbnails

Incoming request:

GET /v1/products/10/images/thumbnails

Actual behavior:
Both paths /products/{product}/images/{image} and /products/{product}/images/thumbnails are matched.

Expected behavior:
Only the more specific, static path /products/{product}/images/thumbnails should match.

Cause:
The current path matching logic compares only the relative path without properly including the server prefix (e.g., /v1). This leads to ambiguous or incorrect matching when evaluating path candidates of equal length.

Fix:
Ensure that the matching logic compares full paths—including the server prefix—when determining the best match.

@halidovz halidovz changed the title Bug Fix: Incorrect Path Matching with Server Prefix and Ambiguous Routes Bug Fix: Incorrect Static Paths Prioritising Apr 16, 2025
@halidovz
Copy link
Author

Hey @lezhnev74 , could you please review this when you get a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant