当我将示例添加到我的 swagger 文档中并在 swagger 编辑器上进行测试时,它永远不会显示在任何地方。有人能给我一个例子,说明多个例子实际上在任何地方显示吗?
它来自:https : //swagger.io/docs/specification/adding-examples/
下面是一个 yaml 示例,它examples在在线 swagger 编辑器上不显示任何内容:
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
Run Code Online (Sandbox Code Playgroud)
多个examples显示在 Swagger UI 3.23.0+ 和 Swagger Editor 3.6.21+ 中:

在旧版本中,您可以使用单个example作为解决方法:
parameters:
- name: Client
in: query
required: true
example: '50' # <-----
schema:
type: string
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7653 次 |
| 最近记录: |