forked from loafle/openapi-generator-original
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
This commit is contained in:
39
modules/openapi-generator/src/main/resources/JavaSpring/lombokAnnotation.mustache
vendored
Normal file
39
modules/openapi-generator/src/main/resources/JavaSpring/lombokAnnotation.mustache
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{{#lombok.RequiredArgsConstructor}}
|
||||
{{^useBeanValidation}}
|
||||
{{#required}}
|
||||
@lombok.NonNull
|
||||
{{/required}}
|
||||
{{/useBeanValidation}}
|
||||
{{/lombok.RequiredArgsConstructor}}
|
||||
{{#lombok.ToString}}
|
||||
{{#isPassword}}
|
||||
@lombok.ToString.Exclude
|
||||
{{/isPassword}}
|
||||
{{/lombok.ToString}}
|
||||
{{#lombok.Data}}
|
||||
{{#isPassword}}
|
||||
@lombok.ToString.Exclude
|
||||
{{/isPassword}}
|
||||
{{^isContainer}}{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}{{/isContainer}}
|
||||
{{^useBeanValidation}}
|
||||
{{#required}}
|
||||
@lombok.NonNull
|
||||
{{/required}}
|
||||
{{/useBeanValidation}}
|
||||
{{#swagger2AnnotationLibrary}}
|
||||
@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}})
|
||||
{{/swagger2AnnotationLibrary}}
|
||||
{{#jackson}}@JsonProperty("{{baseName}}")
|
||||
{{#withXml}}
|
||||
@JacksonXmlProperty(localName = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#isXmlAttribute}}, isAttribute = true{{/isXmlAttribute}}{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})
|
||||
{{#isContainer}}
|
||||
@JacksonXmlElementWrapper({{#isXmlWrapped}}localName = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}", {{#xmlNamespace}}namespace = "{{.}}", {{/xmlNamespace}}{{/isXmlWrapped}}useWrapping = {{isXmlWrapped}})
|
||||
{{/isContainer}}
|
||||
{{/withXml}}
|
||||
{{/jackson}}
|
||||
{{/lombok.Data}}
|
||||
{{#lombok.Builder}}
|
||||
{{#defaultValue}}
|
||||
@lombok.Builder.Default
|
||||
{{/defaultValue}}
|
||||
{{/lombok.Builder}}
|
||||
@@ -57,26 +57,10 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
|
||||
{{#gson}}
|
||||
@SerializedName("{{baseName}}")
|
||||
{{/gson}}
|
||||
{{#lombok.RequiredArgsConstructor}}
|
||||
{{^useBeanValidation}}
|
||||
{{#required}}
|
||||
@lombok.NonNull
|
||||
{{/required}}
|
||||
{{/useBeanValidation}}
|
||||
{{/lombok.RequiredArgsConstructor}}
|
||||
{{#lombok.ToString}}
|
||||
{{#isPassword}}
|
||||
@lombok.ToString.Exclude
|
||||
{{/isPassword}}
|
||||
{{/lombok.ToString}}
|
||||
{{>lombokAnnotation}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{.}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
{{#lombok.Builder}}
|
||||
{{#defaultValue}}
|
||||
@lombok.Builder.Default
|
||||
{{/defaultValue}}
|
||||
{{/lombok.Builder}}
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.openapitools.model.Pet;
|
||||
|
||||
|
||||
@@ -27,7 +28,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
@@ -27,8 +27,14 @@ import javax.annotation.Generated;
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
public class Category {
|
||||
|
||||
|
||||
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("id")
|
||||
private @Nullable Long id;
|
||||
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
|
||||
@Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("name")
|
||||
private @Nullable String name;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,10 +29,19 @@ import javax.annotation.Generated;
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
public class ModelApiResponse {
|
||||
|
||||
|
||||
@Schema(name = "code", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("code")
|
||||
private @Nullable Integer code;
|
||||
|
||||
|
||||
@Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("type")
|
||||
private @Nullable String type;
|
||||
|
||||
|
||||
@Schema(name = "message", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("message")
|
||||
private @Nullable String message;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,12 +30,24 @@ import javax.annotation.Generated;
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
public class Order {
|
||||
|
||||
|
||||
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("id")
|
||||
private @Nullable Long id;
|
||||
|
||||
|
||||
@Schema(name = "petId", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("petId")
|
||||
private @Nullable Long petId;
|
||||
|
||||
|
||||
@Schema(name = "quantity", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("quantity")
|
||||
private @Nullable Integer quantity;
|
||||
|
||||
@Valid
|
||||
@Schema(name = "shipDate", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("shipDate")
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
||||
private @Nullable OffsetDateTime shipDate;
|
||||
|
||||
@@ -76,8 +88,14 @@ public class Order {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Schema(name = "status", description = "Order Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("status")
|
||||
private @Nullable StatusEnum status;
|
||||
|
||||
|
||||
@Schema(name = "complete", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("complete")
|
||||
@lombok.Builder.Default
|
||||
private Boolean complete = false;
|
||||
|
||||
|
||||
@@ -33,16 +33,31 @@ import javax.annotation.Generated;
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
public class Pet {
|
||||
|
||||
|
||||
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("id")
|
||||
private @Nullable Long id;
|
||||
|
||||
@Valid
|
||||
@Schema(name = "category", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("category")
|
||||
private @Nullable Category category;
|
||||
|
||||
@NotNull
|
||||
@Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
|
||||
@Schema(name = "photoUrls", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonProperty("photoUrls")
|
||||
@lombok.Builder.Default
|
||||
@Valid
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
|
||||
@Schema(name = "tags", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("tags")
|
||||
@lombok.Builder.Default
|
||||
@Valid
|
||||
private List<@Valid Tag> tags = new ArrayList<>();
|
||||
@@ -84,6 +99,9 @@ public class Pet {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Schema(name = "status", description = "pet status in the store", deprecated = true, requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("status")
|
||||
@Deprecated
|
||||
private @Nullable StatusEnum status;
|
||||
|
||||
|
||||
@@ -27,8 +27,14 @@ import javax.annotation.Generated;
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
public class Tag {
|
||||
|
||||
|
||||
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("id")
|
||||
private @Nullable Long id;
|
||||
|
||||
|
||||
@Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("name")
|
||||
private @Nullable String name;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,20 +27,44 @@ import javax.annotation.Generated;
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
|
||||
public class User {
|
||||
|
||||
|
||||
@Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("id")
|
||||
private @Nullable Long id;
|
||||
|
||||
|
||||
@Schema(name = "username", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("username")
|
||||
private @Nullable String username;
|
||||
|
||||
|
||||
@Schema(name = "firstName", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("firstName")
|
||||
private @Nullable String firstName;
|
||||
|
||||
|
||||
@Schema(name = "lastName", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("lastName")
|
||||
private @Nullable String lastName;
|
||||
|
||||
|
||||
@Schema(name = "email", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("email")
|
||||
private @Nullable String email;
|
||||
|
||||
|
||||
@Schema(name = "password", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("password")
|
||||
private @Nullable String password;
|
||||
|
||||
|
||||
@Schema(name = "phone", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("phone")
|
||||
private @Nullable String phone;
|
||||
|
||||
|
||||
@Schema(name = "userStatus", description = "User Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonProperty("userStatus")
|
||||
private @Nullable Integer userStatus;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user