Skip to content

Commit

Permalink
fix: discriminator with enums #482
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Dec 19, 2020
1 parent 4e01773 commit c68e43f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/resources/one.of.2.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: '3.0.3'
info:
version: 1.0.0
title: Swagger
title: Swagger
servers:
- url: /v1
paths:
Expand Down Expand Up @@ -38,11 +38,13 @@ paths:
propertyName: pet_type
mapping:
cat: '#/components/schemas/CatObject'
kitty: '#/components/schemas/CatObject'
dog: '#/components/schemas/DogObject'
puppy: '#/components/schemas/DogObject'
responses:
'200':
description: Updated

/pets_all:
post:
description: Creates a new pet in the store.
Expand Down Expand Up @@ -80,6 +82,10 @@ components:
enum: [Dingo, Husky, Retriever, Shepherd]
pet_type:
type: string
# since we use an enum here
# add DogObject as an option
# so that the non-mapping / implied mapping tests can pass
enum: [dog, puppy, DogObject]

CatObject:
type: object
Expand All @@ -94,7 +100,11 @@ components:
type: integer
pet_type:
type: string

# since we use an enum here
# add CatObject as an option
# so that the non-mapping / implied mapping tests can pass
enum: [cat, kitty, CatObject]

Pet:
type: object
required:
Expand All @@ -106,7 +116,7 @@ components:
propertyName: pet_type

Dog: # "Dog" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Dog`-specific properties
allOf: # Combines the main `Pet` schema with `Dog`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
Expand All @@ -117,7 +127,7 @@ components:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
Cat: # "Cat" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Cat`-specific properties
allOf: # Combines the main `Pet` schema with `Cat`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
Expand Down

0 comments on commit c68e43f

Please sign in to comment.