NPE when QueryParameter is of type Array and has no CollectionFormat.
Issue #110
resolved
For an array QueryParameter described like (Note there is no collectionFormat):
parameters:
- in: query
name: color
type: array
items:
type: string
The Swagger Request Validator throws a NPE when trying to validate the parameters of the query.
This happens at ArrayParameterValidator.java class on doValidate method, on:
return doValidate(CollectionFormat.from(parameter).split(value), parameter);
because CollectionFormat.from(parameter) assumes that the parameter has a CollectionFormat.
Instead of throwing the NPE, it could log an error saying that a CollectionFormat is required in the parameter definition at the Swagger spec.
Comments (3)
-
-
Which version of the S-R-V are you using?
A similar bug was fixed with
#68and was merged into the 1.2.2 release. -
- changed status to resolved
Fixed in
#68(v1.2.2) - Log in to comment
The CollectionFormat is not required in the Swagger spec. If it's missing a default is defined. It's “csv“. The SRV should handle it accordingly and use “csv“ in case it is missing.