-
Notifications
You must be signed in to change notification settings - Fork 537
3.5.0 OpenAPI3 - enumerated query params are not validated propertly #794
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
Comments
The parameter you have defined should be an array. If you pass two parameters with the same name, only first parameter is validated, the second one is discarded. If you want both parameters, you should define it as: parameters:
- name: param1
in: query
required: true
schema:
type: array
items:
type: string
enum: ["foo", "bar"] As default for OAS 3, your parameter will have |
Actually my initial idea was to have it as just enum - not array - and if case anybody sends more than one value it will not validate as API defines expectation of a single value. I've also tested your suggestion and it does not work exactly as you described - with |
When you send more than one parameter with the same name (formally an array with style form exploded) it should throw a ValidationException, but it doesn't. This is a bug and I will fix that 😄 The new version of swagger-parser will be included in 3.5.1 of vertx-web-api-contract, and it has this fix swagger-api/swagger-parser#569 |
Signed-off-by: francesco <[email protected]>
… including test for #794 fix Signed-off-by: francesco <[email protected]>
Version
Context
I encountered an exception which looks suspicious while trying to force my query parameters to be properly validated.
Example api definition:
when sending request with query parameters
?param1=foo¶m1=baz
it passes validation but should not. Opposite order (?param1=baz¶m1=foo
) ends up inValidationException
as expected.I've narrowed it down to an issue with
EnumTypeValidator
and provided testcases showcasing the problem: https://github.com/vert-x3/vertx-web/compare/master...kgarlikowski:open-api-validation-issues?expand=1. The testcaseshould_not_pass_disallowed_values_opposite_order
fails as it does not produceValidationException
.It is caused by
ParameterTypeValidator
only validating first value from the whole list of query parameters.The text was updated successfully, but these errors were encountered: