You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2022/05/09 07:23:00 UTC
[jira] [Resolved] (CAMEL-18066) OpenApi Specification Generator: Add support for discriminator for xOf
[ https://issues.apache.org/jira/browse/CAMEL-18066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-18066.
---------------------------------
Fix Version/s: 3.17.0
Resolution: Fixed
> OpenApi Specification Generator: Add support for discriminator for xOf
> ----------------------------------------------------------------------
>
> Key: CAMEL-18066
> URL: https://issues.apache.org/jira/browse/CAMEL-18066
> Project: Camel
> Issue Type: Improvement
> Components: camel-openapi-java
> Affects Versions: 3.14.2
> Reporter: Johnathan Ingram
> Priority: Minor
> Fix For: 3.17.0
>
>
> 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
> {code:java}
> @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).
> } {code}
> will generate
> {code:java}
> "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"
> }
> },
> ...{code}
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)