Gi60s / openapi-enforcer

Apache License 2.0
94 stars 22 forks source link

Path enforcer duplicate paths, but they are not #118

Closed acotty closed 3 years ago

acotty commented 3 years ago

In 1.14.2 the path enforcer has a bug where the code incorrectly detects duplicate paths and I output the results as follows in my code: Error: Error: One or more errors exist in the OpenApi definition at: paths Equivalent paths are not allowed Equivalent paths: /pet/{petId} /user/{username}

The problem appears to be an issue with the equivalencyKeyin the src/enforcers/Path.js somewhere around lines 83 though 95 where the equivalencyKey is generated for a particular path that is then used in the path foreach on line 98 for the different methods.

I think the real issue is that the equivalencyKey does not include the path without the parameter if the parameter is the last parameter, but I could be wrong.

Attached is my openapi yaml file I am working on. PetStore_oas3.yaml.txt

Gi60s commented 3 years ago

I'm seeing the same behavior with what you've shared. I'll take a look at it. Thank you for the issue.

Gi60s commented 3 years ago

I've almost figured this one out. You do have a problem with equivalent paths, but it's reporting incorrectly.

Your equivalent paths are /user/{userId} and /user/{username}. I'll get the bug fixed that is reporting incorrectly and let you know when that is done.

Gi60s commented 3 years ago

The fix has been published to NPM as version 1.14.3. Thanks again for the issue.

acotty commented 3 years ago

Thanks very much for the very quick fix it now shows the two equivalent paths correctly (after I reverted the yaml file fix that I fixed yesterday after I posted this bug report).