Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
3.14.2
-
None
-
Unknown
Description
Add support for the OpenApi spec 'discriminator' allowing for explicit selection of a schema type based on a property value.
https://redocly.com/docs/resources/discriminator/
This class
@Schema(oneOf = { XOfFormA.class, XOfFormB.class }, discriminatorProperty = "code", discriminatorMapping = { @DiscriminatorMapping(value = "a-123", schema = XOfFormA.class), @DiscriminatorMapping(value = "b-456", schema = XOfFormB.class) }) public interface OneOfForm { // The discriminator explicitly declares which property you can inspect to determine the object type. // The discriminator must apply to the same level of the schema it is declared in (common mistake when using nested objects). }
will generate
"components" : { "schemas" : { "OneOfForm" : { "oneOf" : [ { "$ref" : "#/components/schemas/XOfFormA" }, { "$ref" : "#/components/schemas/XOfFormB" } ], "discriminator" : { "propertyName" : "code", "mapping" : { "a-123" : "#/components/schemas/org.apache.camel.openapi.model.XOfFormA", "b-456" : "#/components/schemas/org.apache.camel.openapi.model.XOfFormB" } }, ...
Attachments
Issue Links
- links to