mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 06:26:12 +00:00
[JAVA] [SPRING] [PKMST] [MICRONAUT] XML wireformat: Fix Jackson useWrapping=false, JAXB+Jackson namespaces (#18870)
* Fix XML annotations on model properties (JavaSpring) * generate JAXB annotations for attributes and elements * generate wrapper annotations (JAXB and Jackson) * use XML config from items for annotations of containers * Add test for Jackson XML wrapper correctness * Add additional test cases to cover all xml applications in spec Test now covers all use cases described in - https://web.archive.org/web/20240424203304/https://swagger.io/docs/specification/data-models/representing-xml/ - https://spec.openapis.org/oas/v3.0.0#xml-arrays * Fix basename used instead of xmlName when items.xmlName is unset See last example in spec: https://spec.openapis.org/oas/v3.0.0#xml-arrays * Harmonize spacing between Annotation attribute name and value * Refactor and group JAXB vs. Jackson XML annotations, only generate latter if enabled This is in line with the way the class annotations in `xmlAnnotations.mustache` are rendered – which only renders the `@Jackson`… xml annotations if additionalProperty jackson is true. Also reorder annotation attributes in the following order: - localName/name - namespace (optional) - isAttribute/useWrapping (optional) * Explicitly render `useWrapping = true` to @JacksonXmlElementWrapper This was slightly inspired by @jzrebiec via PR #5371. Wrapping is the default since Jackson 2.1 – so explicitly rendering this will: - make generated model work out-of-the-box in Jackson 2.0 for instance - ensure the models still work if the local `XmlWrapper` was configured with `useXmlWrapper(false)` * Move xml test spec to java resources folder (not spring specific) * Make test class name match class-under-test This makes discovery & cross-navigation in IDE easier. * Add complete xml annotations test for Java generators * Fix Java PKMST generator not generating @JacksonXmlElementWrapper * Fix Java microprofile generator missing @JacksonXmlRootElement * Fix Java microprofile generator not using wrapper annotations and namespaces * Fix Java Micronaut Client creating invalid (unclosed) @XmlAttribute annotations * Fix Micronaut Client using wrong localName for @JacksonXmlElementWrapper * Fix Micronaut client rendering @JacksonXmlProperty annotation twice * Make Java Micronaut render @JacksonXmlElementWrapper(useWrapping=false) for non-wrapped elements * Fix Jackson element using `xml.name` when it should be `items.xml.name` Closes #5989 Closes #3223 Relates to #9371 * Fix JAXB element using `baseName` instead of `xmlName` when items.xmlName is unset * Remove XML generation debug output from templates * Remove redundant newline between XML class annotations and class Brings the SpringCodegen in line with other Java Codegen's * Remove redundant newline between XML setter annotations and setter * Fix multiline JavaDoc block indentation and format * Simplify / condense xml annotation template into single lines May look a bit more complex, but cuts out a lot of repetitiveness. Also reorders annotation attributes in the following order: - localName/name - namespace (optional) - isAttribute/useWrapping (optional) * Harmonize spacing between Annotation attribute name and value * Remove unused jackson_annotations partial Was not referenced anywhere in java-helidon resources folder --------- Co-authored-by: Christian Schuster <christian@dnup.de>
This commit is contained in:
@@ -25,7 +25,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
**/
|
||||
*/
|
||||
|
||||
public class Category {
|
||||
|
||||
@@ -35,17 +35,17 @@ public class Category {
|
||||
@JsonbProperty("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
**/
|
||||
* Set id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -55,17 +55,17 @@ public class Category {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
**/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
**/
|
||||
* Set name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -77,8 +77,8 @@ public class Category {
|
||||
|
||||
|
||||
/**
|
||||
* Create a string representation of this pojo.
|
||||
**/
|
||||
* Create a string representation of this pojo.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
**/
|
||||
*/
|
||||
|
||||
public class ModelApiResponse {
|
||||
|
||||
@@ -38,17 +38,17 @@ public class ModelApiResponse {
|
||||
@JsonbProperty("message")
|
||||
private String message;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get code
|
||||
* @return code
|
||||
**/
|
||||
**/
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set code
|
||||
**/
|
||||
* Set code
|
||||
*/
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
@@ -58,17 +58,17 @@ public class ModelApiResponse {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get type
|
||||
* @return type
|
||||
**/
|
||||
**/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type
|
||||
**/
|
||||
* Set type
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
@@ -78,17 +78,17 @@ public class ModelApiResponse {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get message
|
||||
* @return message
|
||||
**/
|
||||
**/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set message
|
||||
**/
|
||||
* Set message
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
@@ -100,8 +100,8 @@ public class ModelApiResponse {
|
||||
|
||||
|
||||
/**
|
||||
* Create a string representation of this pojo.
|
||||
**/
|
||||
* Create a string representation of this pojo.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
**/
|
||||
*/
|
||||
|
||||
public class Order {
|
||||
|
||||
@@ -85,25 +85,25 @@ public class Order {
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
**/
|
||||
* Order Status
|
||||
*/
|
||||
@JsonbProperty("status")
|
||||
private StatusEnum status;
|
||||
|
||||
@JsonbProperty("complete")
|
||||
private Boolean complete = false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
**/
|
||||
* Set id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -113,17 +113,17 @@ public class Order {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get petId
|
||||
* @return petId
|
||||
**/
|
||||
**/
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set petId
|
||||
**/
|
||||
* Set petId
|
||||
*/
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
@@ -133,17 +133,17 @@ public class Order {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get quantity
|
||||
* @return quantity
|
||||
**/
|
||||
**/
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set quantity
|
||||
**/
|
||||
* Set quantity
|
||||
*/
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
@@ -153,17 +153,17 @@ public class Order {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get shipDate
|
||||
* @return shipDate
|
||||
**/
|
||||
**/
|
||||
public Date getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shipDate
|
||||
**/
|
||||
* Set shipDate
|
||||
*/
|
||||
public void setShipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
@@ -173,17 +173,17 @@ public class Order {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Order Status
|
||||
* @return status
|
||||
**/
|
||||
**/
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status
|
||||
**/
|
||||
* Set status
|
||||
*/
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
@@ -193,17 +193,17 @@ public class Order {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get complete
|
||||
* @return complete
|
||||
**/
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set complete
|
||||
**/
|
||||
* Set complete
|
||||
*/
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
@@ -215,8 +215,8 @@ public class Order {
|
||||
|
||||
|
||||
/**
|
||||
* Create a string representation of this pojo.
|
||||
**/
|
||||
* Create a string representation of this pojo.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -30,7 +30,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
**/
|
||||
*/
|
||||
|
||||
public class Pet {
|
||||
|
||||
@@ -92,22 +92,22 @@ public class Pet {
|
||||
}
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
**/
|
||||
* pet status in the store
|
||||
*/
|
||||
@JsonbProperty("status")
|
||||
private StatusEnum status;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
**/
|
||||
* Set id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -117,17 +117,17 @@ public class Pet {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get category
|
||||
* @return category
|
||||
**/
|
||||
**/
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set category
|
||||
**/
|
||||
* Set category
|
||||
*/
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
@@ -137,17 +137,17 @@ public class Pet {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
**/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
**/
|
||||
* Set name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -157,17 +157,17 @@ public class Pet {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get photoUrls
|
||||
* @return photoUrls
|
||||
**/
|
||||
**/
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set photoUrls
|
||||
**/
|
||||
* Set photoUrls
|
||||
*/
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
@@ -185,17 +185,17 @@ public class Pet {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get tags
|
||||
* @return tags
|
||||
**/
|
||||
**/
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tags
|
||||
**/
|
||||
* Set tags
|
||||
*/
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
@@ -213,19 +213,19 @@ public class Pet {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* pet status in the store
|
||||
* @return status
|
||||
* @deprecated
|
||||
**/
|
||||
**/
|
||||
@Deprecated
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status
|
||||
**/
|
||||
* Set status
|
||||
*/
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
@@ -237,8 +237,8 @@ public class Pet {
|
||||
|
||||
|
||||
/**
|
||||
* Create a string representation of this pojo.
|
||||
**/
|
||||
* Create a string representation of this pojo.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
**/
|
||||
*/
|
||||
|
||||
public class Tag {
|
||||
|
||||
@@ -35,17 +35,17 @@ public class Tag {
|
||||
@JsonbProperty("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
**/
|
||||
* Set id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -55,17 +55,17 @@ public class Tag {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
**/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
**/
|
||||
* Set name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -77,8 +77,8 @@ public class Tag {
|
||||
|
||||
|
||||
/**
|
||||
* Create a string representation of this pojo.
|
||||
**/
|
||||
* Create a string representation of this pojo.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.json.bind.annotation.JsonbProperty;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
**/
|
||||
*/
|
||||
|
||||
public class User {
|
||||
|
||||
@@ -51,22 +51,22 @@ public class User {
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* User Status
|
||||
**/
|
||||
* User Status
|
||||
*/
|
||||
@JsonbProperty("userStatus")
|
||||
private Integer userStatus;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
**/
|
||||
* Set id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -76,17 +76,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get username
|
||||
* @return username
|
||||
**/
|
||||
**/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set username
|
||||
**/
|
||||
* Set username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
@@ -96,17 +96,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get firstName
|
||||
* @return firstName
|
||||
**/
|
||||
**/
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set firstName
|
||||
**/
|
||||
* Set firstName
|
||||
*/
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
@@ -116,17 +116,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get lastName
|
||||
* @return lastName
|
||||
**/
|
||||
**/
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set lastName
|
||||
**/
|
||||
* Set lastName
|
||||
*/
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
@@ -136,17 +136,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get email
|
||||
* @return email
|
||||
**/
|
||||
**/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set email
|
||||
**/
|
||||
* Set email
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
@@ -156,17 +156,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get password
|
||||
* @return password
|
||||
**/
|
||||
**/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set password
|
||||
**/
|
||||
* Set password
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
@@ -176,17 +176,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get phone
|
||||
* @return phone
|
||||
**/
|
||||
**/
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set phone
|
||||
**/
|
||||
* Set phone
|
||||
*/
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
@@ -196,17 +196,17 @@ public class User {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* User Status
|
||||
* @return userStatus
|
||||
**/
|
||||
**/
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set userStatus
|
||||
**/
|
||||
* Set userStatus
|
||||
*/
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
@@ -218,8 +218,8 @@ public class User {
|
||||
|
||||
|
||||
/**
|
||||
* Create a string representation of this pojo.
|
||||
**/
|
||||
* Create a string representation of this pojo.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user