swagger-tools
swagger-tools copied to clipboard
case sensitive routing
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.
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.
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.
I'm fixing it in both.
Is the fix to swagger-metadata.js going in anytime soon? 😉
@whitlockjc where can I see this fix?