You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using express-oas-validator with express.js, the routes that end with a trailing slash are not being validated correctly against the OpenAPI definitions. This leads to the validator not recognizing valid endpoints if they are defined without a trailing slash in the OpenAPI documentation but are called with one (e.g., calling /api/forbidden-words/ when the OpenAPI defines /api/forbidden-words).
Steps to Reproduce
Define a route in Express without a trailing slash (e.g., /api/forbidden-words).
Set up the express-oas-validator middleware with OpenAPI definitions matching the route.
Call the endpoint with a trailing slash (e.g., /api/forbidden-words/).
The validator responds with an error stating that the method is not found in the OpenAPI definition.
Expected Behavior
The validator should either recognize that /api/forbidden-words/ and /api/forbidden-words are the same endpoint, or there should be an option to normalize the URL before validation to ensure consistency.
Actual Behavior
The validator returns an error: Method: "get" not found in the OpenAPI definition for "/api/forbidden-words/" endpoint.
Possible Solution
As a temporary workaround, routes can be normalized by stripping trailing slashes before validation. However, it would be preferable to have this handled within the library either by default or via a configuration option.
Additional Context
Please let me know if there are any more details I can provide or if a fix or workaround is already available. Thank you for your assistance!
The text was updated successfully, but these errors were encountered:
Description
When using express-oas-validator with express.js, the routes that end with a trailing slash are not being validated correctly against the OpenAPI definitions. This leads to the validator not recognizing valid endpoints if they are defined without a trailing slash in the OpenAPI documentation but are called with one (e.g., calling
/api/forbidden-words/
when the OpenAPI defines/api/forbidden-words
).Steps to Reproduce
/api/forbidden-words
)./api/forbidden-words/
).Expected Behavior
The validator should either recognize that
/api/forbidden-words/
and/api/forbidden-words
are the same endpoint, or there should be an option to normalize the URL before validation to ensure consistency.Actual Behavior
The validator returns an error:
Method: "get" not found in the OpenAPI definition for "/api/forbidden-words/" endpoint
.Possible Solution
As a temporary workaround, routes can be normalized by stripping trailing slashes before validation. However, it would be preferable to have this handled within the library either by default or via a configuration option.
Additional Context
Please let me know if there are any more details I can provide or if a fix or workaround is already available. Thank you for your assistance!
The text was updated successfully, but these errors were encountered: