rdr*_*rey 13 swagger swagger-2.0
我想definitions在查询字符串中使用作为参数定义的一部分定义的枚举.
我在definitionsSwagger 2.0规范文件中定义了Swagger Enum .
OperationType:
type: string
enum:
- registration
- renewal
Run Code Online (Sandbox Code Playgroud)
我可以在其他定义中创建对它的引用:
Operation:
type: object
properties:
name:
type: string
type:
$ref: '#/definitions/OperationType'
Run Code Online (Sandbox Code Playgroud)
我可以使用schema标签在参数为时引用它in: body,但不是在它的时候in: query
- name: operation
in: body
description: description
schema:
$ref: '#/definitions/OperationType'
Run Code Online (Sandbox Code Playgroud)
我试着放弃schema:并提供参考enum:,但无法让它工作.
这在 OpenAPI 3.0 中是可能的。所有参数现在都使用 a schema,并且通过扩展,可以$ref使用模式。
openapi: 3.0.0
...
paths:
/something:
get:
parameters:
- in: query
name: action
schema:
$ref: '#/components/schemas/OperationType'
...
components:
schemas:
OperationType:
type: string
enum:
- registration
- renewal
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10335 次 |
| 最近记录: |