Freddy Bonda
Freddy Bonda

Reputation: 1259

Swagger Multiple Examples Not Showing

When I add examples into my swagger doc and test it on the swagger editor, then it never shows anywhere. Could someone give me an example of where multiple examples are actually showing anywhere?

Here is an example of how multiple examples are added: enter image description here

it is from: https://swagger.io/docs/specification/adding-examples/

Here is an example of yaml that does not display any examples on the online swagger editor:

openapi: 3.0.0
info:
  title: Some API
  version: 1.0.0
paths:
  /logon:
    get:
      summary: Login user
      tags:
        - '/logon'
      parameters:
        - name: Client
          in: query
          required: true
          examples:
            zero:
              value: '0'
              summary: A sample limit value
            max:
              value: '50'
              summary: A sample limit value
          schema:
            type: string
      responses:
        '200':
          description: Success response

Upvotes: 4

Views: 13211

Answers (1)

Helen
Helen

Reputation: 97677

Multiple examples are displayed in Swagger UI 3.23.0+ and Swagger Editor 3.6.21+:

Swagger UI displays multiple examples using a drop-down list


In older versions, you can use a single example as a workaround:

      parameters:
        - name: Client
          in: query
          required: true
          example: '50'  # <-----
          schema:
            type: string

Upvotes: 9

Related Questions