Swagger 文档错误“应该是对象”

Swagger Documentation error `Should be object`

我正在手动编写 swagger 文档。但是我遇到了一些错误 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:  # <--- I get the "should be object" error here
    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'