forked from loafle/openapi-generator-original
* Fix issue #6100. Tested with all the samples. * Fix multiple issue with the examples. Removing all of this. Adding fake endpoint .sh but it is not compiling right now.
This commit is contained in:
committed by
wing328
parent
5c384d0f15
commit
1e991be5f3
@@ -7,3 +7,4 @@
|
|||||||
./bin/java-play-framework-petstore-server-no-interface.sh
|
./bin/java-play-framework-petstore-server-no-interface.sh
|
||||||
./bin/java-play-framework-petstore-server-no-swagger-ui.sh
|
./bin/java-play-framework-petstore-server-no-swagger-ui.sh
|
||||||
./bin/java-play-framework-petstore-server-no-wrap-calls.sh
|
./bin/java-play-framework-petstore-server-no-wrap-calls.sh
|
||||||
|
./bin/java-play-framework-petstore-server-fake-endpoints.sh
|
||||||
@@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaPlayFramework -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-play-framework -o samples/server/petstore/java-play-framework-no-interface -DhideGenerationTimestamp=true,useInterface=false"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaPlayFramework -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-play-framework -o samples/server/petstore/java-play-framework-no-interface -DhideGenerationTimestamp=true,useInterfaces=false"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -153,6 +153,9 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
|||||||
supportingFiles.add(new SupportingFile("routes.mustache", "conf", "routes"));
|
supportingFiles.add(new SupportingFile("routes.mustache", "conf", "routes"));
|
||||||
|
|
||||||
//App/Utils folder
|
//App/Utils folder
|
||||||
|
if (!this.controllerOnly && this.useInterfaces) {
|
||||||
|
supportingFiles.add(new SupportingFile("module.mustache", "app", "Module.java"));
|
||||||
|
}
|
||||||
supportingFiles.add(new SupportingFile("swaggerUtils.mustache", "app/swagger", "SwaggerUtils.java"));
|
supportingFiles.add(new SupportingFile("swaggerUtils.mustache", "app/swagger", "SwaggerUtils.java"));
|
||||||
if (this.handleExceptions) {
|
if (this.handleExceptions) {
|
||||||
supportingFiles.add(new SupportingFile("errorHandler.mustache", "app/swagger", "ErrorHandler.java"));
|
supportingFiles.add(new SupportingFile("errorHandler.mustache", "app/swagger", "ErrorHandler.java"));
|
||||||
|
|||||||
@@ -61,7 +61,12 @@ play.modules {
|
|||||||
# in the root package (the "app" directory), or you can define them
|
# in the root package (the "app" directory), or you can define them
|
||||||
# explicitly below.
|
# explicitly below.
|
||||||
# If there are any built-in modules that you want to disable, you can list them here.
|
# If there are any built-in modules that you want to disable, you can list them here.
|
||||||
#disabled += ""
|
{{#controllerOnly}}
|
||||||
|
disabled += "Module"
|
||||||
|
{{/controllerOnly}}
|
||||||
|
{{^useInterfaces}}
|
||||||
|
disabled += "Module"
|
||||||
|
{{/useInterfaces}}
|
||||||
}
|
}
|
||||||
|
|
||||||
## IDE
|
## IDE
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
import controllers.*;
|
||||||
|
|
||||||
|
public class Module extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
{{#apiInfo}}
|
||||||
|
{{#apis}}
|
||||||
|
bind({{classname}}ControllerImpInterface.class).to({{classname}}ControllerImp.class);
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,24 +14,10 @@ import javax.validation.constraints.*;
|
|||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}}ControllerImp {{#useInterfaces}}implements {{classname}}ControllerImpInterface{{/useInterfaces}} {
|
public class {{classname}}ControllerImp {{#useInterfaces}}implements {{classname}}ControllerImpInterface{{/useInterfaces}} {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private {{classname}}ControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{#useInterfaces}}@Override{{/useInterfaces}}
|
{{#useInterfaces}}@Override{{/useInterfaces}}
|
||||||
public {{>returnTypes}} {{operationId}}({{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} {
|
public {{>returnTypes}} {{operationId}}({{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
{{#examples}}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("{{{contentType}}}")) {
|
|
||||||
return mapper.readValue("{{#lamdaRemoveLineBreak}}{{#lamdaEscapeDoubleQuote}}{{{example}}}{{/lamdaEscapeDoubleQuote}}{{/lamdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class);
|
|
||||||
}
|
|
||||||
{{/examples}}
|
|
||||||
{{#returnType}}{{#isResponseFile}}return new FileInputStream("replace this");{{/isResponseFile}}{{^isResponseFile}}return new {{>returnTypesNoVoidNoAbstract}}();{{/isResponseFile}}{{/returnType}}
|
{{#returnType}}{{#isResponseFile}}return new FileInputStream("replace this");{{/isResponseFile}}{{^isResponseFile}}return new {{>returnTypesNoVoidNoAbstract}}();{{/isResponseFile}}{{/returnType}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,16 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}}Controller extends Controller {
|
public class {{classname}}Controller extends Controller {
|
||||||
|
|
||||||
{{^controllerOnly}}private final {{classname}}ControllerImp imp;{{/controllerOnly}}
|
{{^controllerOnly}}
|
||||||
|
private final {{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp;
|
||||||
|
{{/controllerOnly}}
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private {{classname}}Controller({{^controllerOnly}}{{classname}}ControllerImp imp{{/controllerOnly}}) {
|
private {{classname}}Controller({{^controllerOnly}}{{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp{{/controllerOnly}}) {
|
||||||
{{^controllerOnly}}this.imp = imp;{{/controllerOnly}}
|
{{^controllerOnly}}
|
||||||
|
this.imp = imp;
|
||||||
|
{{/controllerOnly}}
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class Order {
|
|||||||
* Get complete
|
* Get complete
|
||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
public Boolean getComplete() {
|
public Boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class PetApiController extends Controller {
|
public class PetApiController extends Controller {
|
||||||
|
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PetApiController() {
|
private PetApiController() {
|
||||||
|
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class StoreApiController extends Controller {
|
public class StoreApiController extends Controller {
|
||||||
|
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StoreApiController() {
|
private StoreApiController() {
|
||||||
|
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class UserApiController extends Controller {
|
public class UserApiController extends Controller {
|
||||||
|
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private UserApiController() {
|
private UserApiController() {
|
||||||
|
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
|||||||
|
|
||||||
scalaVersion := "2.11.7"
|
scalaVersion := "2.11.7"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||||
javaJdbc,
|
libraryDependencies += "javax.validation" % "validation-api" % "1.1.0.Final"
|
||||||
cache,
|
|
||||||
javaWs,
|
|
||||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
|
||||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ play.modules {
|
|||||||
# in the root package (the "app" directory), or you can define them
|
# in the root package (the "app" directory), or you can define them
|
||||||
# explicitly below.
|
# explicitly below.
|
||||||
# If there are any built-in modules that you want to disable, you can list them here.
|
# If there are any built-in modules that you want to disable, you can list them here.
|
||||||
#disabled += ""
|
disabled += "Module"
|
||||||
}
|
}
|
||||||
|
|
||||||
## IDE
|
## IDE
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
2017-08-08 12:56:15,882 [INFO] from play.api.Play in ForkJoinPool-1-worker-1 - Application started (Dev)
|
||||||
@@ -173,6 +173,7 @@
|
|||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
|
"deprecated" : true,
|
||||||
"x-contentType" : "application/json",
|
"x-contentType" : "application/json",
|
||||||
"x-accepts" : "application/json"
|
"x-accepts" : "application/json"
|
||||||
}
|
}
|
||||||
@@ -749,7 +750,7 @@
|
|||||||
"title" : "Pet catehgry",
|
"title" : "Pet catehgry",
|
||||||
"description" : "A category for a pet",
|
"description" : "A category for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -790,14 +791,14 @@
|
|||||||
"title" : "a User",
|
"title" : "a User",
|
||||||
"description" : "A User who is purchasing from the pet store",
|
"description" : "A User who is purchasing from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"firstName" : "aeiou",
|
"firstName" : "firstName",
|
||||||
"lastName" : "aeiou",
|
"lastName" : "lastName",
|
||||||
"password" : "aeiou",
|
"password" : "password",
|
||||||
"userStatus" : 6,
|
"userStatus" : 6,
|
||||||
"phone" : "aeiou",
|
"phone" : "phone",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"email" : "aeiou",
|
"email" : "email",
|
||||||
"username" : "aeiou"
|
"username" : "username"
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "User"
|
"name" : "User"
|
||||||
@@ -817,7 +818,7 @@
|
|||||||
"title" : "Pet Tag",
|
"title" : "Pet Tag",
|
||||||
"description" : "A tag for a pet",
|
"description" : "A tag for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -868,15 +869,18 @@
|
|||||||
"title" : "a Pet",
|
"title" : "a Pet",
|
||||||
"description" : "A pet for sale in the pet store",
|
"description" : "A pet for sale in the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
"name" : "doggie",
|
"name" : "doggie",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
} ],
|
} ],
|
||||||
"status" : "available"
|
"status" : "available"
|
||||||
@@ -903,8 +907,8 @@
|
|||||||
"description" : "Describes the result of uploading an image resource",
|
"description" : "Describes the result of uploading an image resource",
|
||||||
"example" : {
|
"example" : {
|
||||||
"code" : 0,
|
"code" : 0,
|
||||||
"type" : "aeiou",
|
"type" : "type",
|
||||||
"message" : "aeiou"
|
"message" : "message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
import controllers.*;
|
||||||
|
|
||||||
|
public class Module extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(FakeApiControllerImpInterface.class).to(FakeApiControllerImp.class);
|
||||||
|
bind(FakeClassnameTags123ApiControllerImpInterface.class).to(FakeClassnameTags123ApiControllerImp.class);
|
||||||
|
bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class);
|
||||||
|
bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class);
|
||||||
|
bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,10 @@ import java.util.Objects;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* AdditionalPropertiesClass
|
* AdditionalPropertiesClass
|
||||||
*/
|
*/
|
||||||
@@ -59,6 +61,7 @@ public class AdditionalPropertiesClass {
|
|||||||
* Get mapOfMapProperty
|
* Get mapOfMapProperty
|
||||||
* @return mapOfMapProperty
|
* @return mapOfMapProperty
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public Map<String, Map<String, String>> getMapOfMapProperty() {
|
public Map<String, Map<String, String>> getMapOfMapProperty() {
|
||||||
return mapOfMapProperty;
|
return mapOfMapProperty;
|
||||||
}
|
}
|
||||||
@@ -107,5 +110,21 @@ public class AdditionalPropertiesClass {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<AdditionalPropertiesClass>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<AdditionalPropertiesClass> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package apimodels;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Animal
|
* Animal
|
||||||
*/
|
*/
|
||||||
@@ -91,5 +93,21 @@ public class Animal {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Animal>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Animal> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import java.util.Objects;
|
|||||||
import apimodels.Animal;
|
import apimodels.Animal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* AnimalFarm
|
* AnimalFarm
|
||||||
*/
|
*/
|
||||||
@@ -47,5 +49,21 @@ public class AnimalFarm extends ArrayList<Animal> {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<AnimalFarm>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<AnimalFarm> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import java.util.Objects;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* ArrayOfArrayOfNumberOnly
|
* ArrayOfArrayOfNumberOnly
|
||||||
*/
|
*/
|
||||||
@@ -31,6 +33,7 @@ public class ArrayOfArrayOfNumberOnly {
|
|||||||
* Get arrayArrayNumber
|
* Get arrayArrayNumber
|
||||||
* @return arrayArrayNumber
|
* @return arrayArrayNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public List<List<BigDecimal>> getArrayArrayNumber() {
|
public List<List<BigDecimal>> getArrayArrayNumber() {
|
||||||
return arrayArrayNumber;
|
return arrayArrayNumber;
|
||||||
}
|
}
|
||||||
@@ -77,5 +80,21 @@ public class ArrayOfArrayOfNumberOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ArrayOfArrayOfNumberOnly>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ArrayOfArrayOfNumberOnly> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import java.util.Objects;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* ArrayOfNumberOnly
|
* ArrayOfNumberOnly
|
||||||
*/
|
*/
|
||||||
@@ -31,6 +33,7 @@ public class ArrayOfNumberOnly {
|
|||||||
* Get arrayNumber
|
* Get arrayNumber
|
||||||
* @return arrayNumber
|
* @return arrayNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public List<BigDecimal> getArrayNumber() {
|
public List<BigDecimal> getArrayNumber() {
|
||||||
return arrayNumber;
|
return arrayNumber;
|
||||||
}
|
}
|
||||||
@@ -77,5 +80,21 @@ public class ArrayOfNumberOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ArrayOfNumberOnly>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ArrayOfNumberOnly> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import java.util.Objects;
|
|||||||
import apimodels.ReadOnlyFirst;
|
import apimodels.ReadOnlyFirst;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* ArrayTest
|
* ArrayTest
|
||||||
*/
|
*/
|
||||||
@@ -62,6 +64,7 @@ public class ArrayTest {
|
|||||||
* Get arrayArrayOfInteger
|
* Get arrayArrayOfInteger
|
||||||
* @return arrayArrayOfInteger
|
* @return arrayArrayOfInteger
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public List<List<Long>> getArrayArrayOfInteger() {
|
public List<List<Long>> getArrayArrayOfInteger() {
|
||||||
return arrayArrayOfInteger;
|
return arrayArrayOfInteger;
|
||||||
}
|
}
|
||||||
@@ -87,6 +90,7 @@ public class ArrayTest {
|
|||||||
* Get arrayArrayOfModel
|
* Get arrayArrayOfModel
|
||||||
* @return arrayArrayOfModel
|
* @return arrayArrayOfModel
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
|
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
|
||||||
return arrayArrayOfModel;
|
return arrayArrayOfModel;
|
||||||
}
|
}
|
||||||
@@ -137,5 +141,21 @@ public class ArrayTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ArrayTest>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ArrayTest> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Capitalization
|
* Capitalization
|
||||||
*/
|
*/
|
||||||
@@ -176,5 +178,21 @@ public class Capitalization {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Capitalization>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Capitalization> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package apimodels;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import apimodels.Animal;
|
import apimodels.Animal;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Cat
|
* Cat
|
||||||
*/
|
*/
|
||||||
@@ -21,7 +23,7 @@ public class Cat extends Animal {
|
|||||||
* Get declawed
|
* Get declawed
|
||||||
* @return declawed
|
* @return declawed
|
||||||
**/
|
**/
|
||||||
public Boolean getDeclawed() {
|
public Boolean isDeclawed() {
|
||||||
return declawed;
|
return declawed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,5 +70,21 @@ public class Cat extends Animal {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Cat>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Cat> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Category
|
* Category
|
||||||
*/
|
*/
|
||||||
@@ -88,5 +90,21 @@ public class Category {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Category>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Category> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Model for testing model with \"_class\" property
|
* Model for testing model with \"_class\" property
|
||||||
*/
|
*/
|
||||||
@@ -66,5 +68,21 @@ public class ClassModel {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ClassModel>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ClassModel> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Client
|
* Client
|
||||||
*/
|
*/
|
||||||
@@ -66,5 +68,21 @@ public class Client {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Client>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Client> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package apimodels;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import apimodels.Animal;
|
import apimodels.Animal;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Dog
|
* Dog
|
||||||
*/
|
*/
|
||||||
@@ -68,5 +70,21 @@ public class Dog extends Animal {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Dog>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Dog> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package apimodels;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* EnumArrays
|
* EnumArrays
|
||||||
*/
|
*/
|
||||||
@@ -160,5 +162,21 @@ public class EnumArrays {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<EnumArrays>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<EnumArrays> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package apimodels;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import apimodels.OuterEnum;
|
import apimodels.OuterEnum;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* EnumTest
|
* EnumTest
|
||||||
*/
|
*/
|
||||||
@@ -176,6 +178,7 @@ public class EnumTest {
|
|||||||
* Get outerEnum
|
* Get outerEnum
|
||||||
* @return outerEnum
|
* @return outerEnum
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public OuterEnum getOuterEnum() {
|
public OuterEnum getOuterEnum() {
|
||||||
return outerEnum;
|
return outerEnum;
|
||||||
}
|
}
|
||||||
@@ -228,5 +231,21 @@ public class EnumTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<EnumTest>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<EnumTest> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* FormatTest
|
* FormatTest
|
||||||
*/
|
*/
|
||||||
@@ -63,7 +65,7 @@ public class FormatTest {
|
|||||||
* @return integer
|
* @return integer
|
||||||
**/
|
**/
|
||||||
@Min(10)
|
@Min(10)
|
||||||
@Max(100)
|
@Max(100)
|
||||||
public Integer getInteger() {
|
public Integer getInteger() {
|
||||||
return integer;
|
return integer;
|
||||||
}
|
}
|
||||||
@@ -84,7 +86,7 @@ public class FormatTest {
|
|||||||
* @return int32
|
* @return int32
|
||||||
**/
|
**/
|
||||||
@Min(20)
|
@Min(20)
|
||||||
@Max(200)
|
@Max(200)
|
||||||
public Integer getInt32() {
|
public Integer getInt32() {
|
||||||
return int32;
|
return int32;
|
||||||
}
|
}
|
||||||
@@ -122,8 +124,9 @@ public class FormatTest {
|
|||||||
* @return number
|
* @return number
|
||||||
**/
|
**/
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin("32.1")
|
@DecimalMin("32.1")
|
||||||
@DecimalMax("543.2")
|
@DecimalMax("543.2")
|
||||||
|
@Valid
|
||||||
public BigDecimal getNumber() {
|
public BigDecimal getNumber() {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
@@ -144,7 +147,7 @@ public class FormatTest {
|
|||||||
* @return _float
|
* @return _float
|
||||||
**/
|
**/
|
||||||
@DecimalMin("54.3")
|
@DecimalMin("54.3")
|
||||||
@DecimalMax("987.6")
|
@DecimalMax("987.6")
|
||||||
public Float getFloat() {
|
public Float getFloat() {
|
||||||
return _float;
|
return _float;
|
||||||
}
|
}
|
||||||
@@ -165,7 +168,7 @@ public class FormatTest {
|
|||||||
* @return _double
|
* @return _double
|
||||||
**/
|
**/
|
||||||
@DecimalMin("67.8")
|
@DecimalMin("67.8")
|
||||||
@DecimalMax("123.4")
|
@DecimalMax("123.4")
|
||||||
public Double getDouble() {
|
public Double getDouble() {
|
||||||
return _double;
|
return _double;
|
||||||
}
|
}
|
||||||
@@ -202,6 +205,7 @@ public class FormatTest {
|
|||||||
* @return _byte
|
* @return _byte
|
||||||
**/
|
**/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$")
|
||||||
public byte[] getByte() {
|
public byte[] getByte() {
|
||||||
return _byte;
|
return _byte;
|
||||||
}
|
}
|
||||||
@@ -237,6 +241,7 @@ public class FormatTest {
|
|||||||
* @return date
|
* @return date
|
||||||
**/
|
**/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
public LocalDate getDate() {
|
public LocalDate getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
@@ -254,6 +259,7 @@ public class FormatTest {
|
|||||||
* Get dateTime
|
* Get dateTime
|
||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public OffsetDateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
@@ -271,6 +277,7 @@ public class FormatTest {
|
|||||||
* Get uuid
|
* Get uuid
|
||||||
* @return uuid
|
* @return uuid
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@@ -289,7 +296,7 @@ public class FormatTest {
|
|||||||
* @return password
|
* @return password
|
||||||
**/
|
**/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min=10,max=64)
|
@Size(min=10,max=64)
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
@@ -360,5 +367,21 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<FormatTest>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<FormatTest> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* HasOnlyReadOnly
|
* HasOnlyReadOnly
|
||||||
*/
|
*/
|
||||||
@@ -88,5 +90,21 @@ public class HasOnlyReadOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<HasOnlyReadOnly>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<HasOnlyReadOnly> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import java.util.Objects;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* MapTest
|
* MapTest
|
||||||
*/
|
*/
|
||||||
@@ -65,6 +67,7 @@ public class MapTest {
|
|||||||
* Get mapMapOfString
|
* Get mapMapOfString
|
||||||
* @return mapMapOfString
|
* @return mapMapOfString
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public Map<String, Map<String, String>> getMapMapOfString() {
|
public Map<String, Map<String, String>> getMapMapOfString() {
|
||||||
return mapMapOfString;
|
return mapMapOfString;
|
||||||
}
|
}
|
||||||
@@ -138,5 +141,21 @@ public class MapTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<MapTest>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<MapTest> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* MixedPropertiesAndAdditionalPropertiesClass
|
* MixedPropertiesAndAdditionalPropertiesClass
|
||||||
*/
|
*/
|
||||||
@@ -32,6 +34,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* Get uuid
|
* Get uuid
|
||||||
* @return uuid
|
* @return uuid
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@@ -49,6 +52,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* Get dateTime
|
* Get dateTime
|
||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public OffsetDateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
@@ -74,6 +78,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* Get map
|
* Get map
|
||||||
* @return map
|
* @return map
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public Map<String, Animal> getMap() {
|
public Map<String, Animal> getMap() {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -124,5 +129,21 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<MixedPropertiesAndAdditionalPropertiesClass>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<MixedPropertiesAndAdditionalPropertiesClass> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Model for testing model name starting with number
|
* Model for testing model name starting with number
|
||||||
*/
|
*/
|
||||||
@@ -88,5 +90,21 @@ public class Model200Response {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Model200Response>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Model200Response> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* ModelApiResponse
|
* ModelApiResponse
|
||||||
*/
|
*/
|
||||||
@@ -110,5 +112,21 @@ public class ModelApiResponse {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ModelApiResponse>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ModelApiResponse> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Model for testing reserved words
|
* Model for testing reserved words
|
||||||
*/
|
*/
|
||||||
@@ -66,5 +68,21 @@ public class ModelReturn {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ModelReturn>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ModelReturn> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Model for testing model name same as property name
|
* Model for testing model name same as property name
|
||||||
*/
|
*/
|
||||||
@@ -133,5 +135,21 @@ public class Name {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Name>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Name> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package apimodels;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* NumberOnly
|
* NumberOnly
|
||||||
*/
|
*/
|
||||||
@@ -21,6 +23,7 @@ public class NumberOnly {
|
|||||||
* Get justNumber
|
* Get justNumber
|
||||||
* @return justNumber
|
* @return justNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public BigDecimal getJustNumber() {
|
public BigDecimal getJustNumber() {
|
||||||
return justNumber;
|
return justNumber;
|
||||||
}
|
}
|
||||||
@@ -67,5 +70,21 @@ public class NumberOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<NumberOnly>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<NumberOnly> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package apimodels;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Order
|
* Order
|
||||||
*/
|
*/
|
||||||
@@ -120,6 +122,7 @@ public class Order {
|
|||||||
* Get shipDate
|
* Get shipDate
|
||||||
* @return shipDate
|
* @return shipDate
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public OffsetDateTime getShipDate() {
|
public OffsetDateTime getShipDate() {
|
||||||
return shipDate;
|
return shipDate;
|
||||||
}
|
}
|
||||||
@@ -154,7 +157,7 @@ public class Order {
|
|||||||
* Get complete
|
* Get complete
|
||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
public Boolean getComplete() {
|
public Boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,5 +213,21 @@ public class Order {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Order>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Order> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package apimodels;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* OuterComposite
|
* OuterComposite
|
||||||
*/
|
*/
|
||||||
@@ -27,6 +29,7 @@ public class OuterComposite {
|
|||||||
* Get myNumber
|
* Get myNumber
|
||||||
* @return myNumber
|
* @return myNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public BigDecimal getMyNumber() {
|
public BigDecimal getMyNumber() {
|
||||||
return myNumber;
|
return myNumber;
|
||||||
}
|
}
|
||||||
@@ -111,5 +114,21 @@ public class OuterComposite {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<OuterComposite>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<OuterComposite> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import apimodels.Category;
|
|||||||
import apimodels.Tag;
|
import apimodels.Tag;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Pet
|
* Pet
|
||||||
*/
|
*/
|
||||||
@@ -89,6 +91,7 @@ public class Pet {
|
|||||||
* Get category
|
* Get category
|
||||||
* @return category
|
* @return category
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public Category getCategory() {
|
public Category getCategory() {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
@@ -155,6 +158,7 @@ public class Pet {
|
|||||||
* Get tags
|
* Get tags
|
||||||
* @return tags
|
* @return tags
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
public List<Tag> getTags() {
|
public List<Tag> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
@@ -228,5 +232,21 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Pet>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Pet> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* ReadOnlyFirst
|
* ReadOnlyFirst
|
||||||
*/
|
*/
|
||||||
@@ -88,5 +90,21 @@ public class ReadOnlyFirst {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<ReadOnlyFirst>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<ReadOnlyFirst> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* SpecialModelName
|
* SpecialModelName
|
||||||
*/
|
*/
|
||||||
@@ -66,5 +68,21 @@ public class SpecialModelName {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<SpecialModelName>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<SpecialModelName> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* Tag
|
* Tag
|
||||||
*/
|
*/
|
||||||
@@ -88,5 +90,21 @@ public class Tag {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<Tag>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<Tag> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package apimodels;
|
package apimodels;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
*/
|
*/
|
||||||
@@ -220,5 +222,21 @@ public class User {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
Validator validator = factory.getValidator();
|
||||||
|
Set<ConstraintViolation<User>> constraintViolations = validator.validate(this);
|
||||||
|
if (constraintViolations.size() > 0) {
|
||||||
|
StringBuilder errors = new StringBuilder();
|
||||||
|
for (ConstraintViolation<User> contraintes : constraintViolations) {
|
||||||
|
errors.append(String.format("%s.%s %s\n",
|
||||||
|
contraintes.getRootBeanClass().getSimpleName(),
|
||||||
|
contraintes.getPropertyPath(),
|
||||||
|
contraintes.getMessage()));
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Bean validation : " + errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import play.mvc.Controller;
|
|||||||
import play.mvc.Result;
|
import play.mvc.Result;
|
||||||
import play.mvc.Http;
|
import play.mvc.Http;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -25,11 +26,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class FakeApiController extends Controller {
|
public class FakeApiController extends Controller {
|
||||||
|
|
||||||
private final FakeApiControllerImp imp;
|
private final FakeApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FakeApiController(FakeApiControllerImp imp) {
|
private FakeApiController(FakeApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,7 @@ public class FakeApiController extends Controller {
|
|||||||
if (nodebody != null) {
|
if (nodebody != null) {
|
||||||
body = mapper.readValue(nodebody.toString(), Boolean.class);
|
body = mapper.readValue(nodebody.toString(), Boolean.class);
|
||||||
|
|
||||||
|
body.validate();
|
||||||
} else {
|
} else {
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
@@ -49,6 +51,7 @@ public class FakeApiController extends Controller {
|
|||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -58,13 +61,16 @@ public class FakeApiController extends Controller {
|
|||||||
if (nodebody != null) {
|
if (nodebody != null) {
|
||||||
body = mapper.readValue(nodebody.toString(), OuterComposite.class);
|
body = mapper.readValue(nodebody.toString(), OuterComposite.class);
|
||||||
|
|
||||||
|
body.validate();
|
||||||
} else {
|
} else {
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
OuterComposite obj = imp.fakeOuterCompositeSerialize(body);
|
OuterComposite obj = imp.fakeOuterCompositeSerialize(body);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -74,13 +80,16 @@ public class FakeApiController extends Controller {
|
|||||||
if (nodebody != null) {
|
if (nodebody != null) {
|
||||||
body = mapper.readValue(nodebody.toString(), BigDecimal.class);
|
body = mapper.readValue(nodebody.toString(), BigDecimal.class);
|
||||||
|
|
||||||
|
body.validate();
|
||||||
} else {
|
} else {
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
BigDecimal obj = imp.fakeOuterNumberSerialize(body);
|
BigDecimal obj = imp.fakeOuterNumberSerialize(body);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -90,6 +99,7 @@ public class FakeApiController extends Controller {
|
|||||||
if (nodebody != null) {
|
if (nodebody != null) {
|
||||||
body = mapper.readValue(nodebody.toString(), String.class);
|
body = mapper.readValue(nodebody.toString(), String.class);
|
||||||
|
|
||||||
|
body.validate();
|
||||||
} else {
|
} else {
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
@@ -97,6 +107,7 @@ public class FakeApiController extends Controller {
|
|||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -105,135 +116,139 @@ public class FakeApiController extends Controller {
|
|||||||
Client body;
|
Client body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), Client.class);
|
body = mapper.readValue(nodebody.toString(), Client.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
Client obj = imp.testClientModel(body);
|
Client obj = imp.testClientModel(body);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result testEndpointParameters() throws Exception {
|
public Result testEndpointParameters() throws Exception {
|
||||||
String valueinteger = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("integer"))[0];
|
String valueinteger = (request().body().asMultipartFormData().asFormUrlEncoded().get("integer"))[0];
|
||||||
Integer integer;
|
Integer integer;
|
||||||
if (valueinteger != null) {
|
if (valueinteger != null) {
|
||||||
integer = Integer.parseInt(valueinteger);
|
integer = Integer.parseInt(valueinteger);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
integer = 0;
|
integer = null;
|
||||||
}
|
}
|
||||||
String valueint32 = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("int32"))[0];
|
String valueint32 = (request().body().asMultipartFormData().asFormUrlEncoded().get("int32"))[0];
|
||||||
Integer int32;
|
Integer int32;
|
||||||
if (valueint32 != null) {
|
if (valueint32 != null) {
|
||||||
int32 = Integer.parseInt(valueint32);
|
int32 = Integer.parseInt(valueint32);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int32 = 0;
|
int32 = null;
|
||||||
}
|
}
|
||||||
String valueint64 = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("int64"))[0];
|
String valueint64 = (request().body().asMultipartFormData().asFormUrlEncoded().get("int64"))[0];
|
||||||
Long int64;
|
Long int64;
|
||||||
if (valueint64 != null) {
|
if (valueint64 != null) {
|
||||||
int64 = Long.parseLong(valueint64);
|
int64 = Long.parseLong(valueint64);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int64 = 0L;
|
int64 = null;
|
||||||
}
|
}
|
||||||
String valuenumber = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("number"))[0];
|
String valuenumber = (request().body().asMultipartFormData().asFormUrlEncoded().get("number"))[0];
|
||||||
BigDecimal number;
|
BigDecimal number;
|
||||||
|
|
||||||
number = Float.parseFloat(valuenumber);
|
number = Float.parseFloat(valuenumber);
|
||||||
|
|
||||||
String value_float = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("float"))[0];
|
String value_float = (request().body().asMultipartFormData().asFormUrlEncoded().get("float"))[0];
|
||||||
Float _float;
|
Float _float;
|
||||||
if (value_float != null) {
|
if (value_float != null) {
|
||||||
_float = Float.parseFloat(value_float);
|
_float = Float.parseFloat(value_float);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_float = 0.0;
|
_float = null;
|
||||||
}
|
}
|
||||||
String value_double = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("double"))[0];
|
String value_double = (request().body().asMultipartFormData().asFormUrlEncoded().get("double"))[0];
|
||||||
Double _double;
|
Double _double;
|
||||||
|
|
||||||
_double = Double.parseDouble(value_double);
|
_double = Double.parseDouble(value_double);
|
||||||
|
|
||||||
String valuestring = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("string"))[0];
|
String valuestring = (request().body().asMultipartFormData().asFormUrlEncoded().get("string"))[0];
|
||||||
String string;
|
String string;
|
||||||
if (valuestring != null) {
|
if (valuestring != null) {
|
||||||
string = (String)valuestring;
|
string = (String)valuestring;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
string = "";
|
string = null;
|
||||||
}
|
}
|
||||||
String valuepatternWithoutDelimiter = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("pattern_without_delimiter"))[0];
|
String valuepatternWithoutDelimiter = (request().body().asMultipartFormData().asFormUrlEncoded().get("pattern_without_delimiter"))[0];
|
||||||
String patternWithoutDelimiter;
|
String patternWithoutDelimiter;
|
||||||
|
|
||||||
patternWithoutDelimiter = (String)valuepatternWithoutDelimiter;
|
patternWithoutDelimiter = (String)valuepatternWithoutDelimiter;
|
||||||
|
|
||||||
String value_byte = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("byte"))[0];
|
String value_byte = (request().body().asMultipartFormData().asFormUrlEncoded().get("byte"))[0];
|
||||||
byte[] _byte;
|
byte[] _byte;
|
||||||
|
|
||||||
_byte = value_byte;
|
_byte = (String)value_byte;
|
||||||
|
|
||||||
String valuebinary = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("binary"))[0];
|
String valuebinary = (request().body().asMultipartFormData().asFormUrlEncoded().get("binary"))[0];
|
||||||
byte[] binary;
|
byte[] binary;
|
||||||
if (valuebinary != null) {
|
if (valuebinary != null) {
|
||||||
binary = valuebinary;
|
binary = valuebinary;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
binary = ;
|
binary = null;
|
||||||
}
|
}
|
||||||
String valuedate = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("date"))[0];
|
String valuedate = (request().body().asMultipartFormData().asFormUrlEncoded().get("date"))[0];
|
||||||
LocalDate date;
|
LocalDate date;
|
||||||
if (valuedate != null) {
|
if (valuedate != null) {
|
||||||
date = valuedate;
|
date = valuedate;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
date = ;
|
date = null;
|
||||||
}
|
}
|
||||||
String valuedateTime = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("dateTime"))[0];
|
String valuedateTime = (request().body().asMultipartFormData().asFormUrlEncoded().get("dateTime"))[0];
|
||||||
OffsetDateTime dateTime;
|
OffsetDateTime dateTime;
|
||||||
if (valuedateTime != null) {
|
if (valuedateTime != null) {
|
||||||
dateTime = valuedateTime;
|
dateTime = OffsetDateTime.parse(valuedateTime);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dateTime = ;
|
dateTime = null;
|
||||||
}
|
}
|
||||||
String valuepassword = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("password"))[0];
|
String valuepassword = (request().body().asMultipartFormData().asFormUrlEncoded().get("password"))[0];
|
||||||
String password;
|
String password;
|
||||||
if (valuepassword != null) {
|
if (valuepassword != null) {
|
||||||
password = (String)valuepassword;
|
password = (String)valuepassword;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
password = "";
|
password = null;
|
||||||
}
|
}
|
||||||
String valueparamCallback = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("callback"))[0];
|
String valueparamCallback = (request().body().asMultipartFormData().asFormUrlEncoded().get("callback"))[0];
|
||||||
String paramCallback;
|
String paramCallback;
|
||||||
if (valueparamCallback != null) {
|
if (valueparamCallback != null) {
|
||||||
paramCallback = (String)valueparamCallback;
|
paramCallback = (String)valueparamCallback;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
paramCallback = "";
|
paramCallback = null;
|
||||||
}
|
}
|
||||||
imp.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
imp.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result testEnumParameters() throws Exception {
|
public Result testEnumParameters() throws Exception {
|
||||||
//TODO: Support this later
|
List<String> enumQueryStringArrayList = SwaggerUtils.parametersToList("csv", request().queryString().get("enum_query_string_array"));
|
||||||
//List<Pair> enumQueryStringArrayPair = SwaggerUtils.parameterToPairs("csv", "enumQueryStringArray", request().getQueryString("enum_query_string_array"));
|
|
||||||
List<String> enumQueryStringArray = new ArrayList<String>();
|
List<String> enumQueryStringArray = new ArrayList<String>();
|
||||||
//for (Pair pair : enumQueryStringArrayPair) {
|
for (String curParam : enumQueryStringArrayList) {
|
||||||
// enumQueryStringArray.add(pair.getValue());
|
//noinspection UseBulkOperation
|
||||||
//}
|
enumQueryStringArray.add(curParam);
|
||||||
|
}
|
||||||
String valueenumQueryString = request().getQueryString("enumQueryString");
|
String valueenumQueryString = request().getQueryString("enumQueryString");
|
||||||
String enumQueryString;
|
String enumQueryString;
|
||||||
if (valueenumQueryString != null) {
|
if (valueenumQueryString != null) {
|
||||||
enumQueryString = (String)valueenumQueryString;
|
enumQueryString = (String)valueenumQueryString;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enumQueryString = "";
|
enumQueryString = "-efg";
|
||||||
}
|
}
|
||||||
String valueenumQueryInteger = request().getQueryString("enumQueryInteger");
|
String valueenumQueryInteger = request().getQueryString("enumQueryInteger");
|
||||||
Integer enumQueryInteger;
|
Integer enumQueryInteger;
|
||||||
@@ -241,57 +256,58 @@ public class FakeApiController extends Controller {
|
|||||||
enumQueryInteger = Integer.parseInt(valueenumQueryInteger);
|
enumQueryInteger = Integer.parseInt(valueenumQueryInteger);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enumQueryInteger = 0;
|
enumQueryInteger = null;
|
||||||
}
|
}
|
||||||
//TODO: Support this later
|
List<String> enumFormStringArrayList = SwaggerUtils.parametersToList("csv", request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array"));
|
||||||
//List<Pair> enumFormStringArrayPair = SwaggerUtils.parameterToPairs("csv", "enumFormStringArray", ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array"))[0]);
|
|
||||||
List<String> enumFormStringArray = new ArrayList<String>();
|
List<String> enumFormStringArray = new ArrayList<String>();
|
||||||
//for (Pair pair : enumFormStringArrayPair) {
|
for (String curParam : enumFormStringArrayList) {
|
||||||
// enumFormStringArray.add(pair.getValue());
|
//noinspection UseBulkOperation
|
||||||
//}
|
enumFormStringArray.add(curParam);
|
||||||
String valueenumFormString = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string"))[0];
|
}
|
||||||
|
String valueenumFormString = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string"))[0];
|
||||||
String enumFormString;
|
String enumFormString;
|
||||||
if (valueenumFormString != null) {
|
if (valueenumFormString != null) {
|
||||||
enumFormString = (String)valueenumFormString;
|
enumFormString = (String)valueenumFormString;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enumFormString = "";
|
enumFormString = "-efg";
|
||||||
}
|
}
|
||||||
String valueenumQueryDouble = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("enum_query_double"))[0];
|
String valueenumQueryDouble = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_query_double"))[0];
|
||||||
Double enumQueryDouble;
|
Double enumQueryDouble;
|
||||||
if (valueenumQueryDouble != null) {
|
if (valueenumQueryDouble != null) {
|
||||||
enumQueryDouble = Double.parseDouble(valueenumQueryDouble);
|
enumQueryDouble = Double.parseDouble(valueenumQueryDouble);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enumQueryDouble = 0.0;
|
enumQueryDouble = null;
|
||||||
|
}
|
||||||
|
List<String> enumHeaderStringArrayList = SwaggerUtils.parametersToList("csv", request().headers().get("enum_header_string_array"));
|
||||||
|
List<String> enumHeaderStringArray = new ArrayList<String>();
|
||||||
|
for (String curParam : enumHeaderStringArrayList) {
|
||||||
|
//noinspection UseBulkOperation
|
||||||
|
enumHeaderStringArray.add(curParam);
|
||||||
}
|
}
|
||||||
//TODO: Support this later
|
|
||||||
//List<Pair> enumHeaderStringArrayPair = SwaggerUtils.parameterToPairs("csv", "enumHeaderStringArray", request().getHeader("enum_header_string_array"));
|
|
||||||
//List<String> enumHeaderStringArray = new ArrayList<String>();
|
|
||||||
//for (Pair pair : enumHeaderStringArrayPair) {
|
|
||||||
// enumHeaderStringArray.add(pair.getValue());
|
|
||||||
//}
|
|
||||||
String valueenumHeaderString = request().getHeader("enum_header_string");
|
String valueenumHeaderString = request().getHeader("enum_header_string");
|
||||||
String enumHeaderString;
|
String enumHeaderString;
|
||||||
if (valueenumHeaderString != null) {
|
if (valueenumHeaderString != null) {
|
||||||
enumHeaderString = (String)valueenumHeaderString;
|
enumHeaderString = (String)valueenumHeaderString;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enumHeaderString = "";
|
enumHeaderString = "-efg";
|
||||||
}
|
}
|
||||||
imp.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
imp.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result testJsonFormData() throws Exception {
|
public Result testJsonFormData() throws Exception {
|
||||||
String valueparam = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("param"))[0];
|
String valueparam = (request().body().asMultipartFormData().asFormUrlEncoded().get("param"))[0];
|
||||||
String param;
|
String param;
|
||||||
|
|
||||||
param = (String)valueparam;
|
param = (String)valueparam;
|
||||||
|
|
||||||
String valueparam2 = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0];
|
String valueparam2 = (request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0];
|
||||||
String param2;
|
String param2;
|
||||||
|
|
||||||
param2 = (String)valueparam2;
|
param2 = (String)valueparam2;
|
||||||
@@ -299,5 +315,6 @@ public class FakeApiController extends Controller {
|
|||||||
imp.testJsonFormData(param, param2);
|
imp.testJsonFormData(param, param2);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,61 +14,33 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class FakeApiControllerImp implements FakeApiControllerImpInterface {
|
public class FakeApiControllerImp implements FakeApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FakeApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean fakeOuterBooleanSerialize(Boolean body) throws Exception {
|
public Boolean fakeOuterBooleanSerialize(Boolean body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Boolean.class);
|
|
||||||
}
|
|
||||||
return new Boolean();
|
return new Boolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Exception {
|
public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", OuterComposite.class);
|
|
||||||
}
|
|
||||||
return new OuterComposite();
|
return new OuterComposite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws Exception {
|
public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", BigDecimal.class);
|
|
||||||
}
|
|
||||||
return new BigDecimal();
|
return new BigDecimal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String fakeOuterStringSerialize(String body) throws Exception {
|
public String fakeOuterStringSerialize(String body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
return new String();
|
return new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Client testClientModel(Client body) throws Exception {
|
public Client testClientModel(Client body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Client.class);
|
|
||||||
}
|
|
||||||
return new Client();
|
return new Client();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import play.mvc.Controller;
|
|||||||
import play.mvc.Result;
|
import play.mvc.Result;
|
||||||
import play.mvc.Http;
|
import play.mvc.Http;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -21,11 +22,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class FakeClassnameTags123ApiController extends Controller {
|
public class FakeClassnameTags123ApiController extends Controller {
|
||||||
|
|
||||||
private final FakeClassnameTags123ApiControllerImp imp;
|
private final FakeClassnameTags123ApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FakeClassnameTags123ApiController(FakeClassnameTags123ApiControllerImp imp) {
|
private FakeClassnameTags123ApiController(FakeClassnameTags123ApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
@@ -37,10 +38,13 @@ public class FakeClassnameTags123ApiController extends Controller {
|
|||||||
Client body;
|
Client body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), Client.class);
|
body = mapper.readValue(nodebody.toString(), Client.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
Client obj = imp.testClassname(body);
|
Client obj = imp.testClassname(body);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,9 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class FakeClassnameTags123ApiControllerImp implements FakeClassnameTags123ApiControllerImpInterface {
|
public class FakeClassnameTags123ApiControllerImp implements FakeClassnameTags123ApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FakeClassnameTags123ApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Client testClassname(Client body) throws Exception {
|
public Client testClassname(Client body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Client.class);
|
|
||||||
}
|
|
||||||
return new Client();
|
return new Client();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import play.mvc.Controller;
|
|||||||
import play.mvc.Result;
|
import play.mvc.Result;
|
||||||
import play.mvc.Http;
|
import play.mvc.Http;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -23,11 +24,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class PetApiController extends Controller {
|
public class PetApiController extends Controller {
|
||||||
|
|
||||||
private final PetApiControllerImp imp;
|
private final PetApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PetApiController(PetApiControllerImp imp) {
|
private PetApiController(PetApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
@@ -39,10 +40,12 @@ public class PetApiController extends Controller {
|
|||||||
Pet body;
|
Pet body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
imp.addPet(body);
|
imp.addPet(body);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -53,47 +56,58 @@ public class PetApiController extends Controller {
|
|||||||
apiKey = (String)valueapiKey;
|
apiKey = (String)valueapiKey;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
apiKey = "";
|
apiKey = null;
|
||||||
}
|
}
|
||||||
imp.deletePet(petId, apiKey);
|
imp.deletePet(petId, apiKey);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result findPetsByStatus() throws Exception {
|
public Result findPetsByStatus() throws Exception {
|
||||||
//TODO: Support this later
|
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status"));
|
||||||
//List<Pair> statusPair = SwaggerUtils.parameterToPairs("csv", "status", request().getQueryString("status"));
|
|
||||||
List<String> status = new ArrayList<String>();
|
List<String> status = new ArrayList<String>();
|
||||||
//for (Pair pair : statusPair) {
|
for (String curParam : statusList) {
|
||||||
// status.add(pair.getValue());
|
//noinspection UseBulkOperation
|
||||||
//}
|
status.add(curParam);
|
||||||
|
}
|
||||||
List<Pet> obj = imp.findPetsByStatus(status);
|
List<Pet> obj = imp.findPetsByStatus(status);
|
||||||
|
for (Pet curItem : obj) {
|
||||||
|
curItem.validate();
|
||||||
|
}
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result findPetsByTags() throws Exception {
|
public Result findPetsByTags() throws Exception {
|
||||||
//TODO: Support this later
|
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags"));
|
||||||
//List<Pair> tagsPair = SwaggerUtils.parameterToPairs("csv", "tags", request().getQueryString("tags"));
|
|
||||||
List<String> tags = new ArrayList<String>();
|
List<String> tags = new ArrayList<String>();
|
||||||
//for (Pair pair : tagsPair) {
|
for (String curParam : tagsList) {
|
||||||
// tags.add(pair.getValue());
|
//noinspection UseBulkOperation
|
||||||
//}
|
tags.add(curParam);
|
||||||
|
}
|
||||||
List<Pet> obj = imp.findPetsByTags(tags);
|
List<Pet> obj = imp.findPetsByTags(tags);
|
||||||
|
for (Pet curItem : obj) {
|
||||||
|
curItem.validate();
|
||||||
|
}
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result getPetById(Long petId) throws Exception {
|
public Result getPetById(Long petId) throws Exception {
|
||||||
Pet obj = imp.getPetById(petId);
|
Pet obj = imp.getPetById(petId);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -102,49 +116,54 @@ public class PetApiController extends Controller {
|
|||||||
Pet body;
|
Pet body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
imp.updatePet(body);
|
imp.updatePet(body);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result updatePetWithForm(Long petId) throws Exception {
|
public Result updatePetWithForm(Long petId) throws Exception {
|
||||||
String valuename = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
|
String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
|
||||||
String name;
|
String name;
|
||||||
if (valuename != null) {
|
if (valuename != null) {
|
||||||
name = (String)valuename;
|
name = (String)valuename;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
name = "";
|
name = null;
|
||||||
}
|
}
|
||||||
String valuestatus = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
|
String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
|
||||||
String status;
|
String status;
|
||||||
if (valuestatus != null) {
|
if (valuestatus != null) {
|
||||||
status = (String)valuestatus;
|
status = (String)valuestatus;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
status = "";
|
status = null;
|
||||||
}
|
}
|
||||||
imp.updatePetWithForm(petId, name, status);
|
imp.updatePetWithForm(petId, name, status);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result uploadFile(Long petId) throws Exception {
|
public Result uploadFile(Long petId) throws Exception {
|
||||||
String valueadditionalMetadata = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
|
String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
|
||||||
String additionalMetadata;
|
String additionalMetadata;
|
||||||
if (valueadditionalMetadata != null) {
|
if (valueadditionalMetadata != null) {
|
||||||
additionalMetadata = (String)valueadditionalMetadata;
|
additionalMetadata = (String)valueadditionalMetadata;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
additionalMetadata = "";
|
additionalMetadata = null;
|
||||||
}
|
}
|
||||||
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
|
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
|
||||||
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
|
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,6 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PetApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPet(Pet body) throws Exception {
|
public void addPet(Pet body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -35,42 +27,18 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pet getPetById(Long petId) throws Exception {
|
public Pet getPetById(Long petId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
return new Pet();
|
return new Pet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +57,6 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", ModelApiResponse.class);
|
|
||||||
}
|
|
||||||
return new ModelApiResponse();
|
return new ModelApiResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import play.mvc.Controller;
|
|||||||
import play.mvc.Result;
|
import play.mvc.Result;
|
||||||
import play.mvc.Http;
|
import play.mvc.Http;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -22,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class StoreApiController extends Controller {
|
public class StoreApiController extends Controller {
|
||||||
|
|
||||||
private final StoreApiControllerImp imp;
|
private final StoreApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StoreApiController(StoreApiControllerImp imp) {
|
private StoreApiController(StoreApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
@@ -37,6 +38,7 @@ public class StoreApiController extends Controller {
|
|||||||
imp.deleteOrder(orderId);
|
imp.deleteOrder(orderId);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -45,14 +47,17 @@ public class StoreApiController extends Controller {
|
|||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||||
Order obj = imp.getOrderById(orderId);
|
Order obj = imp.getOrderById(orderId);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -61,10 +66,13 @@ public class StoreApiController extends Controller {
|
|||||||
Order body;
|
Order body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), Order.class);
|
body = mapper.readValue(nodebody.toString(), Order.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
Order obj = imp.placeOrder(body);
|
Order obj = imp.placeOrder(body);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private StoreApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOrder(String orderId) throws Exception {
|
public void deleteOrder(String orderId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -28,38 +20,18 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Integer> getInventory() throws Exception {
|
public Map<String, Integer> getInventory() throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Map.class);
|
|
||||||
}
|
|
||||||
return new HashMap<String, Integer>();
|
return new HashMap<String, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order placeOrder(Order body) throws Exception {
|
public Order placeOrder(Order body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import play.mvc.Controller;
|
|||||||
import play.mvc.Result;
|
import play.mvc.Result;
|
||||||
import play.mvc.Http;
|
import play.mvc.Http;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -22,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class UserApiController extends Controller {
|
public class UserApiController extends Controller {
|
||||||
|
|
||||||
private final UserApiControllerImp imp;
|
private final UserApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private UserApiController(UserApiControllerImp imp) {
|
private UserApiController(UserApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
@@ -38,10 +39,12 @@ public class UserApiController extends Controller {
|
|||||||
User body;
|
User body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), User.class);
|
body = mapper.readValue(nodebody.toString(), User.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
imp.createUser(body);
|
imp.createUser(body);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -49,11 +52,15 @@ public class UserApiController extends Controller {
|
|||||||
JsonNode nodebody = request().body().asJson();
|
JsonNode nodebody = request().body().asJson();
|
||||||
List<User> body;
|
List<User> body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<List<User>>>(){});
|
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||||
|
for (User curItem : body) {
|
||||||
|
curItem.validate();
|
||||||
|
}
|
||||||
|
|
||||||
imp.createUsersWithArrayInput(body);
|
imp.createUsersWithArrayInput(body);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -61,11 +68,15 @@ public class UserApiController extends Controller {
|
|||||||
JsonNode nodebody = request().body().asJson();
|
JsonNode nodebody = request().body().asJson();
|
||||||
List<User> body;
|
List<User> body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<List<User>>>(){});
|
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||||
|
for (User curItem : body) {
|
||||||
|
curItem.validate();
|
||||||
|
}
|
||||||
|
|
||||||
imp.createUsersWithListInput(body);
|
imp.createUsersWithListInput(body);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -73,14 +84,17 @@ public class UserApiController extends Controller {
|
|||||||
imp.deleteUser(username);
|
imp.deleteUser(username);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
public Result getUserByName(String username) throws Exception {
|
public Result getUserByName(String username) throws Exception {
|
||||||
User obj = imp.getUserByName(username);
|
User obj = imp.getUserByName(username);
|
||||||
|
obj.validate();
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -99,6 +113,7 @@ public class UserApiController extends Controller {
|
|||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -106,6 +121,7 @@ public class UserApiController extends Controller {
|
|||||||
imp.logoutUser();
|
imp.logoutUser();
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiAction
|
@ApiAction
|
||||||
@@ -114,9 +130,11 @@ public class UserApiController extends Controller {
|
|||||||
User body;
|
User body;
|
||||||
|
|
||||||
body = mapper.readValue(nodebody.toString(), User.class);
|
body = mapper.readValue(nodebody.toString(), User.class);
|
||||||
|
body.validate();
|
||||||
|
|
||||||
imp.updateUser(username, body);
|
imp.updateUser(username, body);
|
||||||
|
|
||||||
return ok();
|
return ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private UserApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createUser(User body) throws Exception {
|
public void createUser(User body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -46,28 +38,12 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public User getUserByName(String username) throws Exception {
|
public User getUserByName(String username) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
return new User();
|
return new User();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
return new String();
|
return new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SwaggerUtils {
|
public class SwaggerUtils {
|
||||||
|
|
||||||
@@ -20,56 +17,42 @@ public class SwaggerUtils {
|
|||||||
public @interface ApiAction {
|
public @interface ApiAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> parameterToPairs(String collectionFormat, String name, Object value){
|
public static List<String> parametersToList(String collectionFormat, String[] values){
|
||||||
Map<String, String> params = new HashMap<>();
|
List<String> params = new ArrayList<>();
|
||||||
|
|
||||||
// preconditions
|
if (values == null) {
|
||||||
if (name == null || name.isEmpty() || value == null) return params;
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
Collection valueCollection = null;
|
if (values.length >= 1 && collectionFormat.equals("multi")) {
|
||||||
if (value instanceof Collection) {
|
params.addAll(Arrays.asList(values));
|
||||||
valueCollection = (Collection) value;
|
|
||||||
} else {
|
} else {
|
||||||
params.put(name, parameterToString(value));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valueCollection.isEmpty()){
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the collection format
|
|
||||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv
|
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv
|
||||||
|
|
||||||
// create the params based on the collection format
|
|
||||||
if (collectionFormat.equals("multi")) {
|
|
||||||
for (Object item : valueCollection) {
|
|
||||||
params.put(name, parameterToString(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
String delimiter = ",";
|
String delimiter = ",";
|
||||||
|
|
||||||
if (collectionFormat.equals("csv")) {
|
switch(collectionFormat) {
|
||||||
|
case "csv": {
|
||||||
delimiter = ",";
|
delimiter = ",";
|
||||||
} else if (collectionFormat.equals("ssv")) {
|
break;
|
||||||
|
}
|
||||||
|
case "ssv": {
|
||||||
delimiter = " ";
|
delimiter = " ";
|
||||||
} else if (collectionFormat.equals("tsv")) {
|
break;
|
||||||
|
}
|
||||||
|
case "tsv": {
|
||||||
delimiter = "\t";
|
delimiter = "\t";
|
||||||
} else if (collectionFormat.equals("pipes")) {
|
break;
|
||||||
|
}
|
||||||
|
case "pipes": {
|
||||||
delimiter = "|";
|
delimiter = "|";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder() ;
|
params = Arrays.asList(values[0].split(delimiter));
|
||||||
for (Object item : valueCollection) {
|
|
||||||
sb.append(delimiter);
|
|
||||||
sb.append(parameterToString(item));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
params.put(name, sb.substring(1));
|
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
|||||||
|
|
||||||
scalaVersion := "2.11.7"
|
scalaVersion := "2.11.7"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||||
javaJdbc,
|
libraryDependencies += "javax.validation" % "validation-api" % "1.1.0.Final"
|
||||||
cache,
|
|
||||||
javaWs,
|
|
||||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
|
||||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ play.modules {
|
|||||||
# in the root package (the "app" directory), or you can define them
|
# in the root package (the "app" directory), or you can define them
|
||||||
# explicitly below.
|
# explicitly below.
|
||||||
# If there are any built-in modules that you want to disable, you can list them here.
|
# If there are any built-in modules that you want to disable, you can list them here.
|
||||||
#disabled += ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## IDE
|
## IDE
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ POST /v2/pet/:petId controllers.PetApiController.updateP
|
|||||||
POST /v2/pet/:petId/uploadImage controllers.PetApiController.uploadFile(petId: Long)
|
POST /v2/pet/:petId/uploadImage controllers.PetApiController.uploadFile(petId: Long)
|
||||||
|
|
||||||
#Functions for Store API
|
#Functions for Store API
|
||||||
DELETE /v2/store/order/:order_id controllers.StoreApiController.deleteOrder(orderId: String)
|
DELETE /v2/store/order/:orderId controllers.StoreApiController.deleteOrder(orderId: String)
|
||||||
GET /v2/store/inventory controllers.StoreApiController.getInventory()
|
GET /v2/store/inventory controllers.StoreApiController.getInventory()
|
||||||
GET /v2/store/order/:order_id controllers.StoreApiController.getOrderById(orderId: Long)
|
GET /v2/store/order/:orderId controllers.StoreApiController.getOrderById(orderId: Long)
|
||||||
POST /v2/store/order controllers.StoreApiController.placeOrder()
|
POST /v2/store/order controllers.StoreApiController.placeOrder()
|
||||||
|
|
||||||
#Functions for User API
|
#Functions for User API
|
||||||
|
|||||||
@@ -173,6 +173,7 @@
|
|||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
|
"deprecated" : true,
|
||||||
"x-contentType" : "application/json",
|
"x-contentType" : "application/json",
|
||||||
"x-accepts" : "application/json"
|
"x-accepts" : "application/json"
|
||||||
}
|
}
|
||||||
@@ -698,6 +699,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security" : [ {
|
||||||
|
"api_key_query" : [ ]
|
||||||
|
} ],
|
||||||
"x-contentType" : "application/json",
|
"x-contentType" : "application/json",
|
||||||
"x-accepts" : "application/json"
|
"x-accepts" : "application/json"
|
||||||
}
|
}
|
||||||
@@ -1100,6 +1104,11 @@
|
|||||||
"name" : "api_key",
|
"name" : "api_key",
|
||||||
"in" : "header"
|
"in" : "header"
|
||||||
},
|
},
|
||||||
|
"api_key_query" : {
|
||||||
|
"type" : "apiKey",
|
||||||
|
"name" : "api_key_query",
|
||||||
|
"in" : "query"
|
||||||
|
},
|
||||||
"http_basic_test" : {
|
"http_basic_test" : {
|
||||||
"type" : "basic"
|
"type" : "basic"
|
||||||
}
|
}
|
||||||
@@ -1134,6 +1143,14 @@
|
|||||||
"default" : false
|
"default" : false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"example" : {
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "Order"
|
"name" : "Order"
|
||||||
}
|
}
|
||||||
@@ -1149,6 +1166,10 @@
|
|||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"example" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "Category"
|
"name" : "Category"
|
||||||
}
|
}
|
||||||
@@ -1185,6 +1206,16 @@
|
|||||||
"description" : "User Status"
|
"description" : "User Status"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"example" : {
|
||||||
|
"firstName" : "firstName",
|
||||||
|
"lastName" : "lastName",
|
||||||
|
"password" : "password",
|
||||||
|
"userStatus" : 6,
|
||||||
|
"phone" : "phone",
|
||||||
|
"id" : 0,
|
||||||
|
"email" : "email",
|
||||||
|
"username" : "username"
|
||||||
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "User"
|
"name" : "User"
|
||||||
}
|
}
|
||||||
@@ -1200,6 +1231,10 @@
|
|||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"example" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "Tag"
|
"name" : "Tag"
|
||||||
}
|
}
|
||||||
@@ -1246,6 +1281,23 @@
|
|||||||
"enum" : [ "available", "pending", "sold" ]
|
"enum" : [ "available", "pending", "sold" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"example" : {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "Pet"
|
"name" : "Pet"
|
||||||
}
|
}
|
||||||
@@ -1263,6 +1315,11 @@
|
|||||||
"message" : {
|
"message" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"example" : {
|
||||||
|
"code" : 0,
|
||||||
|
"type" : "type",
|
||||||
|
"message" : "message"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"$special[model.name]" : {
|
"$special[model.name]" : {
|
||||||
@@ -1422,7 +1479,8 @@
|
|||||||
},
|
},
|
||||||
"byte" : {
|
"byte" : {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
"format" : "byte"
|
"format" : "byte",
|
||||||
|
"pattern" : "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
|
||||||
},
|
},
|
||||||
"binary" : {
|
"binary" : {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
@@ -1528,6 +1586,9 @@
|
|||||||
"client" : {
|
"client" : {
|
||||||
"type" : "string"
|
"type" : "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"example" : {
|
||||||
|
"client" : "client"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ReadOnlyFirst" : {
|
"ReadOnlyFirst" : {
|
||||||
@@ -1704,6 +1765,11 @@
|
|||||||
"my_boolean" : {
|
"my_boolean" : {
|
||||||
"$ref" : "#/definitions/OuterBoolean"
|
"$ref" : "#/definitions/OuterBoolean"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"example" : {
|
||||||
|
"my_string" : { },
|
||||||
|
"my_number" : { },
|
||||||
|
"my_boolean" : { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
import controllers.*;
|
||||||
|
|
||||||
|
public class Module extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class);
|
||||||
|
bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class);
|
||||||
|
bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,7 +153,7 @@ public class Order {
|
|||||||
* Get complete
|
* Get complete
|
||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
public Boolean getComplete() {
|
public Boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class PetApiController extends Controller {
|
public class PetApiController extends Controller {
|
||||||
|
|
||||||
private final PetApiControllerImp imp;
|
private final PetApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PetApiController(PetApiControllerImp imp) {
|
private PetApiController(PetApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,6 @@ import java.util.HashMap;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PetApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPet(Pet body) throws Exception {
|
public void addPet(Pet body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -34,42 +26,18 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public List<Pet> findPetsByStatus(List<String> status) throws Exception {
|
public List<Pet> findPetsByStatus(List<String> status) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Pet> findPetsByTags(List<String> tags) throws Exception {
|
public List<Pet> findPetsByTags(List<String> tags) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pet getPetById(Long petId) throws Exception {
|
public Pet getPetById(Long petId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
return new Pet();
|
return new Pet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +56,6 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", ModelApiResponse.class);
|
|
||||||
}
|
|
||||||
return new ModelApiResponse();
|
return new ModelApiResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class StoreApiController extends Controller {
|
public class StoreApiController extends Controller {
|
||||||
|
|
||||||
private final StoreApiControllerImp imp;
|
private final StoreApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StoreApiController(StoreApiControllerImp imp) {
|
private StoreApiController(StoreApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,6 @@ import java.util.HashMap;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private StoreApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOrder(String orderId) throws Exception {
|
public void deleteOrder(String orderId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -27,38 +19,18 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Integer> getInventory() throws Exception {
|
public Map<String, Integer> getInventory() throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Map.class);
|
|
||||||
}
|
|
||||||
return new HashMap<String, Integer>();
|
return new HashMap<String, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order getOrderById(Long orderId) throws Exception {
|
public Order getOrderById(Long orderId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order placeOrder(Order body) throws Exception {
|
public Order placeOrder(Order body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class UserApiController extends Controller {
|
public class UserApiController extends Controller {
|
||||||
|
|
||||||
private final UserApiControllerImp imp;
|
private final UserApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private UserApiController(UserApiControllerImp imp) {
|
private UserApiController(UserApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,6 @@ import java.util.HashMap;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private UserApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createUser(User body) throws Exception {
|
public void createUser(User body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -45,28 +37,12 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public User getUserByName(String username) throws Exception {
|
public User getUserByName(String username) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
return new User();
|
return new User();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String loginUser(String username, String password) throws Exception {
|
public String loginUser(String username, String password) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
return new String();
|
return new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,4 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
|||||||
|
|
||||||
scalaVersion := "2.11.7"
|
scalaVersion := "2.11.7"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||||
javaJdbc,
|
|
||||||
cache,
|
|
||||||
javaWs,
|
|
||||||
"org.webjars" % "swagger-ui" % "2.2.10-1")
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ play.modules {
|
|||||||
# in the root package (the "app" directory), or you can define them
|
# in the root package (the "app" directory), or you can define them
|
||||||
# explicitly below.
|
# explicitly below.
|
||||||
# If there are any built-in modules that you want to disable, you can list them here.
|
# If there are any built-in modules that you want to disable, you can list them here.
|
||||||
#disabled += ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## IDE
|
## IDE
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
2017-08-08 12:59:36,779 [INFO] from play.api.Play in ForkJoinPool-1-worker-1 - Application started (Dev)
|
||||||
@@ -173,6 +173,7 @@
|
|||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
|
"deprecated" : true,
|
||||||
"x-contentType" : "application/json",
|
"x-contentType" : "application/json",
|
||||||
"x-accepts" : "application/json"
|
"x-accepts" : "application/json"
|
||||||
}
|
}
|
||||||
@@ -749,7 +750,7 @@
|
|||||||
"title" : "Pet catehgry",
|
"title" : "Pet catehgry",
|
||||||
"description" : "A category for a pet",
|
"description" : "A category for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -790,14 +791,14 @@
|
|||||||
"title" : "a User",
|
"title" : "a User",
|
||||||
"description" : "A User who is purchasing from the pet store",
|
"description" : "A User who is purchasing from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"firstName" : "aeiou",
|
"firstName" : "firstName",
|
||||||
"lastName" : "aeiou",
|
"lastName" : "lastName",
|
||||||
"password" : "aeiou",
|
"password" : "password",
|
||||||
"userStatus" : 6,
|
"userStatus" : 6,
|
||||||
"phone" : "aeiou",
|
"phone" : "phone",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"email" : "aeiou",
|
"email" : "email",
|
||||||
"username" : "aeiou"
|
"username" : "username"
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "User"
|
"name" : "User"
|
||||||
@@ -817,7 +818,7 @@
|
|||||||
"title" : "Pet Tag",
|
"title" : "Pet Tag",
|
||||||
"description" : "A tag for a pet",
|
"description" : "A tag for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -868,15 +869,18 @@
|
|||||||
"title" : "a Pet",
|
"title" : "a Pet",
|
||||||
"description" : "A pet for sale in the pet store",
|
"description" : "A pet for sale in the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
"name" : "doggie",
|
"name" : "doggie",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
} ],
|
} ],
|
||||||
"status" : "available"
|
"status" : "available"
|
||||||
@@ -903,8 +907,8 @@
|
|||||||
"description" : "Describes the result of uploading an image resource",
|
"description" : "Describes the result of uploading an image resource",
|
||||||
"example" : {
|
"example" : {
|
||||||
"code" : 0,
|
"code" : 0,
|
||||||
"type" : "aeiou",
|
"type" : "type",
|
||||||
"message" : "aeiou"
|
"message" : "message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
import controllers.*;
|
||||||
|
|
||||||
|
public class Module extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class);
|
||||||
|
bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class);
|
||||||
|
bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -157,7 +157,7 @@ public class Order {
|
|||||||
* Get complete
|
* Get complete
|
||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
public Boolean getComplete() {
|
public Boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class PetApiController extends Controller {
|
public class PetApiController extends Controller {
|
||||||
|
|
||||||
private final PetApiControllerImp imp;
|
private final PetApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PetApiController(PetApiControllerImp imp) {
|
private PetApiController(PetApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,6 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PetApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPet(Pet body) {
|
public void addPet(Pet body) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -35,42 +27,18 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) {
|
public List<Pet> findPetsByStatus( @NotNull List<String> status) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) {
|
public List<Pet> findPetsByTags( @NotNull List<String> tags) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pet getPetById(Long petId) {
|
public Pet getPetById(Long petId) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
return new Pet();
|
return new Pet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +57,6 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) {
|
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", ModelApiResponse.class);
|
|
||||||
}
|
|
||||||
return new ModelApiResponse();
|
return new ModelApiResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class StoreApiController extends Controller {
|
public class StoreApiController extends Controller {
|
||||||
|
|
||||||
private final StoreApiControllerImp imp;
|
private final StoreApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StoreApiController(StoreApiControllerImp imp) {
|
private StoreApiController(StoreApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private StoreApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOrder(String orderId) {
|
public void deleteOrder(String orderId) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -28,38 +20,18 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Integer> getInventory() {
|
public Map<String, Integer> getInventory() {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Map.class);
|
|
||||||
}
|
|
||||||
return new HashMap<String, Integer>();
|
return new HashMap<String, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) {
|
public Order getOrderById( @Min(1) @Max(5)Long orderId) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order placeOrder(Order body) {
|
public Order placeOrder(Order body) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
|||||||
|
|
||||||
public class UserApiController extends Controller {
|
public class UserApiController extends Controller {
|
||||||
|
|
||||||
private final UserApiControllerImp imp;
|
private final UserApiControllerImpInterface imp;
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private UserApiController(UserApiControllerImp imp) {
|
private UserApiController(UserApiControllerImpInterface imp) {
|
||||||
this.imp = imp;
|
this.imp = imp;
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private UserApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createUser(User body) {
|
public void createUser(User body) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
@@ -46,28 +38,12 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
|||||||
@Override
|
@Override
|
||||||
public User getUserByName(String username) {
|
public User getUserByName(String username) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
return new User();
|
return new User();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String loginUser( @NotNull String username, @NotNull String password) {
|
public String loginUser( @NotNull String username, @NotNull String password) {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
return new String();
|
return new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
|||||||
|
|
||||||
scalaVersion := "2.11.7"
|
scalaVersion := "2.11.7"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||||
javaJdbc,
|
libraryDependencies += "javax.validation" % "validation-api" % "1.1.0.Final"
|
||||||
cache,
|
|
||||||
javaWs,
|
|
||||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
|
||||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ play.modules {
|
|||||||
# in the root package (the "app" directory), or you can define them
|
# in the root package (the "app" directory), or you can define them
|
||||||
# explicitly below.
|
# explicitly below.
|
||||||
# If there are any built-in modules that you want to disable, you can list them here.
|
# If there are any built-in modules that you want to disable, you can list them here.
|
||||||
#disabled += ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## IDE
|
## IDE
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
2017-08-08 13:00:03,356 [INFO] from play.api.Play in ForkJoinPool-1-worker-1 - Application started (Dev)
|
||||||
@@ -173,6 +173,7 @@
|
|||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
|
"deprecated" : true,
|
||||||
"x-contentType" : "application/json",
|
"x-contentType" : "application/json",
|
||||||
"x-accepts" : "application/json"
|
"x-accepts" : "application/json"
|
||||||
}
|
}
|
||||||
@@ -749,7 +750,7 @@
|
|||||||
"title" : "Pet catehgry",
|
"title" : "Pet catehgry",
|
||||||
"description" : "A category for a pet",
|
"description" : "A category for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -790,14 +791,14 @@
|
|||||||
"title" : "a User",
|
"title" : "a User",
|
||||||
"description" : "A User who is purchasing from the pet store",
|
"description" : "A User who is purchasing from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"firstName" : "aeiou",
|
"firstName" : "firstName",
|
||||||
"lastName" : "aeiou",
|
"lastName" : "lastName",
|
||||||
"password" : "aeiou",
|
"password" : "password",
|
||||||
"userStatus" : 6,
|
"userStatus" : 6,
|
||||||
"phone" : "aeiou",
|
"phone" : "phone",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"email" : "aeiou",
|
"email" : "email",
|
||||||
"username" : "aeiou"
|
"username" : "username"
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "User"
|
"name" : "User"
|
||||||
@@ -817,7 +818,7 @@
|
|||||||
"title" : "Pet Tag",
|
"title" : "Pet Tag",
|
||||||
"description" : "A tag for a pet",
|
"description" : "A tag for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -868,15 +869,18 @@
|
|||||||
"title" : "a Pet",
|
"title" : "a Pet",
|
||||||
"description" : "A pet for sale in the pet store",
|
"description" : "A pet for sale in the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
"name" : "doggie",
|
"name" : "doggie",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
} ],
|
} ],
|
||||||
"status" : "available"
|
"status" : "available"
|
||||||
@@ -903,8 +907,8 @@
|
|||||||
"description" : "Describes the result of uploading an image resource",
|
"description" : "Describes the result of uploading an image resource",
|
||||||
"example" : {
|
"example" : {
|
||||||
"code" : 0,
|
"code" : 0,
|
||||||
"type" : "aeiou",
|
"type" : "type",
|
||||||
"message" : "aeiou"
|
"message" : "message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class Order {
|
|||||||
* Get complete
|
* Get complete
|
||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
public Boolean getComplete() {
|
public Boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,88 +11,52 @@ import java.util.HashMap;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
public class PetApiControllerImp {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PetApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPet(Pet body) throws Exception {
|
public void addPet(Pet body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deletePet(Long petId, String apiKey) throws Exception {
|
public void deletePet(Long petId, String apiKey) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", List.class);
|
|
||||||
}
|
|
||||||
return new ArrayList<Pet>();
|
return new ArrayList<Pet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Pet getPetById(Long petId) throws Exception {
|
public Pet getPetById(Long petId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Pet.class);
|
|
||||||
}
|
|
||||||
return new Pet();
|
return new Pet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updatePet(Pet body) throws Exception {
|
public void updatePet(Pet body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updatePetWithForm(Long petId, String name, String status) throws Exception {
|
public void updatePetWithForm(Long petId, String name, String status) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", ModelApiResponse.class);
|
|
||||||
}
|
|
||||||
return new ModelApiResponse();
|
return new ModelApiResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
package controllers;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import apimodels.ModelApiResponse;
|
|
||||||
import apimodels.Pet;
|
|
||||||
|
|
||||||
import play.mvc.Http;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
public interface PetApiControllerImpInterface {
|
|
||||||
void addPet(Pet body) throws Exception;
|
|
||||||
|
|
||||||
void deletePet(Long petId, String apiKey) throws Exception;
|
|
||||||
|
|
||||||
List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception;
|
|
||||||
|
|
||||||
List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception;
|
|
||||||
|
|
||||||
Pet getPetById(Long petId) throws Exception;
|
|
||||||
|
|
||||||
void updatePet(Pet body) throws Exception;
|
|
||||||
|
|
||||||
void updatePetWithForm(Long petId, String name, String status) throws Exception;
|
|
||||||
|
|
||||||
ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -10,56 +10,28 @@ import java.util.HashMap;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
public class StoreApiControllerImp {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private StoreApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteOrder(String orderId) throws Exception {
|
public void deleteOrder(String orderId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Integer> getInventory() throws Exception {
|
public Map<String, Integer> getInventory() throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Map.class);
|
|
||||||
}
|
|
||||||
return new HashMap<String, Integer>();
|
return new HashMap<String, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Order placeOrder(Order body) throws Exception {
|
public Order placeOrder(Order body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", Order.class);
|
|
||||||
}
|
|
||||||
return new Order();
|
return new Order();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package controllers;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import apimodels.Order;
|
|
||||||
|
|
||||||
import play.mvc.Http;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
public interface StoreApiControllerImpInterface {
|
|
||||||
void deleteOrder(String orderId) throws Exception;
|
|
||||||
|
|
||||||
Map<String, Integer> getInventory() throws Exception;
|
|
||||||
|
|
||||||
Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception;
|
|
||||||
|
|
||||||
Order placeOrder(Order body) throws Exception;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -10,74 +10,50 @@ import java.util.HashMap;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
public class UserApiControllerImp {
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private UserApiControllerImp() {
|
|
||||||
mapper = new ObjectMapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createUser(User body) throws Exception {
|
public void createUser(User body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createUsersWithArrayInput(List<User> body) throws Exception {
|
public void createUsersWithArrayInput(List<User> body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createUsersWithListInput(List<User> body) throws Exception {
|
public void createUsersWithListInput(List<User> body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteUser(String username) throws Exception {
|
public void deleteUser(String username) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public User getUserByName(String username) throws Exception {
|
public User getUserByName(String username) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", User.class);
|
|
||||||
}
|
|
||||||
return new User();
|
return new User();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/xml")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
String accept = request().getHeader("Accept");
|
|
||||||
if (accept != null && accept.contains("application/json")) {
|
|
||||||
return mapper.readValue("", String.class);
|
|
||||||
}
|
|
||||||
return new String();
|
return new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logoutUser() throws Exception {
|
public void logoutUser() throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateUser(String username, User body) throws Exception {
|
public void updateUser(String username, User body) throws Exception {
|
||||||
//Do your magic!!!
|
//Do your magic!!!
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package controllers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import apimodels.User;
|
|
||||||
|
|
||||||
import play.mvc.Http;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
public interface UserApiControllerImpInterface {
|
|
||||||
void createUser(User body) throws Exception;
|
|
||||||
|
|
||||||
void createUsersWithArrayInput(List<User> body) throws Exception;
|
|
||||||
|
|
||||||
void createUsersWithListInput(List<User> body) throws Exception;
|
|
||||||
|
|
||||||
void deleteUser(String username) throws Exception;
|
|
||||||
|
|
||||||
User getUserByName(String username) throws Exception;
|
|
||||||
|
|
||||||
String loginUser( @NotNull String username, @NotNull String password) throws Exception;
|
|
||||||
|
|
||||||
void logoutUser() throws Exception;
|
|
||||||
|
|
||||||
void updateUser(String username, User body) throws Exception;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
|||||||
|
|
||||||
scalaVersion := "2.11.7"
|
scalaVersion := "2.11.7"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||||
javaJdbc,
|
libraryDependencies += "javax.validation" % "validation-api" % "1.1.0.Final"
|
||||||
cache,
|
|
||||||
javaWs,
|
|
||||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
|
||||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ play.modules {
|
|||||||
# in the root package (the "app" directory), or you can define them
|
# in the root package (the "app" directory), or you can define them
|
||||||
# explicitly below.
|
# explicitly below.
|
||||||
# If there are any built-in modules that you want to disable, you can list them here.
|
# If there are any built-in modules that you want to disable, you can list them here.
|
||||||
#disabled += ""
|
disabled += "Module"
|
||||||
}
|
}
|
||||||
|
|
||||||
## IDE
|
## IDE
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
2017-08-08 13:00:28,358 [INFO] from play.api.Play in ForkJoinPool-1-worker-1 - Application started (Dev)
|
||||||
@@ -173,6 +173,7 @@
|
|||||||
"security" : [ {
|
"security" : [ {
|
||||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||||
} ],
|
} ],
|
||||||
|
"deprecated" : true,
|
||||||
"x-contentType" : "application/json",
|
"x-contentType" : "application/json",
|
||||||
"x-accepts" : "application/json"
|
"x-accepts" : "application/json"
|
||||||
}
|
}
|
||||||
@@ -749,7 +750,7 @@
|
|||||||
"title" : "Pet catehgry",
|
"title" : "Pet catehgry",
|
||||||
"description" : "A category for a pet",
|
"description" : "A category for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -790,14 +791,14 @@
|
|||||||
"title" : "a User",
|
"title" : "a User",
|
||||||
"description" : "A User who is purchasing from the pet store",
|
"description" : "A User who is purchasing from the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"firstName" : "aeiou",
|
"firstName" : "firstName",
|
||||||
"lastName" : "aeiou",
|
"lastName" : "lastName",
|
||||||
"password" : "aeiou",
|
"password" : "password",
|
||||||
"userStatus" : 6,
|
"userStatus" : 6,
|
||||||
"phone" : "aeiou",
|
"phone" : "phone",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"email" : "aeiou",
|
"email" : "email",
|
||||||
"username" : "aeiou"
|
"username" : "username"
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
"name" : "User"
|
"name" : "User"
|
||||||
@@ -817,7 +818,7 @@
|
|||||||
"title" : "Pet Tag",
|
"title" : "Pet Tag",
|
||||||
"description" : "A tag for a pet",
|
"description" : "A tag for a pet",
|
||||||
"example" : {
|
"example" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
},
|
},
|
||||||
"xml" : {
|
"xml" : {
|
||||||
@@ -868,15 +869,18 @@
|
|||||||
"title" : "a Pet",
|
"title" : "a Pet",
|
||||||
"description" : "A pet for sale in the pet store",
|
"description" : "A pet for sale in the pet store",
|
||||||
"example" : {
|
"example" : {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
"name" : "doggie",
|
"name" : "doggie",
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
"id" : 6
|
"id" : 6
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
"name" : "aeiou",
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
"id" : 1
|
"id" : 1
|
||||||
} ],
|
} ],
|
||||||
"status" : "available"
|
"status" : "available"
|
||||||
@@ -903,8 +907,8 @@
|
|||||||
"description" : "Describes the result of uploading an image resource",
|
"description" : "Describes the result of uploading an image resource",
|
||||||
"example" : {
|
"example" : {
|
||||||
"code" : 0,
|
"code" : 0,
|
||||||
"type" : "aeiou",
|
"type" : "type",
|
||||||
"message" : "aeiou"
|
"message" : "message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
import controllers.*;
|
||||||
|
|
||||||
|
public class Module extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class);
|
||||||
|
bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class);
|
||||||
|
bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -157,7 +157,7 @@ public class Order {
|
|||||||
* Get complete
|
* Get complete
|
||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
public Boolean getComplete() {
|
public Boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user