How to reproduce the inheritance behavior of allOf in Swagger using the OpenAPI 3.1 spec? - Stack Overflow

The Swagger documentation gives an example of how to implement model inheritance in OpenAPI:components

The Swagger documentation gives an example of how to implement model inheritance in OpenAPI:

components:
  schemas:
    BasicErrorModel:
      type: object
      required:
        - message
        - code
      properties:
        message:
          type: string
        code:
          type: integer
          minimum: 100
          maximum: 600
    ExtendedErrorModel:
      allOf: # Combines the BasicErrorModel and the inline model
        - $ref: "#/components/schemas/BasicErrorModel"
        - type: object
          required:
            - rootCause
          properties:
            rootCause:
              type: string

When using the 3.0 version of the OpenAPI specification, this works as intended, and the ExtendedErrorModel has all properties of both the base and derived object:

Switching to the 3.1 version of the specification (supported in the "next" web editor), however, breaks this example, treating the siblings as separate and leaving the ref as text:

Is this expected behavior given the semantic changes in the 3.1 spec? If so, is there a replacement for the mechanism?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744404010a4572534.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信