The discriminator is used with anyOf or oneOf keywords only.
Side note
This also breaks openapi based code generators that properly support polymorphism honoring discriminators
Solution
Use the result of the invocation of GenerateConcreteSchema, filling the anyOf/oneOf field. More specifically, we think that oneOf better suits this use case.
Problem
The problematic line is this: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/e727e8d53cd9f7edebe5faa6b8bf183e19afb0c6/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs#L416
This line properly generates subtype definitions but doesn't populate any of the
anyOf
/oneOf
properties, resulting in a "broken" swagger document.Quoting the Swagger doc:
Side note
This also breaks openapi based code generators that properly support polymorphism honoring discriminators
Solution
Use the result of the invocation of
GenerateConcreteSchema
, filling theanyOf
/oneOf
field. More specifically, we think that oneOf better suits this use case.