mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-22 02:47:09 +00:00
Java support for application/xml (#5962)
* WIP: CodegenProperty with XML * WIP: CodegenModel XML bits * WIP: Jackson XML * WIP: Java templating * WIP: Java client withXml flag * WIP: resttemplate work * WIP: withXml only when Jackson is used * WIP: Tabs to spaces * WIP: java-petstore-resttemplate-withxml sample * WIP: language: spring * WIP: language "spring" using library "spring-boot" should include apiPackage in @ComponentScan to detect the API * WIP: javax.xml for non-Jackson Java and enabled payload logging for jersey2 * WIP: updated java petstore samples * WIP: JavaSpring with non-jackson XML * WIP: bin/spring-all-pestore.sh
This commit is contained in:
@@ -55,6 +55,15 @@
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${springfox-version}</version>
|
||||
</dependency>
|
||||
{{#withXml}}
|
||||
|
||||
<!-- XML processing: Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
{{/withXml}}
|
||||
{{#java8}}
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = "{{basePackage}}")
|
||||
@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" })
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,6 +50,15 @@
|
||||
<groupId>org.springframework.security.oauth</groupId>
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
</dependency>
|
||||
{{#withXml}}
|
||||
|
||||
<!-- XML processing: Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
{{/withXml}}
|
||||
{{#java8}}
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -100,6 +100,16 @@
|
||||
<version>${springfox-version}</version>
|
||||
</dependency>
|
||||
|
||||
{{#withXml}}
|
||||
|
||||
<!-- XML processing: Jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
|
||||
{{/withXml}}
|
||||
{{#java8}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
|
||||
@@ -10,6 +10,15 @@ import java.io.Serializable;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
{{/useBeanValidation}}
|
||||
{{#jackson}}
|
||||
{{#withXml}}
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
{{/withXml}}
|
||||
{{/jackson}}
|
||||
{{#withXml}}
|
||||
import javax.xml.bind.annotation.*;
|
||||
{{/withXml}}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
*/{{#description}}
|
||||
@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
|
||||
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||
{{#serializableModel}}
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -22,7 +22,8 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
{{/items}}
|
||||
{{/items.isEnum}}
|
||||
{{#jackson}}
|
||||
@JsonProperty("{{baseName}}")
|
||||
@JsonProperty("{{baseName}}"){{#withXml}}
|
||||
@JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"){{/withXml}}
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
@SerializedName("{{baseName}}")
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{{#withXml}}
|
||||
{{#jackson}}
|
||||
@JacksonXmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}")
|
||||
{{/jackson}}
|
||||
@XmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}")
|
||||
@XmlAccessorType(XmlAccessType.FIELD){{/withXml}}
|
||||
Reference in New Issue
Block a user