我正在手动编写摇摇欲坠的文档。但是我遇到了一些错误Should be object
我不知道为什么我在下面的代码中出错。
events:
$ref: "#/def/Events"
Events:
type: "object"
properties:
oneOf:
- $ref: '#/def/ClassRef'
- $ref: '#/def/TypeRef'
- $ref: '#/def/EventRef'
- $ref: '#/def/MarketRef'
- $ref: '#/def/OutcomeRef'
ClassRef:
type: "object"
properties:
classRef:
type: "string"
TypeRef:
type: "object"
properties:
typeRef:
type: "string"
EventRef:
type: "object"
properties:
eventRef:
type: "string"
MarketRef:
type: "object"
properties:
marketRef:
type: "string"
OutcomeRef:
type: "object"
properties:
outcomeRef:
type: "string"
我在ClassRef行中收到此错误。有人可以帮我吗
[OpenAPI 2.0(swagger: '2.0'
)不支持oneOf
,您需要OpenAPI 3.0(openapi: 3.0.0
)才能使用oneOf
。
假设您使用的是OpenAPI 3.0,并且所有架构都位于components/schemas
部分中,则按如下所示更改Events
架构:
Events:
oneOf:
- $ref: '#/components/schemas/ClassRef'
- $ref: '#/components/schemas/TypeRef'
- $ref: '#/components/schemas/EventRef'
- $ref: '#/components/schemas/MarketRef'
- $ref: '#/components/schemas/OutcomeRef'