我在Swagger.yaml
中有以下陈述Content:
type: object
properties:
text:
type: string
image:
ref: "#/definitions/Image"
allowEmptyValue: true
我不允许获得其他属性:allowEmptyValue作为错误
如何使图像可选?IE可能仅是文本没有图像
allowEmptyValue
仅适用于查询参数,意味着另一件事 - 包括参数,但其值可能为空,如 ?param=
。
在架构中,所有属性均为默认情况下。您可以通过将它们包括在required
数组中来确保某些属性。required
中未列出的属性被认为是可选的。
Content:
type: object
properties:
text:
type: string
image:
ref: "#/definitions/Image"
# text is required, image is optional
required:
- text