我想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:,但无法让它工作.
我很难弄清楚如何在swagger 2.0中嵌套模型.
目前我有:
SomeModel:
properties:
prop1:
type: string
prop2:
type: integer
prop3:
type:
$ref: OtherModel
OtherModel:
properties:
otherProp:
type: string
Run Code Online (Sandbox Code Playgroud)
我尝试了很多其他方法:
prop3:
$ref: OtherModel
# or
prop3:
schema:
$ref: OtherModel
# or
prop3:
type:
schema:
$ref: OtherModel
Run Code Online (Sandbox Code Playgroud)
以上都不适用.
但是,使用数组工作正常:
prop3:
type: array
items:
$ref: OtherModel
Run Code Online (Sandbox Code Playgroud)