Swagger openApi 3所有输入/组件/参数
我试图使用OpenAPI3创建一个招摇过市的文档,但当我试图在参数定义中使用Swagger openApi 3所有输入/组件/参数,swagger,openapi,swagger-editor,Swagger,Openapi,Swagger Editor,我试图使用OpenAPI3创建一个招摇过市的文档,但当我试图在参数定义中使用allOf关键字时,会出现错误 components: parameters: idParam: name: id in: path description: ID of the boxx required: true schema: type: string format: int65 dataSourceI
allOf
关键字时,会出现错误
components:
parameters:
idParam:
name: id
in: path
description: ID of the boxx
required: true
schema:
type: string
format: int65
dataSourceID:
allOf:
- $ref: '#/components/parameters/idParam'
- name: dataSourceID
description: ID of the data source
组件处的架构错误。参数['dataSourceID']
不应具有其他属性
附加属性:allOf
是否可以重用另一个参数的值?可能以另一种方式?
allOf
仅在中受支持,用于实现<在参数
、路径
和其他位置不支持code>allOf
在您的示例中,最多可以为int65
定义一个可重用的模式,并从两个参数中引用它:
openapi:3.0.0
...
组件:
模式:
int65:
类型:字符串
格式:int65
参数:
Iparam:
姓名:id
在:路径
描述:boxx的ID
必填项:true
模式:
$ref:'#/components/schemas/int65'#我想allOf
可以在参数模式中使用,如下所示
allOf
只能在架构对象中使用。
由于参数,路径可能包含schema
对象,因此allOf
可以在参数中使用,如下所示
components:
parameters:
idParam:
name: id
in: path
description: ID of the boxx
required: true
schema:
type: string
format: int65
dataSourceID:
name: dataSourceID
in: path
description: dataSourceID of the boxx
schema:
allOf:
- $ref: '#/components/parameters/idParam'
- type: object
properties:
name:
type: string
description:
type: string
谢谢,尽管这有点令人失望,因为这是不可能的。@请随意选择以在OpenAPI规范存储库中提交功能请求:我猜行“allOf在参数、路径和其他位置不受支持。”用词不当,因为allOf在架构对象和参数上受支持,路径可能包含架构对象。因此,allOf也可以在参数下使用,即具有模式对象的路径。