swagger-tools icon indicating copy to clipboard operation
swagger-tools copied to clipboard

case sensitive routing

Open Al77056 opened this issue 7 years ago • 5 comments

This is derived from the issue to support case sensitive routing in swagger node.

I found out that the lack of support for case sensitive routing in swagger node is due to the fact that the "apiCache" built in swagger-metadata.js is using a regular expression with the case insensitive option. It would be nice to expose a 'pathIsCaseSensitive' option in the swagger-metadata module, such that this option is used to build the regular expression (cacheEntry.re) at line 378.

After the option is added we'll then be able to modify swagger-node-runner to expose the option in the swagger_metadata fittings.

Al77056 avatar Jul 20 '17 19:07 Al77056

Per RFC3986 6.2.2.1, it seems that all URI components other than scheme and host are suppose to be case-sensitive. This is a bug and should be fixed.

whitlockjc avatar Jul 20 '17 21:07 whitlockjc

If it's a bug, why fixing it in sway? I tried changing the following in swagger-metadata.js

var re = pathToRegexp(expressPath, keys, { end: handleSubPaths });

to

var re = pathToRegexp(expressPath, keys, { end: handleSubPaths, sensitive: true });

and it fixes the issue by matching the apiPath correctly with the regular expression.

Al77056 avatar Jul 21 '17 00:07 Al77056

I'm fixing it in both.

whitlockjc avatar Jul 21 '17 00:07 whitlockjc

Is the fix to swagger-metadata.js going in anytime soon? 😉

paulkchen avatar Aug 27 '18 21:08 paulkchen

@whitlockjc where can I see this fix?

burgalon avatar Jan 05 '21 14:01 burgalon