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-swagger-ui.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.
|
||||
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
|
||||
|
||||
@@ -153,6 +153,9 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
||||
supportingFiles.add(new SupportingFile("routes.mustache", "conf", "routes"));
|
||||
|
||||
//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"));
|
||||
if (this.handleExceptions) {
|
||||
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
|
||||
# explicitly below.
|
||||
# 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
|
||||
|
||||
@@ -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}}
|
||||
{{#operations}}
|
||||
public class {{classname}}ControllerImp {{#useInterfaces}}implements {{classname}}ControllerImpInterface{{/useInterfaces}} {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private {{classname}}ControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
{{#useInterfaces}}@Override{{/useInterfaces}}
|
||||
public {{>returnTypes}} {{operationId}}({{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} {
|
||||
//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}}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,16 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
{{#operations}}
|
||||
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;
|
||||
|
||||
@Inject
|
||||
private {{classname}}Controller({{^controllerOnly}}{{classname}}ControllerImp imp{{/controllerOnly}}) {
|
||||
{{^controllerOnly}}this.imp = imp;{{/controllerOnly}}
|
||||
private {{classname}}Controller({{^controllerOnly}}{{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp{{/controllerOnly}}) {
|
||||
{{^controllerOnly}}
|
||||
this.imp = imp;
|
||||
{{/controllerOnly}}
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public class Order {
|
||||
* Get complete
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
public Boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,10 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class PetApiController extends Controller {
|
||||
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiController() {
|
||||
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class StoreApiController extends Controller {
|
||||
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiController() {
|
||||
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class UserApiController extends Controller {
|
||||
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiController() {
|
||||
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
||||
|
||||
scalaVersion := "2.11.7"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
javaJdbc,
|
||||
cache,
|
||||
javaWs,
|
||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
||||
)
|
||||
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||
libraryDependencies += "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
|
||||
# explicitly below.
|
||||
# If there are any built-in modules that you want to disable, you can list them here.
|
||||
#disabled += ""
|
||||
disabled += "Module"
|
||||
}
|
||||
|
||||
## 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" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"deprecated" : true,
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
@@ -749,7 +750,7 @@
|
||||
"title" : "Pet catehgry",
|
||||
"description" : "A category for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
@@ -790,14 +791,14 @@
|
||||
"title" : "a User",
|
||||
"description" : "A User who is purchasing from the pet store",
|
||||
"example" : {
|
||||
"firstName" : "aeiou",
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "aeiou",
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
@@ -817,7 +818,7 @@
|
||||
"title" : "Pet Tag",
|
||||
"description" : "A tag for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
@@ -868,15 +869,18 @@
|
||||
"title" : "a Pet",
|
||||
"description" : "A pet for sale in the pet store",
|
||||
"example" : {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
@@ -903,8 +907,8 @@
|
||||
"description" : "Describes the result of uploading an image resource",
|
||||
"example" : {
|
||||
"code" : 0,
|
||||
"type" : "aeiou",
|
||||
"message" : "aeiou"
|
||||
"type" : "type",
|
||||
"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.List;
|
||||
import java.util.Map;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* AdditionalPropertiesClass
|
||||
*/
|
||||
@@ -59,6 +61,7 @@ public class AdditionalPropertiesClass {
|
||||
* Get mapOfMapProperty
|
||||
* @return mapOfMapProperty
|
||||
**/
|
||||
@Valid
|
||||
public Map<String, Map<String, String>> getMapOfMapProperty() {
|
||||
return mapOfMapProperty;
|
||||
}
|
||||
@@ -107,5 +110,21 @@ public class AdditionalPropertiesClass {
|
||||
}
|
||||
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 com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Animal
|
||||
*/
|
||||
@@ -91,5 +93,21 @@ public class Animal {
|
||||
}
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* AnimalFarm
|
||||
*/
|
||||
@@ -47,5 +49,21 @@ public class AnimalFarm extends ArrayList<Animal> {
|
||||
}
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
@@ -31,6 +33,7 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
* Get arrayArrayNumber
|
||||
* @return arrayArrayNumber
|
||||
**/
|
||||
@Valid
|
||||
public List<List<BigDecimal>> getArrayArrayNumber() {
|
||||
return arrayArrayNumber;
|
||||
}
|
||||
@@ -77,5 +80,21 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
}
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
*/
|
||||
@@ -31,6 +33,7 @@ public class ArrayOfNumberOnly {
|
||||
* Get arrayNumber
|
||||
* @return arrayNumber
|
||||
**/
|
||||
@Valid
|
||||
public List<BigDecimal> getArrayNumber() {
|
||||
return arrayNumber;
|
||||
}
|
||||
@@ -77,5 +80,21 @@ public class ArrayOfNumberOnly {
|
||||
}
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayTest
|
||||
*/
|
||||
@@ -62,6 +64,7 @@ public class ArrayTest {
|
||||
* Get arrayArrayOfInteger
|
||||
* @return arrayArrayOfInteger
|
||||
**/
|
||||
@Valid
|
||||
public List<List<Long>> getArrayArrayOfInteger() {
|
||||
return arrayArrayOfInteger;
|
||||
}
|
||||
@@ -87,6 +90,7 @@ public class ArrayTest {
|
||||
* Get arrayArrayOfModel
|
||||
* @return arrayArrayOfModel
|
||||
**/
|
||||
@Valid
|
||||
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
|
||||
return arrayArrayOfModel;
|
||||
}
|
||||
@@ -137,5 +141,21 @@ public class ArrayTest {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Capitalization
|
||||
*/
|
||||
@@ -176,5 +178,21 @@ public class Capitalization {
|
||||
}
|
||||
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 apimodels.Animal;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Cat
|
||||
*/
|
||||
@@ -21,7 +23,7 @@ public class Cat extends Animal {
|
||||
* Get declawed
|
||||
* @return declawed
|
||||
**/
|
||||
public Boolean getDeclawed() {
|
||||
public Boolean isDeclawed() {
|
||||
return declawed;
|
||||
}
|
||||
|
||||
@@ -68,5 +70,21 @@ public class Cat extends Animal {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
@@ -88,5 +90,21 @@ public class Category {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model with \"_class\" property
|
||||
*/
|
||||
@@ -66,5 +68,21 @@ public class ClassModel {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Client
|
||||
*/
|
||||
@@ -66,5 +68,21 @@ public class Client {
|
||||
}
|
||||
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 apimodels.Animal;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Dog
|
||||
*/
|
||||
@@ -68,5 +70,21 @@ public class Dog extends Animal {
|
||||
}
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* EnumArrays
|
||||
*/
|
||||
@@ -160,5 +162,21 @@ public class EnumArrays {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,10 @@ package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import apimodels.OuterEnum;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* EnumTest
|
||||
*/
|
||||
@@ -176,6 +178,7 @@ public class EnumTest {
|
||||
* Get outerEnum
|
||||
* @return outerEnum
|
||||
**/
|
||||
@Valid
|
||||
public OuterEnum getOuterEnum() {
|
||||
return outerEnum;
|
||||
}
|
||||
@@ -228,5 +231,21 @@ public class EnumTest {
|
||||
}
|
||||
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.OffsetDateTime;
|
||||
import java.util.UUID;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* FormatTest
|
||||
*/
|
||||
@@ -63,7 +65,7 @@ public class FormatTest {
|
||||
* @return integer
|
||||
**/
|
||||
@Min(10)
|
||||
@Max(100)
|
||||
@Max(100)
|
||||
public Integer getInteger() {
|
||||
return integer;
|
||||
}
|
||||
@@ -84,7 +86,7 @@ public class FormatTest {
|
||||
* @return int32
|
||||
**/
|
||||
@Min(20)
|
||||
@Max(200)
|
||||
@Max(200)
|
||||
public Integer getInt32() {
|
||||
return int32;
|
||||
}
|
||||
@@ -122,8 +124,9 @@ public class FormatTest {
|
||||
* @return number
|
||||
**/
|
||||
@NotNull
|
||||
@DecimalMin("32.1")
|
||||
@DecimalMax("543.2")
|
||||
@DecimalMin("32.1")
|
||||
@DecimalMax("543.2")
|
||||
@Valid
|
||||
public BigDecimal getNumber() {
|
||||
return number;
|
||||
}
|
||||
@@ -144,7 +147,7 @@ public class FormatTest {
|
||||
* @return _float
|
||||
**/
|
||||
@DecimalMin("54.3")
|
||||
@DecimalMax("987.6")
|
||||
@DecimalMax("987.6")
|
||||
public Float getFloat() {
|
||||
return _float;
|
||||
}
|
||||
@@ -165,7 +168,7 @@ public class FormatTest {
|
||||
* @return _double
|
||||
**/
|
||||
@DecimalMin("67.8")
|
||||
@DecimalMax("123.4")
|
||||
@DecimalMax("123.4")
|
||||
public Double getDouble() {
|
||||
return _double;
|
||||
}
|
||||
@@ -202,6 +205,7 @@ public class FormatTest {
|
||||
* @return _byte
|
||||
**/
|
||||
@NotNull
|
||||
@Pattern(regexp="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$")
|
||||
public byte[] getByte() {
|
||||
return _byte;
|
||||
}
|
||||
@@ -237,6 +241,7 @@ public class FormatTest {
|
||||
* @return date
|
||||
**/
|
||||
@NotNull
|
||||
@Valid
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
@@ -254,6 +259,7 @@ public class FormatTest {
|
||||
* Get dateTime
|
||||
* @return dateTime
|
||||
**/
|
||||
@Valid
|
||||
public OffsetDateTime getDateTime() {
|
||||
return dateTime;
|
||||
}
|
||||
@@ -271,6 +277,7 @@ public class FormatTest {
|
||||
* Get uuid
|
||||
* @return uuid
|
||||
**/
|
||||
@Valid
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
@@ -289,7 +296,7 @@ public class FormatTest {
|
||||
* @return password
|
||||
**/
|
||||
@NotNull
|
||||
@Size(min=10,max=64)
|
||||
@Size(min=10,max=64)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
@@ -360,5 +367,21 @@ public class FormatTest {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* HasOnlyReadOnly
|
||||
*/
|
||||
@@ -88,5 +90,21 @@ public class HasOnlyReadOnly {
|
||||
}
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* MapTest
|
||||
*/
|
||||
@@ -65,6 +67,7 @@ public class MapTest {
|
||||
* Get mapMapOfString
|
||||
* @return mapMapOfString
|
||||
**/
|
||||
@Valid
|
||||
public Map<String, Map<String, String>> getMapMapOfString() {
|
||||
return mapMapOfString;
|
||||
}
|
||||
@@ -138,5 +141,21 @@ public class MapTest {
|
||||
}
|
||||
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.Map;
|
||||
import java.util.UUID;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
@@ -32,6 +34,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
* Get uuid
|
||||
* @return uuid
|
||||
**/
|
||||
@Valid
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
@@ -49,6 +52,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
* Get dateTime
|
||||
* @return dateTime
|
||||
**/
|
||||
@Valid
|
||||
public OffsetDateTime getDateTime() {
|
||||
return dateTime;
|
||||
}
|
||||
@@ -74,6 +78,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
* Get map
|
||||
* @return map
|
||||
**/
|
||||
@Valid
|
||||
public Map<String, Animal> getMap() {
|
||||
return map;
|
||||
}
|
||||
@@ -124,5 +129,21 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
*/
|
||||
@@ -88,5 +90,21 @@ public class Model200Response {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ModelApiResponse
|
||||
*/
|
||||
@@ -110,5 +112,21 @@ public class ModelApiResponse {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
*/
|
||||
@@ -66,5 +68,21 @@ public class ModelReturn {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
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
|
||||
*/
|
||||
@@ -133,5 +135,21 @@ public class Name {
|
||||
}
|
||||
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.math.BigDecimal;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* NumberOnly
|
||||
*/
|
||||
@@ -21,6 +23,7 @@ public class NumberOnly {
|
||||
* Get justNumber
|
||||
* @return justNumber
|
||||
**/
|
||||
@Valid
|
||||
public BigDecimal getJustNumber() {
|
||||
return justNumber;
|
||||
}
|
||||
@@ -67,5 +70,21 @@ public class NumberOnly {
|
||||
}
|
||||
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.time.OffsetDateTime;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Order
|
||||
*/
|
||||
@@ -120,6 +122,7 @@ public class Order {
|
||||
* Get shipDate
|
||||
* @return shipDate
|
||||
**/
|
||||
@Valid
|
||||
public OffsetDateTime getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
@@ -154,7 +157,7 @@ public class Order {
|
||||
* Get complete
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
public Boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
@@ -210,5 +213,21 @@ public class Order {
|
||||
}
|
||||
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.math.BigDecimal;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* OuterComposite
|
||||
*/
|
||||
@@ -27,6 +29,7 @@ public class OuterComposite {
|
||||
* Get myNumber
|
||||
* @return myNumber
|
||||
**/
|
||||
@Valid
|
||||
public BigDecimal getMyNumber() {
|
||||
return myNumber;
|
||||
}
|
||||
@@ -111,5 +114,21 @@ public class OuterComposite {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,10 @@ import apimodels.Category;
|
||||
import apimodels.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Pet
|
||||
*/
|
||||
@@ -89,6 +91,7 @@ public class Pet {
|
||||
* Get category
|
||||
* @return category
|
||||
**/
|
||||
@Valid
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
@@ -155,6 +158,7 @@ public class Pet {
|
||||
* Get tags
|
||||
* @return tags
|
||||
**/
|
||||
@Valid
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
@@ -228,5 +232,21 @@ public class Pet {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ReadOnlyFirst
|
||||
*/
|
||||
@@ -88,5 +90,21 @@ public class ReadOnlyFirst {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* SpecialModelName
|
||||
*/
|
||||
@@ -66,5 +68,21 @@ public class SpecialModelName {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Tag
|
||||
*/
|
||||
@@ -88,5 +90,21 @@ public class Tag {
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
@@ -220,5 +222,21 @@ public class User {
|
||||
}
|
||||
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.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -25,11 +26,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class FakeApiController extends Controller {
|
||||
|
||||
private final FakeApiControllerImp imp;
|
||||
private final FakeApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private FakeApiController(FakeApiControllerImp imp) {
|
||||
private FakeApiController(FakeApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
@@ -42,6 +43,7 @@ public class FakeApiController extends Controller {
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Boolean.class);
|
||||
|
||||
body.validate();
|
||||
} else {
|
||||
body = null;
|
||||
}
|
||||
@@ -49,6 +51,7 @@ public class FakeApiController extends Controller {
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -58,13 +61,16 @@ public class FakeApiController extends Controller {
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), OuterComposite.class);
|
||||
|
||||
body.validate();
|
||||
} else {
|
||||
body = null;
|
||||
}
|
||||
OuterComposite obj = imp.fakeOuterCompositeSerialize(body);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -74,13 +80,16 @@ public class FakeApiController extends Controller {
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), BigDecimal.class);
|
||||
|
||||
body.validate();
|
||||
} else {
|
||||
body = null;
|
||||
}
|
||||
BigDecimal obj = imp.fakeOuterNumberSerialize(body);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -90,6 +99,7 @@ public class FakeApiController extends Controller {
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), String.class);
|
||||
|
||||
body.validate();
|
||||
} else {
|
||||
body = null;
|
||||
}
|
||||
@@ -97,6 +107,7 @@ public class FakeApiController extends Controller {
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -105,135 +116,139 @@ public class FakeApiController extends Controller {
|
||||
Client body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), Client.class);
|
||||
body.validate();
|
||||
|
||||
Client obj = imp.testClientModel(body);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
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;
|
||||
if (valueinteger != null) {
|
||||
integer = Integer.parseInt(valueinteger);
|
||||
|
||||
} 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;
|
||||
if (valueint32 != null) {
|
||||
int32 = Integer.parseInt(valueint32);
|
||||
|
||||
} 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;
|
||||
if (valueint64 != null) {
|
||||
int64 = Long.parseLong(valueint64);
|
||||
|
||||
} 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;
|
||||
|
||||
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;
|
||||
if (value_float != null) {
|
||||
_float = Float.parseFloat(value_float);
|
||||
|
||||
} 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.parseDouble(value_double);
|
||||
|
||||
String valuestring = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("string"))[0];
|
||||
String valuestring = (request().body().asMultipartFormData().asFormUrlEncoded().get("string"))[0];
|
||||
String string;
|
||||
if (valuestring != null) {
|
||||
string = (String)valuestring;
|
||||
|
||||
} 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;
|
||||
|
||||
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 = 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;
|
||||
if (valuebinary != null) {
|
||||
binary = valuebinary;
|
||||
|
||||
} 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;
|
||||
if (valuedate != null) {
|
||||
date = valuedate;
|
||||
|
||||
} 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;
|
||||
if (valuedateTime != null) {
|
||||
dateTime = valuedateTime;
|
||||
dateTime = OffsetDateTime.parse(valuedateTime);
|
||||
|
||||
} 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;
|
||||
if (valuepassword != null) {
|
||||
password = (String)valuepassword;
|
||||
|
||||
} 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;
|
||||
if (valueparamCallback != null) {
|
||||
paramCallback = (String)valueparamCallback;
|
||||
|
||||
} else {
|
||||
paramCallback = "";
|
||||
paramCallback = null;
|
||||
}
|
||||
imp.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result testEnumParameters() throws Exception {
|
||||
//TODO: Support this later
|
||||
//List<Pair> enumQueryStringArrayPair = SwaggerUtils.parameterToPairs("csv", "enumQueryStringArray", request().getQueryString("enum_query_string_array"));
|
||||
List<String> enumQueryStringArrayList = SwaggerUtils.parametersToList("csv", request().queryString().get("enum_query_string_array"));
|
||||
List<String> enumQueryStringArray = new ArrayList<String>();
|
||||
//for (Pair pair : enumQueryStringArrayPair) {
|
||||
// enumQueryStringArray.add(pair.getValue());
|
||||
//}
|
||||
for (String curParam : enumQueryStringArrayList) {
|
||||
//noinspection UseBulkOperation
|
||||
enumQueryStringArray.add(curParam);
|
||||
}
|
||||
String valueenumQueryString = request().getQueryString("enumQueryString");
|
||||
String enumQueryString;
|
||||
if (valueenumQueryString != null) {
|
||||
enumQueryString = (String)valueenumQueryString;
|
||||
|
||||
} else {
|
||||
enumQueryString = "";
|
||||
enumQueryString = "-efg";
|
||||
}
|
||||
String valueenumQueryInteger = request().getQueryString("enumQueryInteger");
|
||||
Integer enumQueryInteger;
|
||||
@@ -241,57 +256,58 @@ public class FakeApiController extends Controller {
|
||||
enumQueryInteger = Integer.parseInt(valueenumQueryInteger);
|
||||
|
||||
} else {
|
||||
enumQueryInteger = 0;
|
||||
enumQueryInteger = null;
|
||||
}
|
||||
//TODO: Support this later
|
||||
//List<Pair> enumFormStringArrayPair = SwaggerUtils.parameterToPairs("csv", "enumFormStringArray", ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array"))[0]);
|
||||
List<String> enumFormStringArrayList = SwaggerUtils.parametersToList("csv", request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array"));
|
||||
List<String> enumFormStringArray = new ArrayList<String>();
|
||||
//for (Pair pair : enumFormStringArrayPair) {
|
||||
// enumFormStringArray.add(pair.getValue());
|
||||
//}
|
||||
String valueenumFormString = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string"))[0];
|
||||
for (String curParam : enumFormStringArrayList) {
|
||||
//noinspection UseBulkOperation
|
||||
enumFormStringArray.add(curParam);
|
||||
}
|
||||
String valueenumFormString = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string"))[0];
|
||||
String enumFormString;
|
||||
if (valueenumFormString != null) {
|
||||
enumFormString = (String)valueenumFormString;
|
||||
|
||||
} 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;
|
||||
if (valueenumQueryDouble != null) {
|
||||
enumQueryDouble = Double.parseDouble(valueenumQueryDouble);
|
||||
|
||||
} 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 enumHeaderString;
|
||||
if (valueenumHeaderString != null) {
|
||||
enumHeaderString = (String)valueenumHeaderString;
|
||||
|
||||
} else {
|
||||
enumHeaderString = "";
|
||||
enumHeaderString = "-efg";
|
||||
}
|
||||
imp.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
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;
|
||||
|
||||
param = (String)valueparam;
|
||||
|
||||
String valueparam2 = ((String[]) request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0];
|
||||
String valueparam2 = (request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0];
|
||||
String param2;
|
||||
|
||||
param2 = (String)valueparam2;
|
||||
@@ -299,5 +315,6 @@ public class FakeApiController extends Controller {
|
||||
imp.testJsonFormData(param, param2);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,61 +14,33 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class FakeApiControllerImp implements FakeApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private FakeApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fakeOuterBooleanSerialize(Boolean body) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", Boolean.class);
|
||||
}
|
||||
return new Boolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", OuterComposite.class);
|
||||
}
|
||||
return new OuterComposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", BigDecimal.class);
|
||||
}
|
||||
return new BigDecimal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fakeOuterStringSerialize(String body) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", String.class);
|
||||
}
|
||||
return new String();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Client testClientModel(Client body) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", Client.class);
|
||||
}
|
||||
return new Client();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -21,11 +22,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class FakeClassnameTags123ApiController extends Controller {
|
||||
|
||||
private final FakeClassnameTags123ApiControllerImp imp;
|
||||
private final FakeClassnameTags123ApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private FakeClassnameTags123ApiController(FakeClassnameTags123ApiControllerImp imp) {
|
||||
private FakeClassnameTags123ApiController(FakeClassnameTags123ApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
@@ -37,10 +38,13 @@ public class FakeClassnameTags123ApiController extends Controller {
|
||||
Client body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), Client.class);
|
||||
body.validate();
|
||||
|
||||
Client obj = imp.testClassname(body);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,9 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class FakeClassnameTags123ApiControllerImp implements FakeClassnameTags123ApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private FakeClassnameTags123ApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Client testClassname(Client body) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", Client.class);
|
||||
}
|
||||
return new Client();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -23,11 +24,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class PetApiController extends Controller {
|
||||
|
||||
private final PetApiControllerImp imp;
|
||||
private final PetApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiController(PetApiControllerImp imp) {
|
||||
private PetApiController(PetApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
@@ -39,10 +40,12 @@ public class PetApiController extends Controller {
|
||||
Pet body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
body.validate();
|
||||
|
||||
imp.addPet(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -53,47 +56,58 @@ public class PetApiController extends Controller {
|
||||
apiKey = (String)valueapiKey;
|
||||
|
||||
} else {
|
||||
apiKey = "";
|
||||
apiKey = null;
|
||||
}
|
||||
imp.deletePet(petId, apiKey);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result findPetsByStatus() throws Exception {
|
||||
//TODO: Support this later
|
||||
//List<Pair> statusPair = SwaggerUtils.parameterToPairs("csv", "status", request().getQueryString("status"));
|
||||
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status"));
|
||||
List<String> status = new ArrayList<String>();
|
||||
//for (Pair pair : statusPair) {
|
||||
// status.add(pair.getValue());
|
||||
//}
|
||||
for (String curParam : statusList) {
|
||||
//noinspection UseBulkOperation
|
||||
status.add(curParam);
|
||||
}
|
||||
List<Pet> obj = imp.findPetsByStatus(status);
|
||||
for (Pet curItem : obj) {
|
||||
curItem.validate();
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result findPetsByTags() throws Exception {
|
||||
//TODO: Support this later
|
||||
//List<Pair> tagsPair = SwaggerUtils.parameterToPairs("csv", "tags", request().getQueryString("tags"));
|
||||
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags"));
|
||||
List<String> tags = new ArrayList<String>();
|
||||
//for (Pair pair : tagsPair) {
|
||||
// tags.add(pair.getValue());
|
||||
//}
|
||||
for (String curParam : tagsList) {
|
||||
//noinspection UseBulkOperation
|
||||
tags.add(curParam);
|
||||
}
|
||||
List<Pet> obj = imp.findPetsByTags(tags);
|
||||
for (Pet curItem : obj) {
|
||||
curItem.validate();
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getPetById(Long petId) throws Exception {
|
||||
Pet obj = imp.getPetById(petId);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -102,49 +116,54 @@ public class PetApiController extends Controller {
|
||||
Pet body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
body.validate();
|
||||
|
||||
imp.updatePet(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
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;
|
||||
if (valuename != null) {
|
||||
name = (String)valuename;
|
||||
|
||||
} 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;
|
||||
if (valuestatus != null) {
|
||||
status = (String)valuestatus;
|
||||
|
||||
} else {
|
||||
status = "";
|
||||
status = null;
|
||||
}
|
||||
imp.updatePetWithForm(petId, name, status);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
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;
|
||||
if (valueadditionalMetadata != null) {
|
||||
additionalMetadata = (String)valueadditionalMetadata;
|
||||
|
||||
} else {
|
||||
additionalMetadata = "";
|
||||
additionalMetadata = null;
|
||||
}
|
||||
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
|
||||
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,6 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPet(Pet body) throws Exception {
|
||||
//Do your magic!!!
|
||||
@@ -35,42 +27,18 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet getPetById(Long petId) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@@ -89,10 +57,6 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", ModelApiResponse.class);
|
||||
}
|
||||
return new ModelApiResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -22,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class StoreApiController extends Controller {
|
||||
|
||||
private final StoreApiControllerImp imp;
|
||||
private final StoreApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiController(StoreApiControllerImp imp) {
|
||||
private StoreApiController(StoreApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
@@ -37,6 +38,7 @@ public class StoreApiController extends Controller {
|
||||
imp.deleteOrder(orderId);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -45,14 +47,17 @@ public class StoreApiController extends Controller {
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||
Order obj = imp.getOrderById(orderId);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -61,10 +66,13 @@ public class StoreApiController extends Controller {
|
||||
Order body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), Order.class);
|
||||
body.validate();
|
||||
|
||||
Order obj = imp.placeOrder(body);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOrder(String orderId) throws Exception {
|
||||
//Do your magic!!!
|
||||
@@ -28,38 +20,18 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
@Override
|
||||
public Map<String, Integer> getInventory() throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order placeOrder(Order body) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -22,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class UserApiController extends Controller {
|
||||
|
||||
private final UserApiControllerImp imp;
|
||||
private final UserApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiController(UserApiControllerImp imp) {
|
||||
private UserApiController(UserApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
@@ -38,10 +39,12 @@ public class UserApiController extends Controller {
|
||||
User body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
body.validate();
|
||||
|
||||
imp.createUser(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -49,11 +52,15 @@ public class UserApiController extends Controller {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
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);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -61,11 +68,15 @@ public class UserApiController extends Controller {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
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);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -73,14 +84,17 @@ public class UserApiController extends Controller {
|
||||
imp.deleteUser(username);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getUserByName(String username) throws Exception {
|
||||
User obj = imp.getUserByName(username);
|
||||
obj.validate();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -99,6 +113,7 @@ public class UserApiController extends Controller {
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -106,6 +121,7 @@ public class UserApiController extends Controller {
|
||||
imp.logoutUser();
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -114,9 +130,11 @@ public class UserApiController extends Controller {
|
||||
User body;
|
||||
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
body.validate();
|
||||
|
||||
imp.updateUser(username, body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUser(User body) throws Exception {
|
||||
//Do your magic!!!
|
||||
@@ -46,28 +38,12 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
@Override
|
||||
public User getUserByName(String username) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class SwaggerUtils {
|
||||
|
||||
@@ -20,56 +17,42 @@ public class SwaggerUtils {
|
||||
public @interface ApiAction {
|
||||
}
|
||||
|
||||
public static Map<String, String> parameterToPairs(String collectionFormat, String name, Object value){
|
||||
Map<String, String> params = new HashMap<>();
|
||||
public static List<String> parametersToList(String collectionFormat, String[] values){
|
||||
List<String> params = new ArrayList<>();
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty() || value == null) return params;
|
||||
if (values == null) {
|
||||
return params;
|
||||
}
|
||||
|
||||
Collection valueCollection = null;
|
||||
if (value instanceof Collection) {
|
||||
valueCollection = (Collection) value;
|
||||
if (values.length >= 1 && collectionFormat.equals("multi")) {
|
||||
params.addAll(Arrays.asList(values));
|
||||
} 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
|
||||
|
||||
// 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 = ",";
|
||||
|
||||
if (collectionFormat.equals("csv")) {
|
||||
switch(collectionFormat) {
|
||||
case "csv": {
|
||||
delimiter = ",";
|
||||
} else if (collectionFormat.equals("ssv")) {
|
||||
break;
|
||||
}
|
||||
case "ssv": {
|
||||
delimiter = " ";
|
||||
} else if (collectionFormat.equals("tsv")) {
|
||||
break;
|
||||
}
|
||||
case "tsv": {
|
||||
delimiter = "\t";
|
||||
} else if (collectionFormat.equals("pipes")) {
|
||||
break;
|
||||
}
|
||||
case "pipes": {
|
||||
delimiter = "|";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder() ;
|
||||
for (Object item : valueCollection) {
|
||||
sb.append(delimiter);
|
||||
sb.append(parameterToString(item));
|
||||
params = Arrays.asList(values[0].split(delimiter));
|
||||
}
|
||||
|
||||
params.put(name, sb.substring(1));
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
||||
|
||||
scalaVersion := "2.11.7"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
javaJdbc,
|
||||
cache,
|
||||
javaWs,
|
||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
||||
)
|
||||
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||
libraryDependencies += "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
|
||||
# explicitly below.
|
||||
# If there are any built-in modules that you want to disable, you can list them here.
|
||||
#disabled += ""
|
||||
}
|
||||
|
||||
## IDE
|
||||
|
||||
@@ -29,9 +29,9 @@ POST /v2/pet/:petId controllers.PetApiController.updateP
|
||||
POST /v2/pet/:petId/uploadImage controllers.PetApiController.uploadFile(petId: Long)
|
||||
|
||||
#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/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()
|
||||
|
||||
#Functions for User API
|
||||
|
||||
@@ -173,6 +173,7 @@
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"deprecated" : true,
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
@@ -698,6 +699,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"api_key_query" : [ ]
|
||||
} ],
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
@@ -1100,6 +1104,11 @@
|
||||
"name" : "api_key",
|
||||
"in" : "header"
|
||||
},
|
||||
"api_key_query" : {
|
||||
"type" : "apiKey",
|
||||
"name" : "api_key_query",
|
||||
"in" : "query"
|
||||
},
|
||||
"http_basic_test" : {
|
||||
"type" : "basic"
|
||||
}
|
||||
@@ -1134,6 +1143,14 @@
|
||||
"default" : false
|
||||
}
|
||||
},
|
||||
"example" : {
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Order"
|
||||
}
|
||||
@@ -1149,6 +1166,10 @@
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"example" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Category"
|
||||
}
|
||||
@@ -1185,6 +1206,16 @@
|
||||
"description" : "User Status"
|
||||
}
|
||||
},
|
||||
"example" : {
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
}
|
||||
@@ -1200,6 +1231,10 @@
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"example" : {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Tag"
|
||||
}
|
||||
@@ -1246,6 +1281,23 @@
|
||||
"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" : {
|
||||
"name" : "Pet"
|
||||
}
|
||||
@@ -1263,6 +1315,11 @@
|
||||
"message" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"example" : {
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}
|
||||
},
|
||||
"$special[model.name]" : {
|
||||
@@ -1422,7 +1479,8 @@
|
||||
},
|
||||
"byte" : {
|
||||
"type" : "string",
|
||||
"format" : "byte"
|
||||
"format" : "byte",
|
||||
"pattern" : "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
|
||||
},
|
||||
"binary" : {
|
||||
"type" : "string",
|
||||
@@ -1528,6 +1586,9 @@
|
||||
"client" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"example" : {
|
||||
"client" : "client"
|
||||
}
|
||||
},
|
||||
"ReadOnlyFirst" : {
|
||||
@@ -1704,6 +1765,11 @@
|
||||
"my_boolean" : {
|
||||
"$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
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
public Boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class PetApiController extends Controller {
|
||||
|
||||
private final PetApiControllerImp imp;
|
||||
private final PetApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiController(PetApiControllerImp imp) {
|
||||
private PetApiController(PetApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@ import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPet(Pet body) throws Exception {
|
||||
//Do your magic!!!
|
||||
@@ -34,42 +26,18 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public List<Pet> findPetsByStatus(List<String> status) throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pet> findPetsByTags(List<String> tags) throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet getPetById(Long petId) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@@ -88,10 +56,6 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", ModelApiResponse.class);
|
||||
}
|
||||
return new ModelApiResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class StoreApiController extends Controller {
|
||||
|
||||
private final StoreApiControllerImp imp;
|
||||
private final StoreApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiController(StoreApiControllerImp imp) {
|
||||
private StoreApiController(StoreApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -10,14 +10,6 @@ import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOrder(String orderId) throws Exception {
|
||||
//Do your magic!!!
|
||||
@@ -27,38 +19,18 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
@Override
|
||||
public Map<String, Integer> getInventory() throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrderById(Long orderId) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order placeOrder(Order body) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class UserApiController extends Controller {
|
||||
|
||||
private final UserApiControllerImp imp;
|
||||
private final UserApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiController(UserApiControllerImp imp) {
|
||||
private UserApiController(UserApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -10,14 +10,6 @@ import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUser(User body) throws Exception {
|
||||
//Do your magic!!!
|
||||
@@ -45,28 +37,12 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
@Override
|
||||
public User getUserByName(String username) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loginUser(String username, String password) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,4 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
||||
|
||||
scalaVersion := "2.11.7"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
javaJdbc,
|
||||
cache,
|
||||
javaWs,
|
||||
"org.webjars" % "swagger-ui" % "2.2.10-1")
|
||||
libraryDependencies += "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
|
||||
# explicitly below.
|
||||
# If there are any built-in modules that you want to disable, you can list them here.
|
||||
#disabled += ""
|
||||
}
|
||||
|
||||
## 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" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"deprecated" : true,
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
@@ -749,7 +750,7 @@
|
||||
"title" : "Pet catehgry",
|
||||
"description" : "A category for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
@@ -790,14 +791,14 @@
|
||||
"title" : "a User",
|
||||
"description" : "A User who is purchasing from the pet store",
|
||||
"example" : {
|
||||
"firstName" : "aeiou",
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "aeiou",
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
@@ -817,7 +818,7 @@
|
||||
"title" : "Pet Tag",
|
||||
"description" : "A tag for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
@@ -868,15 +869,18 @@
|
||||
"title" : "a Pet",
|
||||
"description" : "A pet for sale in the pet store",
|
||||
"example" : {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
@@ -903,8 +907,8 @@
|
||||
"description" : "Describes the result of uploading an image resource",
|
||||
"example" : {
|
||||
"code" : 0,
|
||||
"type" : "aeiou",
|
||||
"message" : "aeiou"
|
||||
"type" : "type",
|
||||
"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
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
public Boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class PetApiController extends Controller {
|
||||
|
||||
private final PetApiControllerImp imp;
|
||||
private final PetApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiController(PetApiControllerImp imp) {
|
||||
private PetApiController(PetApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -12,14 +12,6 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private PetApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPet(Pet body) {
|
||||
//Do your magic!!!
|
||||
@@ -35,42 +27,18 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet getPetById(Long petId) {
|
||||
//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();
|
||||
}
|
||||
|
||||
@@ -89,10 +57,6 @@ public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", ModelApiResponse.class);
|
||||
}
|
||||
return new ModelApiResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class StoreApiController extends Controller {
|
||||
|
||||
private final StoreApiControllerImp imp;
|
||||
private final StoreApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiController(StoreApiControllerImp imp) {
|
||||
private StoreApiController(StoreApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private StoreApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOrder(String orderId) {
|
||||
//Do your magic!!!
|
||||
@@ -28,38 +20,18 @@ public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
@Override
|
||||
public Map<String, Integer> getInventory() {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order placeOrder(Order body) {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
public class UserApiController extends Controller {
|
||||
|
||||
private final UserApiControllerImp imp;
|
||||
private final UserApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiController(UserApiControllerImp imp) {
|
||||
private UserApiController(UserApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@ import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private UserApiControllerImp() {
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUser(User body) {
|
||||
//Do your magic!!!
|
||||
@@ -46,28 +38,12 @@ public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
@Override
|
||||
public User getUserByName(String username) {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loginUser( @NotNull String username, @NotNull String password) {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,5 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
||||
|
||||
scalaVersion := "2.11.7"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
javaJdbc,
|
||||
cache,
|
||||
javaWs,
|
||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
||||
)
|
||||
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||
libraryDependencies += "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
|
||||
# explicitly below.
|
||||
# If there are any built-in modules that you want to disable, you can list them here.
|
||||
#disabled += ""
|
||||
}
|
||||
|
||||
## 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" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"deprecated" : true,
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
@@ -749,7 +750,7 @@
|
||||
"title" : "Pet catehgry",
|
||||
"description" : "A category for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
@@ -790,14 +791,14 @@
|
||||
"title" : "a User",
|
||||
"description" : "A User who is purchasing from the pet store",
|
||||
"example" : {
|
||||
"firstName" : "aeiou",
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "aeiou",
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
@@ -817,7 +818,7 @@
|
||||
"title" : "Pet Tag",
|
||||
"description" : "A tag for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
@@ -868,15 +869,18 @@
|
||||
"title" : "a Pet",
|
||||
"description" : "A pet for sale in the pet store",
|
||||
"example" : {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
@@ -903,8 +907,8 @@
|
||||
"description" : "Describes the result of uploading an image resource",
|
||||
"example" : {
|
||||
"code" : 0,
|
||||
"type" : "aeiou",
|
||||
"message" : "aeiou"
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -157,7 +157,7 @@ public class Order {
|
||||
* Get complete
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
public Boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,88 +11,52 @@ import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
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 {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void deletePet(Long petId, String apiKey) throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Pet getPetById(Long petId) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void updatePet(Pet body) throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void updatePetWithForm(Long petId, String name, String status) throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||
//Do your magic!!!
|
||||
String accept = request().getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return mapper.readValue("", ModelApiResponse.class);
|
||||
}
|
||||
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 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 {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Map<String, Integer> getInventory() throws Exception {
|
||||
//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>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Order placeOrder(Order body) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 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 {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void createUsersWithArrayInput(List<User> body) throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void createUsersWithListInput(List<User> body) throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void deleteUser(String username) throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public User getUserByName(String username) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
||||
//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();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void logoutUser() throws Exception {
|
||||
//Do your magic!!!
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void updateUser(String username, User body) throws Exception {
|
||||
//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"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
javaJdbc,
|
||||
cache,
|
||||
javaWs,
|
||||
"org.webjars" % "swagger-ui" % "2.2.10-1",
|
||||
"javax.validation" % "validation-api" % "1.1.0.Final"
|
||||
)
|
||||
libraryDependencies += "org.webjars" % "swagger-ui" % "2.2.10-1"
|
||||
libraryDependencies += "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
|
||||
# explicitly below.
|
||||
# If there are any built-in modules that you want to disable, you can list them here.
|
||||
#disabled += ""
|
||||
disabled += "Module"
|
||||
}
|
||||
|
||||
## 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" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"deprecated" : true,
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
@@ -749,7 +750,7 @@
|
||||
"title" : "Pet catehgry",
|
||||
"description" : "A category for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
@@ -790,14 +791,14 @@
|
||||
"title" : "a User",
|
||||
"description" : "A User who is purchasing from the pet store",
|
||||
"example" : {
|
||||
"firstName" : "aeiou",
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "aeiou",
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
@@ -817,7 +818,7 @@
|
||||
"title" : "Pet Tag",
|
||||
"description" : "A tag for a pet",
|
||||
"example" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
@@ -868,15 +869,18 @@
|
||||
"title" : "a Pet",
|
||||
"description" : "A pet for sale in the pet store",
|
||||
"example" : {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
@@ -903,8 +907,8 @@
|
||||
"description" : "Describes the result of uploading an image resource",
|
||||
"example" : {
|
||||
"code" : 0,
|
||||
"type" : "aeiou",
|
||||
"message" : "aeiou"
|
||||
"type" : "type",
|
||||
"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
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean getComplete() {
|
||||
public Boolean isComplete() {
|
||||
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