-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation Option to disable strict path parameter uniqueness validation #157
Conversation
1efe773
to
b4b6ac8
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #157 +/- ##
=======================================
Coverage 90.60% 90.60%
=======================================
Files 22 22
Lines 2990 2991 +1
=======================================
+ Hits 2709 2710 +1
Misses 227 227
Partials 54 54 ☔ View full report in Codecov by Sentry. |
go mod replace github.com/go-openapi/validate with github.com/dadgar/validate. The forked validate contains the changes from here: go-openapi/validate#157
Wouldn't it make more sense to just turn the error into a warning? And perhaps make this a configurable behavior via an env var or validator config. Basically, this is a breaking change and while it might not work for your case, others might be depending on the behavior. This tool has been around for a long time |
@casualjim I would be willing to plump it through a config. So you would want the default behavior to be the historic behavior? As I see it, the validation is enforcing something that is not in the spec and thus didn't warrant keeping the old behavior around; configurable or not. |
Yeah, it's just that we don't know who is depending on this behavior, and since it's been around for so long, this has become a feature for some and a bug for you. I understand where you're coming from, but the issue is not so critical that it warrants a breaking change. We can easily address both use cases with a simple guard. |
Add a validation option to remove strict path uniqueness validation behavior where path parameters are ignored. Signed-off-by: Alex Dadgar <[email protected]>
@casualjim Please take another look, added a validation option to switch the behavior and kept the existing default. |
@casualjim would appreciate a look at the updated PR when you have the chance. Thank you. |
Thank you! |
Adds a validation option to disable path uniqueness validation behavior where path parameters are ignored. The existing behavior of the validator replaces path parameters with an X and then checks for uniqueness.
As an example, the two paths
GET /v1/{book}
andGET /v1/{shelve}
wherebook
has the patternshelves/*/book/*
andshelve
has the patternshelve/*
, get both replaced to/v1/X
and an error is returned reporting overlapping paths.This does not allow the resource name pattern described by Google's AIPs. Further, I do not see it being described in the specification that the path parameters can not have slashes and thus the path can be unique based on the required path parameter.
I will add that I tested other Swagger validators / code generators and they were perfectly happy with paths that are only unique based on unique path parameters.