Skip to content

Commit fb2878c

Browse files
authored
fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606 (#22544)
* fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606 * fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606 * fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606 * fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606 * fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606 * fix #22492 [BUG][JAVA][MAVEN] Lombok @Getter disables validation and #19743 #18794 #17793 #17606
1 parent a3d03ba commit fb2878c

File tree

11 files changed

+125
-20
lines changed

11 files changed

+125
-20
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{#lombok.RequiredArgsConstructor}}
2+
{{^useBeanValidation}}
3+
{{#required}}
4+
@lombok.NonNull
5+
{{/required}}
6+
{{/useBeanValidation}}
7+
{{/lombok.RequiredArgsConstructor}}
8+
{{#lombok.ToString}}
9+
{{#isPassword}}
10+
@lombok.ToString.Exclude
11+
{{/isPassword}}
12+
{{/lombok.ToString}}
13+
{{#lombok.Data}}
14+
{{#isPassword}}
15+
@lombok.ToString.Exclude
16+
{{/isPassword}}
17+
{{^isContainer}}{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}{{/isContainer}}
18+
{{^useBeanValidation}}
19+
{{#required}}
20+
@lombok.NonNull
21+
{{/required}}
22+
{{/useBeanValidation}}
23+
{{#swagger2AnnotationLibrary}}
24+
@Schema(name = "{{{baseName}}}"{{#isReadOnly}}, accessMode = Schema.AccessMode.READ_ONLY{{/isReadOnly}}{{#example}}, example = "{{{.}}}"{{/example}}{{#description}}, description = "{{{.}}}"{{/description}}{{#deprecated}}, deprecated = true{{/deprecated}}, requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}})
25+
{{/swagger2AnnotationLibrary}}
26+
{{#jackson}}@JsonProperty("{{baseName}}")
27+
{{#withXml}}
28+
@JacksonXmlProperty(localName = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#isXmlAttribute}}, isAttribute = true{{/isXmlAttribute}}{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
29+
{{#isContainer}}
30+
@JacksonXmlElementWrapper({{#isXmlWrapped}}localName = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}", {{#xmlNamespace}}namespace = "{{.}}", {{/xmlNamespace}}{{/isXmlWrapped}}useWrapping = {{isXmlWrapped}})
31+
{{/isContainer}}
32+
{{/withXml}}
33+
{{/jackson}}
34+
{{/lombok.Data}}
35+
{{#lombok.Builder}}
36+
{{#defaultValue}}
37+
@lombok.Builder.Default
38+
{{/defaultValue}}
39+
{{/lombok.Builder}}

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,10 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
5757
{{#gson}}
5858
@SerializedName("{{baseName}}")
5959
{{/gson}}
60-
{{#lombok.RequiredArgsConstructor}}
61-
{{^useBeanValidation}}
62-
{{#required}}
63-
@lombok.NonNull
64-
{{/required}}
65-
{{/useBeanValidation}}
66-
{{/lombok.RequiredArgsConstructor}}
67-
{{#lombok.ToString}}
68-
{{#isPassword}}
69-
@lombok.ToString.Exclude
70-
{{/isPassword}}
71-
{{/lombok.ToString}}
60+
{{>lombokAnnotation}}
7261
{{#vendorExtensions.x-field-extra-annotation}}
7362
{{{.}}}
7463
{{/vendorExtensions.x-field-extra-annotation}}
75-
{{#lombok.Builder}}
76-
{{#defaultValue}}
77-
@lombok.Builder.Default
78-
{{/defaultValue}}
79-
{{/lombok.Builder}}
8064
{{#deprecated}}
8165
@Deprecated
8266
{{/deprecated}}

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/api/PetApiController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.openapitools.api;
22

33
import org.openapitools.model.ModelApiResponse;
4+
import org.springframework.lang.Nullable;
45
import org.openapitools.model.Pet;
56

67

@@ -27,7 +28,7 @@
2728
import java.util.Optional;
2829
import javax.annotation.Generated;
2930

30-
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
31+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3132
@Controller
3233
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
3334
public class PetApiController implements PetApi {

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/api/StoreApiController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.Optional;
2828
import javax.annotation.Generated;
2929

30-
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
30+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3131
@Controller
3232
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
3333
public class StoreApiController implements StoreApi {

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/api/UserApiController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.Optional;
2828
import javax.annotation.Generated;
2929

30-
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
30+
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3131
@Controller
3232
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
3333
public class UserApiController implements UserApi {

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/model/Category.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2828
public class Category {
2929

30+
31+
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
32+
@JsonProperty("id")
3033
private @Nullable Long id;
3134

35+
@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
36+
@Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
37+
@JsonProperty("name")
3238
private @Nullable String name;
3339

3440
}

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/model/ModelApiResponse.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,19 @@
2929
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3030
public class ModelApiResponse {
3131

32+
33+
@Schema(name = "code", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
34+
@JsonProperty("code")
3235
private @Nullable Integer code;
3336

37+
38+
@Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
39+
@JsonProperty("type")
3440
private @Nullable String type;
3541

42+
43+
@Schema(name = "message", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
44+
@JsonProperty("message")
3645
private @Nullable String message;
3746

3847
}

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/model/Order.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,24 @@
3030
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3131
public class Order {
3232

33+
34+
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
35+
@JsonProperty("id")
3336
private @Nullable Long id;
3437

38+
39+
@Schema(name = "petId", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
40+
@JsonProperty("petId")
3541
private @Nullable Long petId;
3642

43+
44+
@Schema(name = "quantity", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
45+
@JsonProperty("quantity")
3746
private @Nullable Integer quantity;
3847

48+
@Valid
49+
@Schema(name = "shipDate", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
50+
@JsonProperty("shipDate")
3951
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
4052
private @Nullable OffsetDateTime shipDate;
4153

@@ -76,8 +88,14 @@ public static StatusEnum fromValue(String value) {
7688
}
7789
}
7890

91+
92+
@Schema(name = "status", description = "Order Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
93+
@JsonProperty("status")
7994
private @Nullable StatusEnum status;
8095

96+
97+
@Schema(name = "complete", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
98+
@JsonProperty("complete")
8199
@lombok.Builder.Default
82100
private Boolean complete = false;
83101

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/model/Pet.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,31 @@
3333
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3434
public class Pet {
3535

36+
37+
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
38+
@JsonProperty("id")
3639
private @Nullable Long id;
3740

41+
@Valid
42+
@Schema(name = "category", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
43+
@JsonProperty("category")
3844
private @Nullable Category category;
3945

46+
@NotNull
47+
@Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED)
48+
@JsonProperty("name")
4049
private String name;
4150

51+
52+
@Schema(name = "photoUrls", requiredMode = Schema.RequiredMode.REQUIRED)
53+
@JsonProperty("photoUrls")
4254
@lombok.Builder.Default
4355
@Valid
4456
private List<String> photoUrls = new ArrayList<>();
4557

58+
59+
@Schema(name = "tags", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
60+
@JsonProperty("tags")
4661
@lombok.Builder.Default
4762
@Valid
4863
private List<@Valid Tag> tags = new ArrayList<>();
@@ -84,6 +99,9 @@ public static StatusEnum fromValue(String value) {
8499
}
85100
}
86101

102+
103+
@Schema(name = "status", description = "pet status in the store", deprecated = true, requiredMode = Schema.RequiredMode.NOT_REQUIRED)
104+
@JsonProperty("status")
87105
@Deprecated
88106
private @Nullable StatusEnum status;
89107

samples/server/petstore/springboot-lombok-data/src/main/java/org/openapitools/model/Tag.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2828
public class Tag {
2929

30+
31+
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
32+
@JsonProperty("id")
3033
private @Nullable Long id;
3134

35+
36+
@Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
37+
@JsonProperty("name")
3238
private @Nullable String name;
3339

3440
}

0 commit comments

Comments
 (0)