Swagger 多级鉴别器OpenAPI
问候并感谢您抽出时间。 我正在使用OpenAPI编写一些ReDoc文档,但找不到一种方法来正确地进行两级继承。这就是我所拥有的:Swagger 多级鉴别器OpenAPI,swagger,openapi,Swagger,Openapi,问候并感谢您抽出时间。 我正在使用OpenAPI编写一些ReDoc文档,但找不到一种方法来正确地进行两级继承。这就是我所拥有的: components: schemas: Pet: type: object required: - pet_type properties: pet_type: type: string discriminator: propertyName:
components:
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
discriminator:
propertyName: pet_type
mapping:
dogs: Dog
cats: Cat
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
name:
type: string
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: string
size:
type: string
discriminator:
propertyName: size
mapping:
large: '#/components/schemas/LargeDog'
medium: '#/components/schemas/MediumDog'
SmallDogs:
allOf:
- $ref: '#/components/schemas/Dog'
- type: object
LargeDogs:
allOf:
- $ref: '#/components/schemas/Dog'
- type: object
提前感谢。您正在做一些奇怪的事情,或者您的示例没有充分揭示问题的本质。对于狗的大小,您不需要使用鉴别器。下面的例子
components:
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
discriminator:
propertyName: pet_type
mapping:
dogs: Dog
cats: Cat
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
name:
type: string
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: string
size:
type: string
enum:
- large
- medium