Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ee71f0c
Fix XML annotations on model properties (JavaSpring)
chschu Aug 21, 2023
34c22ee
Add test for Jackson XML wrapper correctness
Philzen May 2, 2024
aa642a1
Add additional test cases to cover all xml applications in spec
Philzen May 21, 2024
9fa2c4c
Fix basename used instead of xmlName when items.xmlName is unset
Philzen May 22, 2024
eae9d8e
Harmonize spacing between Annotation attribute name and value
Philzen May 21, 2024
5341dfd
Refactor and group JAXB vs. Jackson XML annotations, only generate la…
Philzen May 21, 2024
cd3d5b4
Explicitly render `useWrapping = true` to @JacksonXmlElementWrapper
Philzen May 21, 2024
8889ff5
Move xml test spec to java resources folder (not spring specific)
Philzen May 22, 2024
d1fe5a4
Make test class name match class-under-test
Philzen May 24, 2024
2a8f38b
Add complete xml annotations test for Java generators
Philzen May 22, 2024
2b8e1cf
Fix Java PKMST generator not generating @JacksonXmlElementWrapper
Philzen May 24, 2024
7ec8287
Fix Java microprofile generator missing @JacksonXmlRootElement
Philzen Jun 6, 2024
0a76de9
Fix Java microprofile generator not using wrapper annotations and nam…
Philzen May 23, 2024
de30247
Fix Java Micronaut Client creating invalid (unclosed) @XmlAttribute a…
Philzen May 24, 2024
b5dd27b
Fix Micronaut Client using wrong localName for @JacksonXmlElementWrapper
Philzen May 24, 2024
c869b15
Fix Micronaut client rendering @JacksonXmlProperty annotation twice
Philzen May 24, 2024
d775104
Make Java Micronaut render @JacksonXmlElementWrapper(useWrapping=fals…
Philzen May 24, 2024
fa00e35
Fix Jackson element using `xml.name` when it should be `items.xml.name`
Philzen May 22, 2024
09bc55c
Fix JAXB element using `baseName` instead of `xmlName` when items.xml…
Philzen May 22, 2024
8785cde
Remove XML generation debug output from templates
Philzen May 22, 2024
9cc1176
Remove redundant newline between XML class annotations and class
Philzen May 22, 2024
1fb1108
Remove redundant newline between XML setter annotations and setter
Philzen May 22, 2024
8239d56
Fix multiline JavaDoc block indentation and format
Philzen May 22, 2024
fd10bc3
Simplify / condense xml annotation template into single lines
Philzen May 22, 2024
3b2097d
Harmonize spacing between Annotation attribute name and value
Philzen May 22, 2024
26be7d5
Remove unused jackson_annotations partial
Philzen May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
}}
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
@JsonInclude({{#isMap}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMap}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}})
{{#withXml}}
{{^isContainer}}
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}localName = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
{{#xmlName}}
// xmlName={{.}}
{{/xmlName}}
@JacksonXmlProperty({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/xmlName}}")
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}{{#xmlNamespace}}, namespace="{{.}}"{{/xmlNamespace}}{{#isXmlWrapped}}, localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{/isXmlWrapped}})
{{/isContainer}}
{{/withXml}}
{{#withXml}}
@JacksonXmlProperty(localName = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#isXmlAttribute}}, isAttribute = true{{/isXmlAttribute}}{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{#isContainer}}
@JacksonXmlElementWrapper({{#isXmlWrapped}}localName = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}", {{#xmlNamespace}}namespace = "{{.}}", {{/xmlNamespace}}{{/isXmlWrapped}}useWrapping = {{isXmlWrapped}})
{{/isContainer}}
{{/withXml}}
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,15 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
{{/jackson}}
{{#withXml}}
{{#isXmlAttribute}}
@XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlAttribute}}
{{^isXmlAttribute}}
{{^isContainer}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
// Is a container wrapped={{isXmlWrapped}}
{{#items}}
// items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}}
// items.example={{example}} items.type={{dataType}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/items}}
{{#isXmlWrapped}}
@XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{#isDateTime}}
@Xml{{#isXmlAttribute}}Attribute{{/isXmlAttribute}}{{^isXmlAttribute}}Element{{/isXmlAttribute}}(name = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{#isXmlWrapped}}
@XmlElementWrapper(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{/isXmlWrapped}}
{{^isXmlAttribute}}
{{#isDateTime}}
@XmlJavaTypeAdapter(OffsetDateTimeXmlAdapter.class)
{{/isDateTime}}
{{/isXmlAttribute}}
{{/isDateTime}}
{{/isXmlAttribute}}
{{/withXml}}
{{#gson}}
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
Expand Down Expand Up @@ -181,7 +168,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isMap}}

{{/isReadOnly}}
/**
/**
{{#description}}
* {{.}}
{{/description}}
Expand All @@ -198,7 +185,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#deprecated}}
* @deprecated
{{/deprecated}}
**/
*/
{{#deprecated}}
@Deprecated
{{/deprecated}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
{{/jackson}}
{{#withXml}}
{{#isXmlAttribute}}
@XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlAttribute}}
{{^isXmlAttribute}}
{{^isContainer}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
// Is a container wrapped={{isXmlWrapped}}
{{#items}}
// items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}}
// items.example={{example}} items.type={{dataType}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/items}}
{{#isXmlWrapped}}
@XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{/isXmlAttribute}}
@Xml{{#isXmlAttribute}}Attribute{{/isXmlAttribute}}{{^isXmlAttribute}}Element{{/isXmlAttribute}}(name = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{#isXmlWrapped}}
@XmlElementWrapper(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{/isXmlWrapped}}
{{/withXml}}
{{#gson}}
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
Expand Down Expand Up @@ -191,7 +176,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isMap}}

{{/isReadOnly}}
/**
/**
{{#description}}
* {{.}}
{{/description}}
Expand All @@ -208,7 +193,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#deprecated}}
* @deprecated
{{/deprecated}}
**/
*/
{{#deprecated}}
@Deprecated
{{/deprecated}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
{{/jackson}}
{{#withXml}}
{{#isXmlAttribute}}
@XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlAttribute}}
{{^isXmlAttribute}}
{{^isContainer}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
// Is a container wrapped={{isXmlWrapped}}
{{#items}}
// items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}}
// items.example={{example}} items.type={{dataType}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/items}}
{{#isXmlWrapped}}
@XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{/isXmlAttribute}}
@Xml{{#isXmlAttribute}}Attribute{{/isXmlAttribute}}{{^isXmlAttribute}}Element{{/isXmlAttribute}}(name = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{#isXmlWrapped}}
@XmlElementWrapper(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{/isXmlWrapped}}
{{/withXml}}
{{#gson}}
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
Expand Down Expand Up @@ -191,7 +176,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isMap}}

{{/isReadOnly}}
/**
/**
{{#description}}
* {{.}}
{{/description}}
Expand All @@ -208,7 +193,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#deprecated}}
* @deprecated
{{/deprecated}}
**/
*/
{{#deprecated}}
@Deprecated
{{/deprecated}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{{#withXml}}
@XmlAccessorType(XmlAccessType.FIELD)
{{#hasVars}} @XmlType(name = "{{classname}}", propOrder =
{ {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}}
}){{/hasVars}}
{{#hasVars}}@XmlType(name = "{{classname}}", propOrder =
{ {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}} }
){{/hasVars}}
{{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}}
{{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}}
{{> xmlAnnotation }}
{{/withXml}}
{{#jackson}}
@JsonPropertyOrder({
Expand All @@ -21,7 +20,7 @@
{{#description}}
/**
* {{{.}}}
**/
*/
{{/description}}
{{>additionalModelTypeAnnotations}}
{{#vendorExtensions.x-class-extra-annotation}}
Expand All @@ -35,12 +34,15 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
{{/jackson}}
{{#withXml}}
@XmlElement(name="{{baseName}}"{{#required}}, required = {{required}}{{/required}})
@Xml{{#isXmlAttribute}}Attribute{{/isXmlAttribute}}{{^isXmlAttribute}}Element{{/isXmlAttribute}}(name = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{#isXmlWrapped}}
@XmlElementWrapper(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{/isXmlWrapped}}
{{/withXml}}
{{#description}}
/**
* {{{.}}}
**/
* {{{.}}}
*/
{{/description}}
{{^withXml}}
{{#jsonb}}@JsonbProperty("{{baseName}}"){{/jsonb}}
Expand Down Expand Up @@ -71,7 +73,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
}
{{/withXml}}{{/vendorExtensions.x-has-readonly-properties}}
{{#vars}}
/**
/**
{{#description}}
* {{.}}
{{/description}}
Expand All @@ -88,7 +90,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
{{#deprecated}}
* @deprecated
{{/deprecated}}
**/
**/
{{#deprecated}}
@Deprecated
{{/deprecated}}
Expand All @@ -112,8 +114,8 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi

{{^isReadOnly}}
/**
* Set {{name}}
**/
* Set {{name}}
*/
{{#vendorExtensions.x-setter-extra-annotation}} {{{vendorExtensions.x-setter-extra-annotation}}}
{{/vendorExtensions.x-setter-extra-annotation}}{{#jackson}}{{> jackson_annotations}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
Expand Down Expand Up @@ -148,8 +150,8 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
{{/vars}}

/**
* Create a string representation of this pojo.
**/
* Create a string representation of this pojo.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
{{/jackson}}
{{#withXml}}
{{#isXmlAttribute}}
@XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlAttribute}}
{{^isXmlAttribute}}
{{^isContainer}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isContainer}}
{{#isContainer}}
// Is a container wrapped={{isXmlWrapped}}
{{#items}}
// items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}}
// items.example={{example}} items.type={{dataType}}
@XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/items}}
{{#isXmlWrapped}}
@XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
{{/isXmlWrapped}}
{{/isContainer}}
{{/isXmlAttribute}}
@Xml{{#isXmlAttribute}}Attribute{{/isXmlAttribute}}{{^isXmlAttribute}}Element{{/isXmlAttribute}}(name = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{#isXmlWrapped}}
@XmlElementWrapper(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
{{/isXmlWrapped}}
{{/withXml}}
{{#gson}}
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
Expand Down Expand Up @@ -182,7 +167,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isMap}}

{{/isReadOnly}}
/**
/**
{{#description}}
* {{.}}
{{/description}}
Expand All @@ -199,7 +184,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#deprecated}}
* @deprecated
{{/deprecated}}
**/
*/
{{#deprecated}}
@Deprecated
{{/deprecated}}
Expand Down Expand Up @@ -230,8 +215,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}}
@JsonIgnore
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#jackson}}{{> jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}}
public {{{datatypeWithEnum}}} {{getter}}() {
{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#jackson}}{{> jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
{{#isReadOnly}}{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}}
if ({{name}} == null) {
Expand Down
Loading