[英]With drf-yasg, how can i show multiple openapi schemes?
Used: Django 2.2, drf-yasg 1.17.1, python 3.9
使用:
Django 2.2, drf-yasg 1.17.1, python 3.9
How can I show with drf-yasg multiple openapi schemes?如何使用 drf-yasg 显示多个 openapi 方案?
API returning different responses, depending on the request. API 根据请求返回不同的响应。
Basic response:基本回应:
Is it possible in drf-yasg to show responses like this?是否有可能在 drf-yasg 中显示这样的响应?
In the yaml file, this is implemented using oneOf
.在 yaml 文件中,这是使用
oneOf
实现的。
Code example:代码示例:
responses:
'200':
content:
application/json:
schema:
properties:
count:
type: integer
next:
type: string
previous:
type: string
results:
oneOf:
- $ref: '#/components/schemas/BaseStocks'
- $ref: '#/components/schemas/Apteka36.6Stocks'
- $ref: '#/components/schemas/FarmiyaStocks'
- $ref: '#/components/schemas/MailruStocks'
- $ref: '#/components/schemas/NeofarmStocks'
- $ref: '#/components/schemas/YandexStock'
- $ref: '#/components/schemas/UtekaStocks'
Is it possible to repeat such a construction with drf-yasg?是否可以用 drf-yasg 重复这样的构造?
Unfortunately this is not possible.不幸的是,这是不可能的。
oneOf
- has been added to OpenAPI 3.0, drf-yasg only supports OpenAPI 2.0 oneOf
- 已添加到 OpenAPI 3.0,drf-yasg 仅支持OpenAPI 2.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.