Swagger Multiple Examples Not Showing

社会主义新天地 提交于 2021-02-10 05:13:46

问题


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:

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

回答1:


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


来源:https://stackoverflow.com/questions/52595690/swagger-multiple-examples-not-showing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!