Skip to content

Commit 81ab5b7

Browse files
committed
fixes(spring) add JsonProperty on setter
Fixes #22757
1 parent b1022e7 commit 81ab5b7

1,178 files changed

Lines changed: 4069 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
261261
{{#deprecated}}
262262
@Deprecated
263263
{{/deprecated}}
264+
{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}@JsonProperty("{{baseName}}"){{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}}
264265
public void {{setter}}({{>nullableAnnotation}}{{>nullableDataType}} {{name}}) {
265266
this.{{name}} = {{name}};
266267
}

samples/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/model/Pet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public String getAtType() {
6868
return atType;
6969
}
7070

71+
@JsonProperty("@type")
7172
public void setAtType(String atType) {
7273
this.atType = atType;
7374
}
@@ -88,6 +89,7 @@ public Integer getAge() {
8889
return age;
8990
}
9091

92+
@JsonProperty("age")
9193
public void setAge(Integer age) {
9294
this.age = age;
9395
}
@@ -108,6 +110,7 @@ public Boolean getHappy() {
108110
return happy;
109111
}
110112

113+
@JsonProperty("happy")
111114
public void setHappy(Boolean happy) {
112115
this.happy = happy;
113116
}
@@ -128,6 +131,7 @@ public BigDecimal getPrice() {
128131
return price;
129132
}
130133

134+
@JsonProperty("price")
131135
public void setPrice(BigDecimal price) {
132136
this.price = price;
133137
}
@@ -148,6 +152,7 @@ public OffsetDateTime getLastFeed() {
148152
return lastFeed;
149153
}
150154

155+
@JsonProperty("lastFeed")
151156
public void setLastFeed(OffsetDateTime lastFeed) {
152157
this.lastFeed = lastFeed;
153158
}
@@ -168,6 +173,7 @@ public LocalDate getDateOfBirth() {
168173
return dateOfBirth;
169174
}
170175

176+
@JsonProperty("dateOfBirth")
171177
public void setDateOfBirth(LocalDate dateOfBirth) {
172178
this.dateOfBirth = dateOfBirth;
173179
}

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Category.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public Category id(@Nullable Long id) {
4343
return id;
4444
}
4545

46+
@JsonProperty("id")
4647
public void setId(@Nullable Long id) {
4748
this.id = id;
4849
}
@@ -63,6 +64,7 @@ public Category name(@Nullable String name) {
6364
return name;
6465
}
6566

67+
@JsonProperty("name")
6668
public void setName(@Nullable String name) {
6769
this.name = name;
6870
}

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/ModelApiResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public ModelApiResponse code(@Nullable Integer code) {
4747
return code;
4848
}
4949

50+
@JsonProperty("code")
5051
public void setCode(@Nullable Integer code) {
5152
this.code = code;
5253
}
@@ -67,6 +68,7 @@ public ModelApiResponse type(@Nullable String type) {
6768
return type;
6869
}
6970

71+
@JsonProperty("type")
7072
public void setType(@Nullable String type) {
7173
this.type = type;
7274
}
@@ -87,6 +89,7 @@ public ModelApiResponse message(@Nullable String message) {
8789
return message;
8890
}
8991

92+
@JsonProperty("message")
9093
public void setMessage(@Nullable String message) {
9194
this.message = message;
9295
}

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Order.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public Order id(@Nullable Long id) {
9494
return id;
9595
}
9696

97+
@JsonProperty("id")
9798
public void setId(@Nullable Long id) {
9899
this.id = id;
99100
}
@@ -114,6 +115,7 @@ public Order petId(@Nullable Long petId) {
114115
return petId;
115116
}
116117

118+
@JsonProperty("petId")
117119
public void setPetId(@Nullable Long petId) {
118120
this.petId = petId;
119121
}
@@ -134,6 +136,7 @@ public Order quantity(@Nullable Integer quantity) {
134136
return quantity;
135137
}
136138

139+
@JsonProperty("quantity")
137140
public void setQuantity(@Nullable Integer quantity) {
138141
this.quantity = quantity;
139142
}
@@ -154,6 +157,7 @@ public Order shipDate(@Nullable OffsetDateTime shipDate) {
154157
return shipDate;
155158
}
156159

160+
@JsonProperty("shipDate")
157161
public void setShipDate(@Nullable OffsetDateTime shipDate) {
158162
this.shipDate = shipDate;
159163
}
@@ -174,6 +178,7 @@ public Order status(@Nullable StatusEnum status) {
174178
return status;
175179
}
176180

181+
@JsonProperty("status")
177182
public void setStatus(@Nullable StatusEnum status) {
178183
this.status = status;
179184
}
@@ -194,6 +199,7 @@ public Boolean getComplete() {
194199
return complete;
195200
}
196201

202+
@JsonProperty("complete")
197203
public void setComplete(Boolean complete) {
198204
this.complete = complete;
199205
}

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Pet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public Pet id(@Nullable Long id) {
109109
return id;
110110
}
111111

112+
@JsonProperty("id")
112113
public void setId(@Nullable Long id) {
113114
this.id = id;
114115
}
@@ -129,6 +130,7 @@ public Pet category(@Nullable Category category) {
129130
return category;
130131
}
131132

133+
@JsonProperty("category")
132134
public void setCategory(@Nullable Category category) {
133135
this.category = category;
134136
}
@@ -149,6 +151,7 @@ public JsonNullable<String> getName() {
149151
return name;
150152
}
151153

154+
@JsonProperty("name")
152155
public void setName(JsonNullable<String> name) {
153156
this.name = name;
154157
}
@@ -183,6 +186,7 @@ public List<String> getPhotoUrls() {
183186
* @deprecated
184187
*/
185188
@Deprecated
189+
@JsonProperty("photoUrls")
186190
public void setPhotoUrls(List<String> photoUrls) {
187191
this.photoUrls = photoUrls;
188192
}
@@ -211,6 +215,7 @@ public Pet addTagsItem(Tag tagsItem) {
211215
return tags;
212216
}
213217

218+
@JsonProperty("tags")
214219
public void setTags(List<@Valid Tag> tags) {
215220
this.tags = tags;
216221
}
@@ -231,6 +236,7 @@ public Pet status(@Nullable StatusEnum status) {
231236
return status;
232237
}
233238

239+
@JsonProperty("status")
234240
public void setStatus(@Nullable StatusEnum status) {
235241
this.status = status;
236242
}

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Tag.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public Tag id(@Nullable Long id) {
4343
return id;
4444
}
4545

46+
@JsonProperty("id")
4647
public void setId(@Nullable Long id) {
4748
this.id = id;
4849
}
@@ -63,6 +64,7 @@ public Tag name(@Nullable String name) {
6364
return name;
6465
}
6566

67+
@JsonProperty("name")
6668
public void setName(@Nullable String name) {
6769
this.name = name;
6870
}

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/User.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public User id(@Nullable Long id) {
5555
return id;
5656
}
5757

58+
@JsonProperty("id")
5859
public void setId(@Nullable Long id) {
5960
this.id = id;
6061
}
@@ -75,6 +76,7 @@ public User username(@Nullable String username) {
7576
return username;
7677
}
7778

79+
@JsonProperty("username")
7880
public void setUsername(@Nullable String username) {
7981
this.username = username;
8082
}
@@ -95,6 +97,7 @@ public User firstName(@Nullable String firstName) {
9597
return firstName;
9698
}
9799

100+
@JsonProperty("firstName")
98101
public void setFirstName(@Nullable String firstName) {
99102
this.firstName = firstName;
100103
}
@@ -115,6 +118,7 @@ public User lastName(@Nullable String lastName) {
115118
return lastName;
116119
}
117120

121+
@JsonProperty("lastName")
118122
public void setLastName(@Nullable String lastName) {
119123
this.lastName = lastName;
120124
}
@@ -135,6 +139,7 @@ public User email(@Nullable String email) {
135139
return email;
136140
}
137141

142+
@JsonProperty("email")
138143
public void setEmail(@Nullable String email) {
139144
this.email = email;
140145
}
@@ -155,6 +160,7 @@ public User password(@Nullable String password) {
155160
return password;
156161
}
157162

163+
@JsonProperty("password")
158164
public void setPassword(@Nullable String password) {
159165
this.password = password;
160166
}
@@ -175,6 +181,7 @@ public User phone(@Nullable String phone) {
175181
return phone;
176182
}
177183

184+
@JsonProperty("phone")
178185
public void setPhone(@Nullable String phone) {
179186
this.phone = phone;
180187
}
@@ -195,6 +202,7 @@ public User userStatus(@Nullable Integer userStatus) {
195202
return userStatus;
196203
}
197204

205+
@JsonProperty("userStatus")
198206
public void setUserStatus(@Nullable Integer userStatus) {
199207
this.userStatus = userStatus;
200208
}

samples/client/petstore/spring-cloud-feign-without-url/src/main/java/org/openapitools/model/Category.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public Category id(@Nullable Long id) {
4444
return id;
4545
}
4646

47+
@JsonProperty("id")
4748
public void setId(@Nullable Long id) {
4849
this.id = id;
4950
}
@@ -64,6 +65,7 @@ public Category name(@Nullable String name) {
6465
return name;
6566
}
6667

68+
@JsonProperty("name")
6769
public void setName(@Nullable String name) {
6870
this.name = name;
6971
}

samples/client/petstore/spring-cloud-feign-without-url/src/main/java/org/openapitools/model/ModelApiResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public ModelApiResponse code(@Nullable Integer code) {
4848
return code;
4949
}
5050

51+
@JsonProperty("code")
5152
public void setCode(@Nullable Integer code) {
5253
this.code = code;
5354
}
@@ -68,6 +69,7 @@ public ModelApiResponse type(@Nullable String type) {
6869
return type;
6970
}
7071

72+
@JsonProperty("type")
7173
public void setType(@Nullable String type) {
7274
this.type = type;
7375
}
@@ -88,6 +90,7 @@ public ModelApiResponse message(@Nullable String message) {
8890
return message;
8991
}
9092

93+
@JsonProperty("message")
9194
public void setMessage(@Nullable String message) {
9295
this.message = message;
9396
}

0 commit comments

Comments
 (0)