[Play Framework] Update the bean validation to use version 2.0. (#8354)

* Update the bean validation to use version 2.0. For a reason I don't know, it was not working anymore with version 1.

* better format

Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
Jean-François Côté
2021-01-22 21:58:36 -05:00
committed by GitHub
parent 96da7aaf9d
commit 030b75b012
117 changed files with 849 additions and 448 deletions

View File

@@ -12,9 +12,11 @@ import javax.validation.constraints.*;
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Category {
@JsonProperty("id")
private Long id;
@JsonProperty("name")
private String name;
public Category id(Long id) {
@@ -26,7 +28,7 @@ public class Category {
* Get id
* @return id
**/
public Long getId() {
public Long getId() {
return id;
}
@@ -43,7 +45,7 @@ public class Category {
* Get name
* @return name
**/
public String getName() {
public String getName() {
return name;
}

View File

@@ -12,12 +12,15 @@ import javax.validation.constraints.*;
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class ModelApiResponse {
@JsonProperty("code")
private Integer code;
@JsonProperty("type")
private String type;
@JsonProperty("message")
private String message;
public ModelApiResponse code(Integer code) {
@@ -29,7 +32,7 @@ public class ModelApiResponse {
* Get code
* @return code
**/
public Integer getCode() {
public Integer getCode() {
return code;
}
@@ -46,7 +49,7 @@ public class ModelApiResponse {
* Get type
* @return type
**/
public String getType() {
public String getType() {
return type;
}
@@ -63,7 +66,7 @@ public class ModelApiResponse {
* Get message
* @return message
**/
public String getMessage() {
public String getMessage() {
return message;
}

View File

@@ -13,15 +13,20 @@ import javax.validation.constraints.*;
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Order {
@JsonProperty("id")
private Long id;
@JsonProperty("petId")
private Long petId;
@JsonProperty("quantity")
private Integer quantity;
@JsonProperty("shipDate")
@Valid
private OffsetDateTime shipDate;
/**
@@ -58,9 +63,11 @@ public class Order {
}
@JsonProperty("status")
private StatusEnum status;
@JsonProperty("complete")
private Boolean complete = false;
public Order id(Long id) {
@@ -72,7 +79,7 @@ public class Order {
* Get id
* @return id
**/
public Long getId() {
public Long getId() {
return id;
}
@@ -89,7 +96,7 @@ public class Order {
* Get petId
* @return petId
**/
public Long getPetId() {
public Long getPetId() {
return petId;
}
@@ -106,7 +113,7 @@ public class Order {
* Get quantity
* @return quantity
**/
public Integer getQuantity() {
public Integer getQuantity() {
return quantity;
}
@@ -123,7 +130,6 @@ public class Order {
* Get shipDate
* @return shipDate
**/
@Valid
public OffsetDateTime getShipDate() {
return shipDate;
}
@@ -141,7 +147,7 @@ public class Order {
* Order Status
* @return status
**/
public StatusEnum getStatus() {
public StatusEnum getStatus() {
return status;
}
@@ -158,7 +164,7 @@ public class Order {
* Get complete
* @return complete
**/
public Boolean getComplete() {
public Boolean getComplete() {
return complete;
}

View File

@@ -16,18 +16,27 @@ import javax.validation.constraints.*;
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Pet {
@JsonProperty("id")
private Long id;
@JsonProperty("category")
@Valid
private Category category;
@JsonProperty("name")
@NotNull
private String name;
@JsonProperty("photoUrls")
@NotNull
private List<String> photoUrls = new ArrayList<>();
@JsonProperty("tags")
@Valid
private List<Tag> tags = null;
/**
@@ -64,6 +73,7 @@ public class Pet {
}
@JsonProperty("status")
private StatusEnum status;
public Pet id(Long id) {
@@ -75,7 +85,7 @@ public class Pet {
* Get id
* @return id
**/
public Long getId() {
public Long getId() {
return id;
}
@@ -92,7 +102,6 @@ public class Pet {
* Get category
* @return category
**/
@Valid
public Category getCategory() {
return category;
}
@@ -110,7 +119,6 @@ public class Pet {
* Get name
* @return name
**/
@NotNull
public String getName() {
return name;
}
@@ -133,7 +141,6 @@ public class Pet {
* Get photoUrls
* @return photoUrls
**/
@NotNull
public List<String> getPhotoUrls() {
return photoUrls;
}
@@ -159,7 +166,6 @@ public class Pet {
* Get tags
* @return tags
**/
@Valid
public List<Tag> getTags() {
return tags;
}
@@ -177,7 +183,7 @@ public class Pet {
* pet status in the store
* @return status
**/
public StatusEnum getStatus() {
public StatusEnum getStatus() {
return status;
}

View File

@@ -12,9 +12,11 @@ import javax.validation.constraints.*;
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Tag {
@JsonProperty("id")
private Long id;
@JsonProperty("name")
private String name;
public Tag id(Long id) {
@@ -26,7 +28,7 @@ public class Tag {
* Get id
* @return id
**/
public Long getId() {
public Long getId() {
return id;
}
@@ -43,7 +45,7 @@ public class Tag {
* Get name
* @return name
**/
public String getName() {
public String getName() {
return name;
}

View File

@@ -12,27 +12,35 @@ import javax.validation.constraints.*;
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class User {
@JsonProperty("id")
private Long id;
@JsonProperty("username")
private String username;
@JsonProperty("firstName")
private String firstName;
@JsonProperty("lastName")
private String lastName;
@JsonProperty("email")
private String email;
@JsonProperty("password")
private String password;
@JsonProperty("phone")
private String phone;
@JsonProperty("userStatus")
private Integer userStatus;
public User id(Long id) {
@@ -44,7 +52,7 @@ public class User {
* Get id
* @return id
**/
public Long getId() {
public Long getId() {
return id;
}
@@ -61,7 +69,7 @@ public class User {
* Get username
* @return username
**/
public String getUsername() {
public String getUsername() {
return username;
}
@@ -78,7 +86,7 @@ public class User {
* Get firstName
* @return firstName
**/
public String getFirstName() {
public String getFirstName() {
return firstName;
}
@@ -95,7 +103,7 @@ public class User {
* Get lastName
* @return lastName
**/
public String getLastName() {
public String getLastName() {
return lastName;
}
@@ -112,7 +120,7 @@ public class User {
* Get email
* @return email
**/
public String getEmail() {
public String getEmail() {
return email;
}
@@ -129,7 +137,7 @@ public class User {
* Get password
* @return password
**/
public String getPassword() {
public String getPassword() {
return password;
}
@@ -146,7 +154,7 @@ public class User {
* Get phone
* @return phone
**/
public String getPhone() {
public String getPhone() {
return phone;
}
@@ -163,7 +171,7 @@ public class User {
* User Status
* @return userStatus
**/
public Integer getUserStatus() {
public Integer getUserStatus() {
return userStatus;
}