From 2461b1194e4e4f0c58f0b904de83128bc98ae0c4 Mon Sep 17 00:00:00 2001 From: maushomu <36569914+maushomu@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:44:14 +0200 Subject: [PATCH 1/3] withXml support in pojo.mustache --- .../main/resources/JavaJaxRS/spec/pojo.mustache | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache index 441b84942298..0c0376729671 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache @@ -7,13 +7,23 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonTypeName; +{{#withXml}} +import {{javaxPackage}}.xml.bind.annotation.XmlElement; +import {{javaxPackage}}.xml.bind.annotation.XmlRootElement; +import {{javaxPackage}}.xml.bind.annotation.XmlAccessType; +import {{javaxPackage}}.xml.bind.annotation.XmlAccessorType; +import {{javaxPackage}}.xml.bind.annotation.XmlType; +import {{javaxPackage}}.xml.bind.annotation.XmlEnum; +import {{javaxPackage}}.xml.bind.annotation.XmlEnumValue; +{{/withXml}} + {{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{#description}}/** * {{.}} **/{{/description}} {{#useSwaggerAnnotations}}{{#description}}@ApiModel(description = "{{{.}}}"){{/description}}{{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}} @org.eclipse.microprofile.openapi.annotations.media.Schema({{#title}}title="{{{.}}}", {{/title}}{{#description}}description="{{{.}}}"{{/description}}{{^description}}description=""{{/description}}){{/useMicroProfileOpenAPIAnnotations}} @JsonTypeName("{{name}}") -{{>generatedAnnotation}}{{>additionalModelTypeAnnotations}} +{{>generatedAnnotation}}{{>additionalModelTypeAnnotations}}{{>xmlPojoAnnotation}} {{#vendorExtensions.x-class-extra-annotation}} {{{vendorExtensions.x-class-extra-annotation}}} {{/vendorExtensions.x-class-extra-annotation}} @@ -92,6 +102,9 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens return this; } + {{#withXml}} + @XmlElement(name="{{baseName}}"{{#required}}, required = {{required}}{{/required}}) + {{/withXml}} {{#vendorExtensions.x-extra-annotation}}{{{vendorExtensions.x-extra-annotation}}}{{/vendorExtensions.x-extra-annotation}}{{#useSwaggerAnnotations}} @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useSwaggerAnnotations}}{{#useMicroProfileOpenAPIAnnotations}} @org.eclipse.microprofile.openapi.annotations.media.Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useMicroProfileOpenAPIAnnotations}} From 4288c5e9020663901f41970dc3b5e256c20e8be9 Mon Sep 17 00:00:00 2001 From: maushomu <36569914+maushomu@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:45:01 +0200 Subject: [PATCH 2/3] Create xmlPojoAnnotation.mustache --- .../resources/JavaJaxRS/spec/xmlPojoAnnotation.mustache | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 modules/openapi-generator/src/main/resources/JavaJaxRS/spec/xmlPojoAnnotation.mustache diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/xmlPojoAnnotation.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/xmlPojoAnnotation.mustache new file mode 100644 index 000000000000..f683cc407c5e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/xmlPojoAnnotation.mustache @@ -0,0 +1,8 @@ +{{#withXml}} + @XmlAccessorType(XmlAccessType.FIELD) + {{#hasVars}} @XmlType(name = "{{classname}}", propOrder = + { {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}} + }){{/hasVars}} + {{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}} + {{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}} +{{/withXml}} From 73f8646ab27938101fe0dcb1be2945957dd0301b Mon Sep 17 00:00:00 2001 From: maushomu <36569914+maushomu@users.noreply.github.com> Date: Wed, 15 Oct 2025 10:02:22 +0200 Subject: [PATCH 3/3] withXml support in enumClass.mustache --- .../src/main/resources/JavaJaxRS/spec/enumClass.mustache | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache index d9b745524085..53d94164f786 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/enumClass.mustache @@ -1,7 +1,11 @@ +{{#withXml}} +@XmlType(name="{{datatypeWithEnum}}") +@XmlEnum({{dataType}}.class) +{{/withXml}} {{>additionalEnumTypeAnnotations}}public enum {{datatypeWithEnum}} { {{#allowableValues}} - {{#enumVars}}{{name}}({{dataType}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}} + {{#enumVars}}{{#withXml}}@XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}){{/withXml}}{{name}}({{dataType}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}} {{/allowableValues}}