oneOf in Swagger schema does not work

前端 未结 3 1484
死守一世寂寞
死守一世寂寞 2020-12-07 00:49

I want to define PaymentMethod as below. Is oneOf supported in swagger.yaml?

PaymentMethod:
      oneOf         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 01:30

    oneOf is supported in OpenAPI version 3 (openapi: 3.0.0), but not in Swagger version 2 (swagger: '2.0').

    PaymentMethod:
      oneOf:
        - $ref: '#/components/schemas/NewPaymentMethod'
        - $ref: '#/components/schemas/ExistPaymentMethod'
    

    GitHub issue ref: https://github.com/OAI/OpenAPI-Specification/issues/333

    For a list of changes in OpenAPI 3.0 compared to 2.0, see: https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/

提交回复
热议问题