Swagger 多个示例未显示 [英] Swagger Multiple Examples Not Showing

查看:90
本文介绍了Swagger 多个示例未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将示例添加到我的 swagger 文档中并在 swagger 编辑器上进行测试时,它永远不会显示在任何地方.有人可以举个例子说明多个例子实际上在任何地方显示吗?

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:

它来自:https://swagger.io/docs/specification/adding-示例/

这里是在线swagger编辑器上不显示任何examples的yaml示例:

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

推荐答案

多个 examples 显示在 Swagger UI 3.23.0+ 和 Swagger Editor 3.6.21+ 中:

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


在旧版本中,您可以使用单个 example 作为解决方法:

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

这篇关于Swagger 多个示例未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