swagger-server icon indicating copy to clipboard operation
swagger-server copied to clipboard

swagger server doesn't take in account default value

Open PavelPolyakov opened this issue 9 years ago • 1 comments
trafficstars

Hi,

Here is my swagger yaml:

swagger: "2.0"
info:
  title: Customers API
  description: Customers API
  version: "1.0.0"
host: localhost:3000
schemes:
  - http
  - https
basePath: /v1
produces:
  - application/json
paths:
  /customers:
    post:
      description: Creates new customer
      operationId: newCustomer
      parameters:
        - name: request
          in: body
          description: customer
          required: true
          schema:
            $ref: ./data-structures/NewCustomer.yaml
      responses:
        200:
          description: boolean
          schema:
            type: boolean
            default: false
definitions:
  Error:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: string

Which results to this response: image

Shouldn't it return false instead?

Regards,

PavelPolyakov avatar Jan 14 '16 16:01 PavelPolyakov

I came across this issue while looking for a solution - I'm experiencing the same thing. I have used both default and example keys, but it still responds with whatever is in the body of the POST request.

Adding a default or example response for GET requests seem to work. PUT and POST seems to just echo back what you send to it.

fmr avatar Mar 30 '16 07:03 fmr