Swagger-ui: how to set the default value for the array?

Created on 8 Jun 2017  路  7Comments  路  Source: swagger-api/swagger-ui

  • swagger-ui version 2.0
    the below is the part code:
      parameters:
      - in: "body"
        name: "body"
        description: ""
        required: true
        schema:
          type: "array"
          items:
            type: "string"
          default:
          - "aaaaa"
          - "bbbbb"

the code is invalid.

P2 lock-bot bug 3.x

Most helpful comment

@codepandy, if you need an example _for display purposes_, you can use example:

        schema:
          type: array
          items:
            type: string
          default:
          - aaaaa
          - bbbbb
          example:
          - aaaaa
          - bbbbb

All 7 comments

There's no swagger-ui version 2.0. Please provide the correct version.

@webron I use the editor is http://editor.swagger.io/#/

I use the version is the latest.

This seems like a bug then.

@webron
how to solve the problem?
the below code only can show the first value,but can't show multiple value.

      parameters:
      - in: "body"
        name: "body"
        description: ""
        required: true
        schema:
          type: "array"
          items:
            type: "string"
            enum:
            - "aaaaa"
            - "bbbbb"
            - "ccccc"

It's a bug, no workaround.

@codepandy, if you need an example _for display purposes_, you can use example:

        schema:
          type: array
          items:
            type: string
          default:
          - aaaaa
          - bbbbb
          example:
          - aaaaa
          - bbbbb

@hkosova You are a big star,thank you very much.
just use the "example" property,don't need the "default" property.

Was this page helpful?
0 / 5 - 0 ratings