NPE when QueryParameter is of type Array and has no CollectionFormat.

Issue #110 resolved
Former user created an issue

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)

  1. Sven Döring

    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.

  2. Sven Döring

    Which version of the S-R-V are you using?

    A similar bug was fixed with #68 and was merged into the 1.2.2 release.

  3. Log in to comment