小编zud*_*uda的帖子

有没有办法覆盖 OAS3 中的属性描述和示例?

我一直在寻找有关 OAS3 中继承的资源,但我得到的最接近的是https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md以上没有答案我是寻找。

这是工作示例

components:
  schemas:
    Pet:
      properties:
        no_legs:
          description: "Number of legs"
          type: number
          example: 4
    Duck:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            no_legs:
              example: 2
      properties:
        no_legs:
          description: 'Number of webbed feet'

Run Code Online (Sandbox Code Playgroud)

受规范启发的失败示例

    Duck:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            no_legs:
              description: 'Number of webbed feet'
              example: 2
Run Code Online (Sandbox Code Playgroud)

我的问题是

  • 我正在查看的覆盖功能是否可用/支持?

  • 如果是这样,正确的做法是什么?

我知道我可以使用组合来解决这个问题,但我会重复很多定义。

openapi

5
推荐指数
1
解决办法
1855
查看次数

标签 统计

openapi ×1