7

I'm using swagger 2.0 to define my API. I'm using enums as described in the docs here. I have the following endpoint in my swagger.yml file:

/my-endpoint:
    x-swagger-router-controller: my-controller
    get:
      summary: my test endpoint
      parameters:
        - name: feeling
          in: query
          type: string
          enum:
            - happy
            - sad
          required: true
      produces:
        - application/json
      responses:
        200:
          description: OK

I would expect a 400 bad request to be returned to the client if the feeling query parameter is not either happy or sad, but it accepts any string. Does swagger not validate that the parameter is in the enum?

cph2117
  • 2,651
  • 1
  • 28
  • 41
  • What server framework are you using - [swagger-node](https://github.com/swagger-api/swagger-node), [swagger-tools](https://github.com/apigee-127/swagger-tools), something else? – Helen Aug 16 '18 at 14:56
  • Using swagger-tools – cph2117 Aug 16 '18 at 15:22

0 Answers0