Skip to content

Commit c26f5fb

Browse files
author
bnasslahsen
committed
XML Support. Fixes #6
1 parent fd66b82 commit c26f5fb

File tree

7 files changed

+199
-94
lines changed

7 files changed

+199
-94
lines changed

springdoc-openapi-spring-boot-2-webmvc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dependencies {
4040
implementation 'org.springframework.boot:spring-boot-starter-actuator'
4141
developmentOnly 'org.springframework.boot:spring-boot-devtools'
4242
implementation "org.springdoc:springdoc-openapi-ui:${springDocVersion}"
43+
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml"
4344
testImplementation "org.springframework.boot:spring-boot-starter-test"
4445
}
4546

springdoc-openapi-spring-boot-2-webmvc/src/main/java/org/springdoc/demo/app2/model/Category.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,34 @@
2020

2121
import java.util.Objects;
2222

23+
import javax.xml.bind.annotation.XmlAccessType;
24+
import javax.xml.bind.annotation.XmlAccessorType;
25+
import javax.xml.bind.annotation.XmlRootElement;
26+
2327
import com.fasterxml.jackson.annotation.JsonProperty;
28+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
29+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
2430
import io.swagger.v3.oas.annotations.media.Schema;
2531

2632
/**
2733
* Category
2834
*/
2935

30-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]")
31-
36+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-12-02T19:53:02.467132-01:00[Atlantic/Azores]")
37+
@JacksonXmlRootElement(localName = "category")
38+
@XmlRootElement(name = "category")
39+
@XmlAccessorType(XmlAccessType.FIELD)
3240

3341
public class Category {
3442

3543
@JsonProperty("id")
44+
@JacksonXmlProperty(localName = "id")
3645

3746
private Long id;
3847

3948

4049
@JsonProperty("name")
50+
@JacksonXmlProperty(localName = "name")
4151

4252
private String name;
4353

@@ -128,4 +138,3 @@ private String toIndentedString(Object o) {
128138
return o.toString().replace("\n", "\n ");
129139
}
130140
}
131-

springdoc-openapi-spring-boot-2-webmvc/src/main/java/org/springdoc/demo/app2/model/ModelApiResponse.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,40 @@
2020

2121
import java.util.Objects;
2222

23+
import javax.xml.bind.annotation.XmlAccessType;
24+
import javax.xml.bind.annotation.XmlAccessorType;
25+
import javax.xml.bind.annotation.XmlRootElement;
26+
2327
import com.fasterxml.jackson.annotation.JsonProperty;
28+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
29+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
2430
import io.swagger.v3.oas.annotations.media.Schema;
2531

2632
/**
2733
* ModelApiResponse
2834
*/
2935

30-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]")
31-
36+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-12-02T19:53:02.467132-01:00[Atlantic/Azores]")
37+
@JacksonXmlRootElement(localName = "##default")
38+
@XmlRootElement(name = "##default")
39+
@XmlAccessorType(XmlAccessType.FIELD)
3240

3341
public class ModelApiResponse {
3442

3543
@JsonProperty("code")
44+
@JacksonXmlProperty(localName = "code")
3645

3746
private Integer code;
3847

3948

4049
@JsonProperty("type")
50+
@JacksonXmlProperty(localName = "type")
4151

4252
private String type;
4353

4454

4555
@JsonProperty("message")
56+
@JacksonXmlProperty(localName = "message")
4657

4758
private String message;
4859

@@ -158,4 +169,3 @@ private String toIndentedString(Object o) {
158169
return o.toString().replace("\n", "\n ");
159170
}
160171
}
161-

springdoc-openapi-spring-boot-2-webmvc/src/main/java/org/springdoc/demo/app2/model/Order.java

Lines changed: 67 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,58 +17,106 @@
1717
*/
1818

1919
package org.springdoc.demo.app2.model;
20-
21-
import java.util.Date;
22-
import java.util.Objects;
23-
24-
import javax.validation.Valid;
25-
2620
import com.fasterxml.jackson.annotation.JsonCreator;
2721
import com.fasterxml.jackson.annotation.JsonProperty;
2822
import com.fasterxml.jackson.annotation.JsonValue;
23+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
24+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
2925
import io.swagger.v3.oas.annotations.media.Schema;
3026

27+
import javax.validation.Valid;
28+
import javax.xml.bind.annotation.XmlAccessType;
29+
import javax.xml.bind.annotation.XmlAccessorType;
30+
import javax.xml.bind.annotation.XmlRootElement;
31+
import java.util.Date;
32+
import java.util.Objects;
33+
3134
/**
3235
* Order
3336
*/
3437

35-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]")
36-
38+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-12-02T19:53:02.467132-01:00[Atlantic/Azores]")
39+
@JacksonXmlRootElement(localName = "order")
40+
@XmlRootElement(name = "order")
41+
@XmlAccessorType(XmlAccessType.FIELD)
3742

