[英]How can I configure "HTTPS" schemes with the drf-yasg auto-generated swagger page?
[英]With drf-yasg, how can i show multiple openapi schemes?
使用: Django 2.2, drf-yasg 1.17.1, python 3.9
如何使用 drf-yasg 显示多个 openapi 方案?
API 根据请求返回不同的响应。
基本回应:
是否有可能在 drf-yasg 中显示这样的响应?
在 yaml 文件中,这是使用oneOf
实现的。
代码示例:
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'
是否可以用 drf-yasg 重复这样的构造?
不幸的是,这是不可能的。
oneOf
- 已添加到 OpenAPI 3.0,drf-yasg 仅支持OpenAPI 2.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.