Skip to content

Instantly share code, notes, and snippets.

@KimSoungRyoul
Created April 18, 2021 15:58
Show Gist options
  • Save KimSoungRyoul/0e6b6763f3260584c5ea0c4eda223151 to your computer and use it in GitHub Desktop.
Save KimSoungRyoul/0e6b6763f3260584c5ea0c4eda223151 to your computer and use it in GitHub Desktop.
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
discriminator: # JSON Object에서는 Object간 상속관계를 알수 없기때문에 이를 알기위한 구분자 필드가 필요하다.
propertyName: pet_type # 이 attr에 명시된 내용을 가지고 해당 JSON Object가 Dog Object인지 Cat Object인지를 구분할수있다.
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: boolean
breed:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
hunts:
type: boolean
age:
type: integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment