这个问题是后续问题这个类似的 https://stackoverflow.com/q/52595690/1571426- 正如@Helen 要求提出一个新问题。
数组类型模式似乎只接受“示例”,而不接受“示例”。以下架构会产生错误编辑器.swagger.io https://editor.swagger.io/ site:
info:
title: Example Inc. REST API version 1.0
version: '1.0'
openapi: 3.0.0
components:
schemas:
user_reference:
properties:
comment:
type: string
middle_name:
type: string
domain:
pattern: '^[0-9A-Za-z][0-9A-Za-z.-]*$'
type: string
id:
minimum: 1
type: integer
first_name:
type: string
last_name:
type: string
username:
pattern: '^[0-9A-Za-z_.@-]+$'
type: string
type: object
owners_reference_list:
type: array
items:
$ref: '#/components/schemas/user_reference'
examples:
by_site:
summary: Access by site and username
value:
- domain: example.com
username: jsmith
by_id:
value:
- id: 14
summary: Access by id
by_other:
summary: Access by other attributes
value:
- middle_name: X.
last_name: Smith
comments: Standard user
first_name: John
responses:
ok:
content:
application/json:
schema:
type: string
description: |
...
paths:
/users:
description: |
A user account ...
get:
parameters:
- description: |
...
content:
application/json:
schema:
$ref: '#/components/schemas/owners_reference_list'
name: owners_ref
required: false
in: query
responses:
'200':
$ref: '#/components/responses/ok'
但是如果我将“examples”属性替换为“example”,例如:
owners_reference_list:
type: array
items:
$ref: '#/components/schemas/user_reference'
example:
- domain: example.com
username: jsmith
然后就可以正常工作了。
所引用的问题的答案是 Swagger Editor 3.6.21 支持“examples”,@Helen 的评论表示 editor.swagger.io 网站正在使用版本 3.8.3。
架构不支持多个examples
,他们只支持一个example
.
多种的examples
只能用于:
- 请求机构:
requestBody.content.<media-type>.examples
- 回应:
responses.<code>.content.<media-type>.examples
- 使用的参数
content
关键词:<parameter>.content.<media-type>.examples
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)