gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:41:40 24 4
gpt4 key购买 nike

我一直在寻找有关 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'


受规范启发的失败示例
    Duck:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
no_legs:
description: 'Number of webbed feet'
example: 2

我的问题是
  • 我正在查看的覆盖功能是否可用/支持?
  • 如果是这样,正确的做法是什么?

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

    最佳答案

    是的,这基本上是覆盖属性的方法。你在失败的例子中遇到了什么样的错误?它在 https://editor.swagger.io/ 工作正常至少。你记得指定 openapi: 3.0.0在文档的根目录?

    请注意,以下两个定义是相同的:

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

    关于openapi - 有没有办法覆盖 OAS3 中的属性描述和示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56354625/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com