Open chaseacton opened 4 years ago
Hey @yonaskolb, have you had a chance to look at this?
Hi @chaseacton
Firstly your response is misconfigured: the array items would need to be a $ref
items:
$ref: '#/components/schemas/Pet'
Then it would generate as Pet
and not [String: Any]
Secondly at this time SwagGen does not support using discriminators in allOf
class hierarchies, only in oneOf
cases.
To get this to work you must declare it like this
paths:
/pets:
get:
responses:
'200':
description: fetch a list of pets
content:
application/json:
schema:
type: object
required:
- data
properties:
data:
type: array
items:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
discriminator:
propertyName: pet_type
mapping: # only required if pet_type is not Cat and Dog
cat: '#/components/schemas/Cat'
dog: '#/components/schemas/Dog'
I hope that helps!
Hi @yonaskolb, I'm back with a new
discriminator
issue. In this sample spec, the discriminator is only declared on the basePet
object and does not generate correctly.GetPets.Response
is empty.