[4947][java]: adds support for validation of primitives in arrays (#17165)

* [4947][java]: adds support for validation of primitives in arrays

* [4947][java]: prevents generation '@Valid' for Object

* [4947][java]: test against different codegens and stick to primitive

* [4947][java]: code review

* [4947][java]: enhance getBeanValidation

* [4947][java]: adds email

* [4947][java]: removes unnecessary override

* [4947][java]: adds postProcessResponseWithProperty

* [4947][java]: adds missing import {{javaxPackage}}.validation.Valid

* [4947][java]: adds missing useBeanValidation

* [4947][java]: fix use rootJavaEEPackage for helidon
This commit is contained in:
Aliaksei
2023-12-11 13:55:38 +01:00
committed by GitHub
parent d4d5196907
commit 809b3331a9
575 changed files with 1982 additions and 843 deletions

View File

@@ -9,7 +9,7 @@
|------------ | ------------- | ------------- | -------------|
|**arrayOfString** | **List<String>** | | [optional] |
|**arrayArrayOfInteger** | **List<List<Long>>** | | [optional] |
|**arrayArrayOfModel** | **List<List<ReadOnlyFirst>>** | | [optional] |
|**arrayArrayOfModel** | **List<List<@Valid ReadOnlyFirst>>** | | [optional] |

View File

@@ -81,7 +81,7 @@ api.createUsersWithArrayInput()
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **body** | [**List<User>**](User.md)| List of user object | |
| **body** | [**List<@Valid User>**](User.md)| List of user object | |
### Return type
@@ -121,7 +121,7 @@ api.createUsersWithListInput()
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **body** | [**List<User>**](User.md)| List of user object | |
| **body** | [**List<@Valid User>**](User.md)| List of user object | |
### Return type

View File

@@ -28,6 +28,9 @@ import io.restassured.common.mapper.TypeRef;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -35,6 +35,9 @@ import io.restassured.common.mapper.TypeRef;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -27,6 +27,9 @@ import io.restassured.common.mapper.TypeRef;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -30,6 +30,9 @@ import io.restassured.common.mapper.TypeRef;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -27,6 +27,9 @@ import io.restassured.common.mapper.TypeRef;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -28,6 +28,9 @@ import io.restassured.common.mapper.TypeRef;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -204,10 +207,10 @@ public class UserApi {
}
/**
* @param body (List<User>) List of user object (required)
* @param body (List<@Valid User>) List of user object (required)
* @return operation
*/
public CreateUsersWithArrayInputOper body(List<User> body) {
public CreateUsersWithArrayInputOper body(List<@Valid User> body) {
reqSpec.setBody(body);
return this;
}
@@ -265,10 +268,10 @@ public class UserApi {
}
/**
* @param body (List&lt;User&gt;) List of user object (required)
* @param body (List&lt;@Valid User&gt;) List of user object (required)
* @return operation
*/
public CreateUsersWithListInputOper body(List<User> body) {
public CreateUsersWithListInputOper body(List<@Valid User> body) {
reqSpec.setBody(body);
return this;
}

View File

@@ -47,7 +47,7 @@ public class ArrayTest {
private List<List<Long>> arrayArrayOfInteger;
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
private List<List<ReadOnlyFirst>> arrayArrayOfModel;
private List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel;
public ArrayTest() {
}
@@ -123,13 +123,13 @@ public class ArrayTest {
}
public ArrayTest arrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
public ArrayTest arrayArrayOfModel(List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
return this;
}
public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
public ArrayTest addArrayArrayOfModelItem(List<@Valid ReadOnlyFirst> arrayArrayOfModelItem) {
if (this.arrayArrayOfModel == null) {
this.arrayArrayOfModel = new ArrayList<>();
}
@@ -147,14 +147,14 @@ public class ArrayTest {
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
public List<List<@Valid ReadOnlyFirst>> getArrayArrayOfModel() {
return arrayArrayOfModel;
}
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
public void setArrayArrayOfModel(List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
}

View File

@@ -43,7 +43,7 @@ public class FileSchemaTestClass {
private ModelFile _file;
public static final String JSON_PROPERTY_FILES = "files";
private List<ModelFile> files;
private List<@Valid ModelFile> files;
public FileSchemaTestClass() {
}
@@ -76,7 +76,7 @@ public class FileSchemaTestClass {
}
public FileSchemaTestClass files(List<ModelFile> files) {
public FileSchemaTestClass files(List<@Valid ModelFile> files) {
this.files = files;
return this;
@@ -100,14 +100,14 @@ public class FileSchemaTestClass {
@JsonProperty(JSON_PROPERTY_FILES)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<ModelFile> getFiles() {
public List<@Valid ModelFile> getFiles() {
return files;
}
@JsonProperty(JSON_PROPERTY_FILES)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFiles(List<ModelFile> files) {
public void setFiles(List<@Valid ModelFile> files) {
this.files = files;
}

View File

@@ -60,7 +60,7 @@ public class Pet {
private Set<String> photoUrls = new LinkedHashSet<>();
public static final String JSON_PROPERTY_TAGS = "tags";
private List<Tag> tags;
private List<@Valid Tag> tags;
/**
* pet status in the store
@@ -225,7 +225,7 @@ public class Pet {
}
public Pet tags(List<Tag> tags) {
public Pet tags(List<@Valid Tag> tags) {
this.tags = tags;
return this;
@@ -249,14 +249,14 @@ public class Pet {
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<Tag> getTags() {
public List<@Valid Tag> getTags() {
return tags;
}
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setTags(List<Tag> tags) {
public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

View File

@@ -9,7 +9,7 @@
|------------ | ------------- | ------------- | -------------|
|**arrayOfString** | **List&lt;String&gt;** | | [optional] |
|**arrayArrayOfInteger** | **List&lt;List&lt;Long&gt;&gt;** | | [optional] |
|**arrayArrayOfModel** | **List&lt;List&lt;ReadOnlyFirst&gt;&gt;** | | [optional] |
|**arrayArrayOfModel** | **List&lt;List&lt;@Valid ReadOnlyFirst&gt;&gt;** | | [optional] |

View File

@@ -81,7 +81,7 @@ api.createUsersWithArrayInput()
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **body** | [**List&lt;User&gt;**](User.md)| List of user object | |
| **body** | [**List&lt;@Valid User&gt;**](User.md)| List of user object | |
### Return type
@@ -121,7 +121,7 @@ api.createUsersWithListInput()
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **body** | [**List&lt;User&gt;**](User.md)| List of user object | |
| **body** | [**List&lt;@Valid User&gt;**](User.md)| List of user object | |
### Return type

View File

@@ -28,6 +28,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -35,6 +35,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -27,6 +27,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -30,6 +30,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -27,6 +27,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;

View File

@@ -28,6 +28,9 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.Method;
import io.restassured.response.Response;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.lang.reflect.Type;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -205,10 +208,10 @@ public class UserApi {
}
/**
* @param body (List&lt;User&gt;) List of user object (required)
* @param body (List&lt;@Valid User&gt;) List of user object (required)
* @return operation
*/
public CreateUsersWithArrayInputOper body(List<User> body) {
public CreateUsersWithArrayInputOper body(List<@Valid User> body) {
reqSpec.setBody(body);
return this;
}
@@ -266,10 +269,10 @@ public class UserApi {
}
/**
* @param body (List&lt;User&gt;) List of user object (required)
* @param body (List&lt;@Valid User&gt;) List of user object (required)
* @return operation
*/
public CreateUsersWithListInputOper body(List<User> body) {
public CreateUsersWithListInputOper body(List<@Valid User> body) {
reqSpec.setBody(body);
return this;
}

View File

@@ -44,7 +44,7 @@ public class ArrayTest {
public static final String SERIALIZED_NAME_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
@SerializedName(SERIALIZED_NAME_ARRAY_ARRAY_OF_MODEL)
private List<List<ReadOnlyFirst>> arrayArrayOfModel;
private List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel;
public ArrayTest() {
}
@@ -112,13 +112,13 @@ public class ArrayTest {
}
public ArrayTest arrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
public ArrayTest arrayArrayOfModel(List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
return this;
}
public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
public ArrayTest addArrayArrayOfModelItem(List<@Valid ReadOnlyFirst> arrayArrayOfModelItem) {
if (this.arrayArrayOfModel == null) {
this.arrayArrayOfModel = new ArrayList<>();
}
@@ -134,12 +134,12 @@ public class ArrayTest {
@Valid
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
public List<List<@Valid ReadOnlyFirst>> getArrayArrayOfModel() {
return arrayArrayOfModel;
}
public void setArrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
public void setArrayArrayOfModel(List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
}

View File

@@ -40,7 +40,7 @@ public class FileSchemaTestClass {
public static final String SERIALIZED_NAME_FILES = "files";
@SerializedName(SERIALIZED_NAME_FILES)
private List<ModelFile> files;
private List<@Valid ModelFile> files;
public FileSchemaTestClass() {
}
@@ -69,7 +69,7 @@ public class FileSchemaTestClass {
}
public FileSchemaTestClass files(List<ModelFile> files) {
public FileSchemaTestClass files(List<@Valid ModelFile> files) {
this.files = files;
return this;
@@ -91,12 +91,12 @@ public class FileSchemaTestClass {
@Valid
public List<ModelFile> getFiles() {
public List<@Valid ModelFile> getFiles() {
return files;
}
public void setFiles(List<ModelFile> files) {
public void setFiles(List<@Valid ModelFile> files) {
this.files = files;
}

View File

@@ -55,7 +55,7 @@ public class Pet {
public static final String SERIALIZED_NAME_TAGS = "tags";
@SerializedName(SERIALIZED_NAME_TAGS)
private List<Tag> tags;
private List<@Valid Tag> tags;
/**
* pet status in the store
@@ -216,7 +216,7 @@ public class Pet {
}
public Pet tags(List<Tag> tags) {
public Pet tags(List<@Valid Tag> tags) {
this.tags = tags;
return this;
@@ -238,12 +238,12 @@ public class Pet {
@Valid
public List<Tag> getTags() {
public List<@Valid Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}

View File

@@ -9,7 +9,7 @@
|------------ | ------------- | ------------- | -------------|
|**arrayOfString** | **List&lt;String&gt;** | | [optional] |
|**arrayArrayOfInteger** | **List&lt;List&lt;Long&gt;&gt;** | | [optional] |
|**arrayArrayOfModel** | **List&lt;List&lt;ReadOnlyFirst&gt;&gt;** | | [optional] |
|**arrayArrayOfModel** | **List&lt;List&lt;@Valid ReadOnlyFirst&gt;&gt;** | | [optional] |

View File

@@ -102,7 +102,7 @@ public class Example {
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
UserApi apiInstance = new UserApi(defaultClient);
List<User> body = Arrays.asList(); // List<User> | List of user object
List<@Valid User> body = Arrays.asList(); // List<@Valid User> | List of user object
try {
apiInstance.createUsersWithArrayInput(body);
} catch (ApiException e) {
@@ -121,7 +121,7 @@ public class Example {
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **body** | [**List&lt;User&gt;**](User.md)| List of user object | |
| **body** | [**List&lt;@Valid User&gt;**](User.md)| List of user object | |
### Return type
@@ -165,7 +165,7 @@ public class Example {
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
UserApi apiInstance = new UserApi(defaultClient);
List<User> body = Arrays.asList(); // List<User> | List of user object
List<@Valid User> body = Arrays.asList(); // List<@Valid User> | List of user object
try {
apiInstance.createUsersWithListInput(body);
} catch (ApiException e) {
@@ -184,7 +184,7 @@ public class Example {
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **body** | [**List&lt;User&gt;**](User.md)| List of user object | |
| **body** | [**List&lt;@Valid User&gt;**](User.md)| List of user object | |
### Return type

View File

@@ -12,6 +12,9 @@ import okhttp3.MultipartBody;
import org.openapitools.client.model.Client;
import java.util.UUID;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -19,6 +19,9 @@ import org.openapitools.client.model.OuterComposite;
import org.openapitools.client.model.User;
import org.openapitools.client.model.XmlItem;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -11,6 +11,9 @@ import okhttp3.MultipartBody;
import org.openapitools.client.model.Client;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -14,6 +14,9 @@ import org.openapitools.client.model.ModelApiResponse;
import org.openapitools.client.model.Pet;
import java.util.Set;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -11,6 +11,9 @@ import okhttp3.MultipartBody;
import org.openapitools.client.model.Order;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -12,6 +12,9 @@ import okhttp3.MultipartBody;
import java.time.OffsetDateTime;
import org.openapitools.client.model.User;
import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +43,7 @@ public interface UserApi {
*/
@POST("user/createWithArray")
CompletionStage<Response<Void>> createUsersWithArrayInput(
@retrofit2.http.Body List<User> body
@retrofit2.http.Body List<@Valid User> body
);
/**
@@ -51,7 +54,7 @@ public interface UserApi {
*/
@POST("user/createWithList")
CompletionStage<Response<Void>> createUsersWithListInput(
@retrofit2.http.Body List<User> body
@retrofit2.http.Body List<@Valid User> body
);
/**

View File

@@ -46,7 +46,7 @@ public class ArrayTest {
private List<List<Long>> arrayArrayOfInteger;
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
private List<List<ReadOnlyFirst>> arrayArrayOfModel;
private List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel;
public ArrayTest() {
}
@@ -122,13 +122,13 @@ public class ArrayTest {
}
public ArrayTest arrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
public ArrayTest arrayArrayOfModel(List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
return this;
}
public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
public ArrayTest addArrayArrayOfModelItem(List<@Valid ReadOnlyFirst> arrayArrayOfModelItem) {
if (this.arrayArrayOfModel == null) {
this.arrayArrayOfModel = new ArrayList<>();
}
@@ -146,14 +146,14 @@ public class ArrayTest {
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
public List<List<@Valid ReadOnlyFirst>> getArrayArrayOfModel() {
return arrayArrayOfModel;
}
@JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
public void setArrayArrayOfModel(List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayArrayOfModel = arrayArrayOfModel;
}

View File

@@ -42,7 +42,7 @@ public class FileSchemaTestClass {
private ModelFile _file;
public static final String JSON_PROPERTY_FILES = "files";
private List<ModelFile> files;
private List<@Valid ModelFile> files;
public FileSchemaTestClass() {
}
@@ -75,7 +75,7 @@ public class FileSchemaTestClass {
}
public FileSchemaTestClass files(List<ModelFile> files) {
public FileSchemaTestClass files(List<@Valid ModelFile> files) {
this.files = files;
return this;
@@ -99,14 +99,14 @@ public class FileSchemaTestClass {
@JsonProperty(JSON_PROPERTY_FILES)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<ModelFile> getFiles() {
public List<@Valid ModelFile> getFiles() {
return files;
}
@JsonProperty(JSON_PROPERTY_FILES)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFiles(List<ModelFile> files) {
public void setFiles(List<@Valid ModelFile> files) {
this.files = files;
}

View File

@@ -59,7 +59,7 @@ public class Pet {
private Set<String> photoUrls = new LinkedHashSet<>();
public static final String JSON_PROPERTY_TAGS = "tags";
private List<Tag> tags;
private List<@Valid Tag> tags;
/**
* pet status in the store
@@ -224,7 +224,7 @@ public class Pet {
}
public Pet tags(List<Tag> tags) {
public Pet tags(List<@Valid Tag> tags) {
this.tags = tags;
return this;
@@ -248,14 +248,14 @@ public class Pet {
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<Tag> getTags() {
public List<@Valid Tag> getTags() {
return tags;
}
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setTags(List<Tag> tags) {
public void setTags(List<@Valid Tag> tags) {
this.tags = tags;
}