krakenjs / hapi-openapi

Build design-driven apis with OpenAPI (formerly swagger) 2.0 and hapi.
Other
211 stars 75 forks source link

validation problem on requests with query parameter of array type #25

Closed guybedo closed 9 years ago

guybedo commented 9 years ago

the swagger spec allows definition of query parameters of type array but queries generated using swagger-ui are not accepted by swaggerize-hapi.

For example, i have this definition for a get request :

get:
      parameters:
        - name: fields
          in: query
          required: false
          type: array
          items:
            type: string
          enum: [date, title, description]

The server accepts requests with the "fields" parameter encoded in these formats: fields[]=date,title,description fields=date&fields=title&fields=description

BUT swagger-ui generates this kind of request : http://test.api.com/request?fields=date,title,description This request is not accepted by the server and i have a 400 response :'fields must be an array'

So it seems that the implementation does not respect the swagger spec

dcharbonnier commented 9 years ago

https://github.com/swagger-api/swagger-ui/issues/810 for reference

guybedo commented 9 years ago

pull request: https://github.com/krakenjs/swaggerize-hapi/pull/26

tlivings commented 9 years ago

Does changing the collectionFormat property of the parameter to multi change how swagger-ui constructs the url? See: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameter-object- and collectionFormat.

tlivings commented 9 years ago

Swagger UI now supports collectionFormat properly.