-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Description
I tried to add xml support for our openapi specs we defined. We use JavaSpring generator for the server and RestTemplate generator for the client.
As a test I tried
animals:
type: array
items:
type: string
xml:
name: animal
xml:
name: aliens
wrapped: true
taken from OpenApi 3.0.2 Spec.
Along with the option withXml the generated code is not correct.
For the client (Resttemplate generator) it generates:
@XmlElement(name = "animal")
@XmlElementWrapper(name = "aliens")
private List<String> animals = null;
@JacksonXmlElementWrapper(useWrapping = true, localName = "animal")
public List<String> getAnimals() {
return animals;
}
The XmlElement and XmlElementWrapper annotations are correct, but JacksonXmlElementWrapper is not, I would expect
@JacksonXmlElementWrapper (localName = "aliens")
@JacksonXmlProperty (localName = "animal")
For the JavaSpring generator it generates
@JacksonXmlProperty(localName = "aliens") // no wrapper annotations at all
private List<String> animals = null;
which is wrong, I expect the same annotations as for the client
@JacksonXmlElementWrapper (localName = "aliens")
@JacksonXmlProperty (localName = "animal")
and to be able to choose between technologies, I think you should also include XmlElement and XmlElementWrapper annotations.
openapi-generator version
4.2.2
OpenAPI declaration file content or url
animals:
type: array
items:
type: string
xml:
name: animal
xml:
name: aliens
wrapped: true
Command line used for generation
Used openapi-generator-maven-plugin 4.2.2
<generatorName>spring</generatorName>
<library>spring-mvc</library>
<configOptions>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<withXml>true</withXml>
</configOptions>
and for the client
<generatorName>java</generatorName>
<library>resttemplate</library>
<configOptions>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<withXml>true</withXml>
</configOptions>
Steps to reproduce
Create a yaml spec containing the above model definition taken from the spec