我在我的模式中有这样的模式对象定义swagger.yaml:
User:
type: object
properties:
username:
type: string
description: the user name
colors:
type: array
items: {
type: string,
enum: [ "red", "blue", "green" ]
}
description: user must have one or more colors associated
required:
- username
- colors
Run Code Online (Sandbox Code Playgroud)
但是,生成的服务器仍然很乐意接受使用此架构对象的POST请求作为不包含任何colors字段的必需body参数.
我是否可以在模式对象中color始终需要字段的方式配置Swagger,User理想情况下还必须包含枚举中的至少一个或多个项目?
我正在为API编写一个昂首阔步的定义文件.API是用于GET请求的
/path/to/my/api:
get:
summary: My Custom API
description: |
Gets a List of FooBar IDs
produces:
- application/json
tags:
- FooBar
responses:
"200":
description: successful operation
schema:
$ref: "#/definitions/MyCustomType"
Run Code Online (Sandbox Code Playgroud)
...
MyCustomType:
type: object
properties:
myCustomObject
type: ??? # list of string?
Run Code Online (Sandbox Code Playgroud)