PayU / openapi-validator-middleware

Input validation using Swagger (Open API) and ajv
Apache License 2.0
144 stars 50 forks source link

Fix pathMatcher to prioritize exact matches #101

Closed msmol closed 4 years ago

msmol commented 4 years ago

Previously if multiple routes were defined like so: /foo/exact_bar /foo/:some_bar_variable

and the openapi definition happened to have the /foo/:some_bar_variable defined first, the pathMatcher would consider this the correct path on which to validate the request.

This change now does the pathMatcher in 2 phases: an exact match first, followed by the previous logic of looking for a variable starting with ':'. This way the exact match is prioritized over an inexact match.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 99.18% when pulling 93eed340dfd293100a53e0ae6eac5bbdcc5d7aa5 on msmol:fix-path-matcher into 45817361bef6a0b7a64fef6265264ad259a46565 on Zooz:master.