diff --git a/src/main/resources/handlebars/Java/typeInfoAnnotation.mustache b/src/main/resources/handlebars/Java/typeInfoAnnotation.mustache index f2a2e1c88f..52695c64fe 100644 --- a/src/main/resources/handlebars/Java/typeInfoAnnotation.mustache +++ b/src/main/resources/handlebars/Java/typeInfoAnnotation.mustache @@ -1,7 +1,14 @@ {{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) + @JsonSubTypes({ + {{#if discriminator.mapping}} + {{#each discriminator.mapping}} + @JsonSubTypes.Type(value = {{this}}.class, name = "{{@key}}"), + {{/each}} + {{else}} + {{#children}} + @JsonSubTypes.Type(value = {{classname}}.class, name = "{{name}}"), + {{/children}} + {{/if}} + }) +{{/jackson}} diff --git a/src/main/resources/handlebars/JavaInflector/typeInfoAnnotation.mustache b/src/main/resources/handlebars/JavaInflector/typeInfoAnnotation.mustache index f2a2e1c88f..52695c64fe 100644 --- a/src/main/resources/handlebars/JavaInflector/typeInfoAnnotation.mustache +++ b/src/main/resources/handlebars/JavaInflector/typeInfoAnnotation.mustache @@ -1,7 +1,14 @@ {{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) + @JsonSubTypes({ + {{#if discriminator.mapping}} + {{#each discriminator.mapping}} + @JsonSubTypes.Type(value = {{this}}.class, name = "{{@key}}"), + {{/each}} + {{else}} + {{#children}} + @JsonSubTypes.Type(value = {{classname}}.class, name = "{{name}}"), + {{/children}} + {{/if}} + }) +{{/jackson}} diff --git a/src/main/resources/handlebars/JavaJaxRS/typeInfoAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/typeInfoAnnotation.mustache index f2a2e1c88f..52695c64fe 100644 --- a/src/main/resources/handlebars/JavaJaxRS/typeInfoAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/typeInfoAnnotation.mustache @@ -1,7 +1,14 @@ {{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) + @JsonSubTypes({ + {{#if discriminator.mapping}} + {{#each discriminator.mapping}} + @JsonSubTypes.Type(value = {{this}}.class, name = "{{@key}}"), + {{/each}} + {{else}} + {{#children}} + @JsonSubTypes.Type(value = {{classname}}.class, name = "{{name}}"), + {{/children}} + {{/if}} + }) +{{/jackson}} diff --git a/src/main/resources/handlebars/JavaMicronaut/typeInfoAnnotation.mustache b/src/main/resources/handlebars/JavaMicronaut/typeInfoAnnotation.mustache index 9fbced41d8..52695c64fe 100644 --- a/src/main/resources/handlebars/JavaMicronaut/typeInfoAnnotation.mustache +++ b/src/main/resources/handlebars/JavaMicronaut/typeInfoAnnotation.mustache @@ -1,7 +1,14 @@ {{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} \ No newline at end of file + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) + @JsonSubTypes({ + {{#if discriminator.mapping}} + {{#each discriminator.mapping}} + @JsonSubTypes.Type(value = {{this}}.class, name = "{{@key}}"), + {{/each}} + {{else}} + {{#children}} + @JsonSubTypes.Type(value = {{classname}}.class, name = "{{name}}"), + {{/children}} + {{/if}} + }) +{{/jackson}}