Gi60s / openapi-enforcer

Apache License 2.0
94 stars 22 forks source link

Case Insensitive Paths #136

Closed AndrewChurchill closed 2 years ago

AndrewChurchill commented 2 years ago

Hello, I was wondering if there's a way to make path matching case insensitive? For example, we would like /SomePath, /SomePATH, and /somepath all to resolve to the /somePath section of the OAS. We don't enforce case-sensitivity on some of our endpoints which is causing some requests to fail with a false positive.

[ EnforcerException: Request has one or more errors
    Path not found ]

If this isn't currently possible, maybe something like the following could be added? I could also take a look at adding this if you're open to contributions.

const Enforcer = require('openapi-enforcer');
Enforcer.config.useCaseInsensitivePaths = true;

Thanks for your help!

Gi60s commented 2 years ago

I think this would be relatively simple to implement. I'll try and get to this later today.

AndrewChurchill commented 2 years ago

Great, thank you!

Gi60s commented 2 years ago

I've implemented this functionality under the option Enforcer.config.useCaseSensitivePaths. It's been released to npm as version 1.18.0 and documented here: https://openapi-enforcer.com/api/#enforcer-config

Have a great day!

AndrewChurchill commented 2 years ago

Thanks again for adding this so quickly! It works great!