swagger-parser
swagger-parser copied to clipboard
Parser does not Dereference Discriminator Mapping Targets
When providing a discriminator for subtypes you can provide a reference to the target type for each discriminator value (see https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/)
I would expect this to be correctly resolved to the target schema object. Instead it is treated as a string and left as a reference. This means the Discriminator.getMapping() method returns data that is useless for deserializing a response.
The following OpenAPI json definition for the discriminator:
"discriminator": {
"propertyName": "myDiscriminator",
"mapping": {
"type_a": "#/components/schemas/TypeA",
"type_b": "#/components/schemas/TypeB"
}
},
Produces a Discriminator instance (after python name mangling) like the following:
{
"mapping": {
"type_a": "#/components/schemas/TypeA",
"type_b": "#/components/schemas/TypeB"
},
"propertyName": "my_discriminator"
}
I would expect the values of the mapping HashMap to actually be the target classes, so that this Discriminator object can be used to dispatch to the correct subclass.