Is order of endpoint validation configurable in some way? #1060
Replies: 1 comment
-
Ok, looks like express-openapi-validator attempts to sort routes into an order such that most dynamic routes are placed last. However, the implementation fails if the parameters are named differently. I have routes that look like this: /endpoint/:app/:uuid/download I have them ordered as above since they do need to be validated correctly in that order. In openapi.spec.loader there is a sorting function:
This sorting function only properly orders routes if the route parameters are named the same across routes. If they are not named the same, this can instead cause validation failures. This function applied to the above endpoints results in them being reordered to: /endpoint/:app/:refType/:refId This results in validation failure. TLDR: I would probably classify this as a bug. I see no way around it with the current version other than renaming your route params to things that don't make sense for the endpoints. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have some endpoints that look something like this:
/endpoint/:app/:uuid/download
/endpoint/:app/:refType/:refId
When these are defined in express I have them defined in the order above such that the more restrictive endpoint is checked first. However, express-openapi-validator is attempting to validate these endpoints in reverse order which is causing validation failure.
Is there some way to control the order of validation in express-openapi-validator? I have them defined in my openapi specification in the order above but it seems this order is not respected during validation.
Beta Was this translation helpful? Give feedback.
All reactions