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;
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.LinkedHashSet;
|
||||
import java.io.FileInputStream;
|
||||
import play.libs.Files.TemporaryFile;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen")
|
||||
public class PetApiControllerImp extends PetApiControllerImpInterface {
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import static play.mvc.Results.unauthorized;
|
||||
import play.libs.Files.TemporaryFile;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public abstract class PetApiControllerImpInterface {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.LinkedHashSet;
|
||||
import java.io.FileInputStream;
|
||||
import play.libs.Files.TemporaryFile;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen")
|
||||
public class StoreApiControllerImp extends StoreApiControllerImpInterface {
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import static play.mvc.Results.unauthorized;
|
||||
import play.libs.Files.TemporaryFile;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public abstract class StoreApiControllerImpInterface {
|
||||
|
||||
@@ -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;
|
||||
@@ -55,9 +56,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);
|
||||
@@ -72,9 +73,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);
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.LinkedHashSet;
|
||||
import java.io.FileInputStream;
|
||||
import play.libs.Files.TemporaryFile;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen")
|
||||
public class UserApiControllerImp extends UserApiControllerImpInterface {
|
||||
@Override
|
||||
@@ -19,12 +20,12 @@ public class UserApiControllerImp extends UserApiControllerImpInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUsersWithArrayInput(Http.Request request, List<User> body) throws Exception {
|
||||
public void createUsersWithArrayInput(Http.Request request, List<@Valid User> body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUsersWithListInput(Http.Request request, List<User> body) throws Exception {
|
||||
public void createUsersWithListInput(Http.Request request, List<@Valid User> body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import static play.mvc.Results.unauthorized;
|
||||
import play.libs.Files.TemporaryFile;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public abstract class UserApiControllerImpInterface {
|
||||
@@ -35,21 +36,21 @@ public abstract class UserApiControllerImpInterface {
|
||||
|
||||
public abstract void createUser(Http.Request request, User body) throws Exception;
|
||||
|
||||
public Result createUsersWithArrayInputHttp(Http.Request request, List<User> body) throws Exception {
|
||||
public Result createUsersWithArrayInputHttp(Http.Request request, List<@Valid User> body) throws Exception {
|
||||
createUsersWithArrayInput(request, body);
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
public abstract void createUsersWithArrayInput(Http.Request request, List<User> body) throws Exception;
|
||||
public abstract void createUsersWithArrayInput(Http.Request request, List<@Valid User> body) throws Exception;
|
||||
|
||||
public Result createUsersWithListInputHttp(Http.Request request, List<User> body) throws Exception {
|
||||
public Result createUsersWithListInputHttp(Http.Request request, List<@Valid User> body) throws Exception {
|
||||
createUsersWithListInput(request, body);
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
public abstract void createUsersWithListInput(Http.Request request, List<User> body) throws Exception;
|
||||
public abstract void createUsersWithListInput(Http.Request request, List<@Valid User> body) throws Exception;
|
||||
|
||||
public Result deleteUserHttp(Http.Request request, String username) throws Exception {
|
||||
deleteUser(request, username);
|
||||
|
||||
Reference in New Issue
Block a user