forked from loafle/openapi-generator-original
[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:
@@ -5,6 +5,7 @@ import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
@@ -38,7 +39,7 @@ public class Pet {
|
||||
@JsonProperty("tags")
|
||||
@Valid
|
||||
|
||||
private List<Tag> tags = null;
|
||||
private List<@Valid Tag> tags = null;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
@@ -153,7 +154,7 @@ public class Pet {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
public Pet tags(List<Tag> tags) {
|
||||
public Pet tags(List<@Valid Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
@@ -170,11 +171,11 @@ public class Pet {
|
||||
* Get tags
|
||||
* @return tags
|
||||
**/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ import openapitools.OpenAPIUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import com.typesafe.config.Config;
|
||||
|
||||
import openapitools.OpenAPIUtils.ApiAction;
|
||||
|
||||
@@ -20,6 +20,7 @@ import openapitools.OpenAPIUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import com.typesafe.config.Config;
|
||||
|
||||
import openapitools.OpenAPIUtils.ApiAction;
|
||||
|
||||
@@ -20,6 +20,7 @@ import openapitools.OpenAPIUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import com.typesafe.config.Config;
|
||||
|
||||
import openapitools.OpenAPIUtils.ApiAction;
|
||||
@@ -53,9 +54,9 @@ public class UserApiController extends Controller {
|
||||
@ApiAction
|
||||
public Result createUsersWithArrayInput(Http.Request request) throws Exception {
|
||||
JsonNode nodebody = request.body().asJson();
|
||||
List<User> body;
|
||||
List<@Valid User> body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<@Valid User>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (User curItem : body) {
|
||||
OpenAPIUtils.validate(curItem);
|
||||
@@ -70,9 +71,9 @@ public class UserApiController extends Controller {
|
||||
@ApiAction
|
||||
public Result createUsersWithListInput(Http.Request request) throws Exception {
|
||||
JsonNode nodebody = request.body().asJson();
|
||||
List<User> body;
|
||||
List<@Valid User> body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<@Valid User>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (User curItem : body) {
|
||||
OpenAPIUtils.validate(curItem);
|
||||
|
||||
Reference in New Issue
Block a user