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

Neetha123

我正在手动编写 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:
    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'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章