我在编写我的招摇文件时遇到问题。当我描述一个参数时,描述被同一参数的$ref的描述所重载(参见下面的示例)。
a-body:
description: The body
type: object
properties:
my_param:
description: Full description
$ref: '#/definitions/reference'
definitions:
reference:
type: object
required: [req]
description: an http reference
properties:
req:
type: string
结果:描述已重载
有人可以帮助我度过难关吗?
$ref
覆盖其所有同级属性 - 这就是$ref
的工作方式。您可以尝试使用以下方法解决此问题:
my_param:
description: Full description
allOf:
- $ref: '#/definitions/reference'
这将在 Swagger Editor 和 Swagger UI 中工作。
OpenAPI 规范存储库中还有一个功能请求,以提供更好的方法将$ref
与其他属性相结合。