Skip to content

Commit

Permalink
java-jaxrs: Add more metadata annotations to enums and improve `@Sche…
Browse files Browse the repository at this point in the history
…ma` annotations on models
  • Loading branch information
karlvr committed Aug 22, 2024
1 parent bfdfdfa commit 2bc3447
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/khaki-avocados-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@openapi-generator-plus/java-jaxrs-generator-common": minor
"@openapi-generator-plus/java-jaxrs-server-generator": minor
---

Add more metadata annotations to enums and improve `@Schema` annotations on models
3 changes: 1 addition & 2 deletions packages/java-jaxrs-common/templates/enum.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package {{modelPackage}};
{{#with enum}}
{{>frag/pojoDocumentation}}
{{>generatedAnnotation}}
@{{javax}}.xml.bind.annotation.XmlType(name = "{{className name}}")
@{{javax}}.xml.bind.annotation.XmlEnum({{enumValueNativeType}}.class)
{{>frag/enumHeader}}
public enum {{className name}} {
{{>enumContents}}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/java-jaxrs-common/templates/enumNested.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{{javax}}.xml.bind.annotation.XmlType(name = "{{className name}}")
@{{javax}}.xml.bind.annotation.XmlEnum({{enumValueNativeType}}.class)
{{>frag/pojoDocumentation}}
{{>frag/enumHeader}}
public enum {{className name}} {
{{>enumContents}}
}
9 changes: 9 additions & 0 deletions packages/java-jaxrs-common/templates/frag/enumHeader.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{>hooks/enumHeaderAnnotations}}
{{#if serializedName}}
@{{javax}}.xml.bind.annotation.XmlRootElement(name = {{{stringLiteral serializedName}}})
{{/if}}
@{{javax}}.xml.bind.annotation.XmlType(name = "{{className name}}")
@{{javax}}.xml.bind.annotation.XmlEnum({{enumValueNativeType}}.class)
{{#if deprecated}}
@java.lang.Deprecated
{{/if}}
2 changes: 1 addition & 1 deletion packages/java-jaxrs-common/templates/frag/pojoHeader.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{>hooks/pojoHeaderAnnotations}}
{{#if serializedName}}
@{{javax}}.xml.bind.annotation.XmlRootElement(name = "{{{serializedName}}}")
@{{javax}}.xml.bind.annotation.XmlRootElement(name = {{{stringLiteral serializedName}}})
{{/if}}
{{#if discriminator}}
@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY, property = "{{{discriminator.serializedName}}}")
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@io.swagger.v3.oas.annotations.media.Schema({{#join ', '}}
{{#if serializedName}}
name = {{{stringLiteral serializedName}}}
{{/if}}
{{#if description}}
description = {{{stringLiteral description}}}
{{/if}}
{{#if deprecated}}
deprecated = true
{{/if}}
{{/join}})
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
@io.swagger.v3.oas.annotations.media.Schema(name = "{{#if serializedName}}{{{serializedName}}}{{/if}}"{{#if description}}, description = {{{stringLiteral description}}}{{/if}}{{#if discriminator}}, discriminatorProperty = "{{{discriminator.serializedName}}}"{{/if}})
@io.swagger.v3.oas.annotations.media.Schema({{#join ', '}}
{{#if serializedName}}
name = {{{stringLiteral serializedName}}}
{{/if}}
{{#if description}}
description = {{{stringLiteral description}}}
{{/if}}
{{#if discriminator}}
discriminatorProperty = {{{stringLiteral discriminator.serializedName}}}
{{/if}}
{{#if deprecated}}
deprecated = true
{{/if}}
{{/join}})

0 comments on commit 2bc3447

Please sign in to comment.