Yelp / swagger_spec_validator

Other
104 stars 71 forks source link

empty array as default value in Open API Specification 3.0 #119

Open dabwali opened 5 years ago

dabwali commented 5 years ago

Hi Team,

Is there any way to define empty array as default value in Open API Specification. I want the below localConnections array to be initialized as empty array rather than null.

Port:
  type: object
  properties:
    id:
      type: string
    value:
      type: string
    localConnections:
      type: array
      items:
        $ref: '#/definitions/Connection'
macisamuele commented 5 years ago

Hey @dabwali the library does not support Open Api version 3. It does handles Swagger 1.2 and 2.0 only.

If your specs are Swagger 2.0 you could define the default value at type: array level

Port:
  type: object
  properties:
    id:
      type: string
    value:
      type: string
    localConnections:
      type: array
      default: []
      items:
        $ref: '#/definitions/Connection'