3843
public class Order {
3944

4045
@JsonProperty("id")
46+
@JacksonXmlProperty(localName = "id")
4147

4248
private Long id;
4349

4450

4551
@JsonProperty("petId")
52+
@JacksonXmlProperty(localName = "petId")
4653

4754
private Long petId;
4855

4956

5057
@JsonProperty("quantity")
58+
@JacksonXmlProperty(localName = "quantity")
5159

5260
private Integer quantity;
5361

5462

5563
@JsonProperty("shipDate")
64+
@JacksonXmlProperty(localName = "shipDate")
5665

5766
private Date shipDate;
5867

68+
/**
69+
* Order Status
70+
*/
71+
public enum StatusEnum {
72+
PLACED("placed"),
73+
74+
APPROVED("approved"),
75+
76+
DELIVERED("delivered");
77+
78+
private String value;
79+
80+
StatusEnum(String value) {
81+
this.value = value;
82+
}
83+
84+
@Override
85+
@JsonValue
86+
public String toString() {
87+
return String.valueOf(value);
88+
}
89+
90+
@JsonCreator
91+
public static StatusEnum fromValue(String value) {
92+
for (StatusEnum b : StatusEnum.values()) {
93+
if (b.value.equals(value)) {
94+
return b;
95+
}
96+
}
97+
throw new IllegalArgumentException("Unexpected value '" + value + "'");
98+
}
99+
}
100+
101+
59102
@JsonProperty("status")
103+
@JacksonXmlProperty(localName = "status")
60104

61105
private StatusEnum status;
62106

107+
63108
@JsonProperty("complete")
109+
@JacksonXmlProperty(localName = "complete")
64110

65111
private Boolean complete;
66112

113+
67114
public Order id(Long id) {
68115
this.id = id;
69116
return this;
70117
}
71118

119+
72120
/**
73121
* Get id
74122
*
@@ -85,11 +133,13 @@ public void setId(Long id) {
85133
this.id = id;
86134
}
87135

136+
88137
public Order petId(Long petId) {
89138
this.petId = petId;
90139
return this;
91140
}
92141

142+
93143
/**
94144
* Get petId
95145
*
@@ -106,11 +156,13 @@ public void setPetId(Long petId) {
106156
this.petId = petId;
107157
}
108158

159+
109160
public Order quantity(Integer quantity) {
110161
this.quantity = quantity;
111162
return this;
112163
}
113164

165+
114166
/**
115167
* Get quantity
116168
*
@@ -127,11 +179,13 @@ public void setQuantity(Integer quantity) {
127179
this.quantity = quantity;
128180
}
129181

182+
130183
public Order shipDate(Date shipDate) {
131184
this.shipDate = shipDate;
132185
return this;
133186
}
134187

188+
135189
/**
136190
* Get shipDate
137191
*
@@ -149,11 +203,13 @@ public void setShipDate(Date shipDate) {
149203
this.shipDate = shipDate;
150204
}
151205

206+
152207
public Order status(StatusEnum status) {
153208
this.status = status;
154209
return this;
155210
}
156211

212+
157213
/**
158214
* Order Status
159215
*
@@ -170,11 +226,13 @@ public void setStatus(StatusEnum status) {
170226
this.status = status;
171227
}
172228

229+
173230
public Order complete(Boolean complete) {
174231
this.complete = complete;
175232
return this;
176233
}
177234

235+
178236
/**
179237
* Get complete
180238
*
@@ -191,6 +249,7 @@ public void setComplete(Boolean complete) {
191249
this.complete = complete;
192250
}
193251

252+
194253
@Override
195254
public boolean equals(Object o) {
196255
if (this == o) {
@@ -238,38 +297,4 @@ private String toIndentedString(Object o) {
238297
}
239298
return o.toString().replace("\n", "\n ");
240299
}
241-
242-
/**
243-
* Order Status
244-
*/
245-
public enum StatusEnum {
246-
PLACED("placed"),
247-
248-
APPROVED("approved"),
249-
250-
DELIVERED("delivered");
251-
252-
private String value;
253-
254-
StatusEnum(String value) {
255-
this.value = value;
256-
}
257-
258-
@JsonCreator
259-
public static StatusEnum fromValue(String value) {
260-
for (StatusEnum b : StatusEnum.values()) {
261-
if (b.value.equals(value)) {
262-
return b;
263-
}
264-
}
265-
throw new IllegalArgumentException("Unexpected value '" + value + "'");
266-
}
267-
268-
@Override
269-
@JsonValue
270-
public String toString() {
271-
return String.valueOf(value);
272-
}
273-
}
274300
}
275-

0 commit comments

Comments
 (0)