不应该有额外的属性
should NOT have additional properties
我是 Open API 规范的新手(我使用的是 3.0)。我正在玩 swagger Editor 在线工具,我收到一个奇怪的错误:
"不应该有额外的属性
附加属性:数据 1、数据 2"
这是我正在使用的 YAML 文件示例:
paths:
/api/assignment:
post:
tags:
- Assignment
summary: "Endpoint to create Resources in system"
description: "This endpoint will create blah blah"
operationId: CreateResource
parameters:
- name: assignment
in: body
description: "This is an object to be sent"
required: true
schema:
type: object
properties:
Ganesh:
type: integer
Test:
type: string
RefClaim:
Data1:
FirstName:
type: string
LastName:
type: string
Data2:
FirstName2:
type: string
LastName2:
type: string
我已经看过所有提出的问题并尝试过这些问题,但我无法得到答案。
注意:我使用的是 Open Api 规范 3.0.1
有几个问题:
1) in: body
参数是 OpenAPI 2.0 的东西。 OpenAPI 3.0 改为使用 requestBody
。
2) Nested objects 还需要 type: object
和 properties
关键字。
正确的版本是:
paths:
/api/assignment:
post:
tags:
- Assignment
summary: "Endpoint to create Resources in system"
description: "This endpoint will create blah blah"
operationId: CreateResource
requestBody: # <-----------
required: true
content:
application/json:
schema:
type: object
properties:
Ganesh:
type: integer
Test:
type: string
RefClaim:
type: object # <-----------
properties: # <-----------
Data1:
type: object # <-----------
properties: # <-----------
FirstName:
type: string
LastName:
type: string
Data2:
type: object # <-----------
properties: # <-----------
FirstName2:
type: string
LastName2:
type: string
我是 Open API 规范的新手(我使用的是 3.0)。我正在玩 swagger Editor 在线工具,我收到一个奇怪的错误:
"不应该有额外的属性 附加属性:数据 1、数据 2"
这是我正在使用的 YAML 文件示例:
paths:
/api/assignment:
post:
tags:
- Assignment
summary: "Endpoint to create Resources in system"
description: "This endpoint will create blah blah"
operationId: CreateResource
parameters:
- name: assignment
in: body
description: "This is an object to be sent"
required: true
schema:
type: object
properties:
Ganesh:
type: integer
Test:
type: string
RefClaim:
Data1:
FirstName:
type: string
LastName:
type: string
Data2:
FirstName2:
type: string
LastName2:
type: string
我已经看过所有提出的问题并尝试过这些问题,但我无法得到答案。 注意:我使用的是 Open Api 规范 3.0.1
有几个问题:
1) in: body
参数是 OpenAPI 2.0 的东西。 OpenAPI 3.0 改为使用 requestBody
。
2) Nested objects 还需要 type: object
和 properties
关键字。
正确的版本是:
paths:
/api/assignment:
post:
tags:
- Assignment
summary: "Endpoint to create Resources in system"
description: "This endpoint will create blah blah"
operationId: CreateResource
requestBody: # <-----------
required: true
content:
application/json:
schema:
type: object
properties:
Ganesh:
type: integer
Test:
type: string
RefClaim:
type: object # <-----------
properties: # <-----------
Data1:
type: object # <-----------
properties: # <-----------
FirstName:
type: string
LastName:
type: string
Data2:
type: object # <-----------
properties: # <-----------
FirstName2:
type: string
LastName2:
type: string