【发布时间】:2019-12-21 18:15:27
【问题描述】:
我正在尝试实现 OpenAPI 定义,其中我将允许值的共享完整列表定义为枚举,然后在不同位置使用值的子组来显示每种情况下允许的值。
使用the enum spec on Swagger.io 中的示例,如果我有这样的定义:
paths:
/products:
get:
parameters:
- in: query
name: color
required: true
schema:
$ref: '#/components/schemas/Color'
responses:
'200':
description: OK
components:
schemas:
Color:
type: string
enum:
- black
- white
- red
- green
- blue
那么是否可以定义例如两个不同的路径,它们以颜色作为参数,但其中一个只接受 black 或 white 而另一个接受所有颜色?
【问题讨论】: