There was no validation when a required field was null, creating crash and null pointer exception further down the line in the business code. Now, it throws a InvalidArgumentException. (#6673)

This commit is contained in:
Jean-François Côté 2017-10-16 09:23:05 -04:00 committed by wing328
parent 619c391be9
commit 8b70f24371
39 changed files with 747 additions and 425 deletions

View File

@ -52,25 +52,35 @@ public class {{classname}}Controller extends Controller {
{{^collectionFormat}} {{^collectionFormat}}
JsonNode node{{paramName}} = request().body().asJson(); JsonNode node{{paramName}} = request().body().asJson();
{{{dataType}}} {{paramName}}; {{{dataType}}} {{paramName}};
{{^required}}
if (node{{paramName}} != null) { if (node{{paramName}} != null) {
{{paramName}} = mapper.readValue(node{{paramName}}.toString(), {{#isContainer}}new TypeReference<{{{dataType}}}>(){}{{/isContainer}}{{^isContainer}}{{{dataType}}}.class{{/isContainer}});{{/required}} {{paramName}} = mapper.readValue(node{{paramName}}.toString(), {{#isContainer}}new TypeReference<{{{dataType}}}>(){}{{/isContainer}}{{^isContainer}}{{{dataType}}}.class{{/isContainer}});
{{#required}}{{paramName}} = mapper.readValue(node{{paramName}}.toString(), {{#isContainer}}new TypeReference<{{{dataType}}}>(){}{{/isContainer}}{{^isContainer}}{{{dataType}}}.class{{/isContainer}});{{/required}}{{#useBeanValidation}} {{#useBeanValidation}}
{{#isListContainer}}for ({{{baseType}}} curItem : {{paramName}}) { {{#isListContainer}}for ({{{baseType}}} curItem : {{paramName}}) {
curItem.validate(); curItem.validate();
}{{/isListContainer}}{{#isMapContainer}}for (Map.Entry<String, {{{baseType}}}> entry : {{paramName}}.entrySet()) { }{{/isListContainer}}{{#isMapContainer}}for (Map.Entry<String, {{{baseType}}}> entry : {{paramName}}.entrySet()) {
entry.getValue().validate(); entry.getValue().validate();
} }
{{/isMapContainer}}{{^isContainer}}{{paramName}}.validate();{{/isContainer}}{{/useBeanValidation}} {{/isMapContainer}}{{^isContainer}}{{paramName}}.validate();{{/isContainer}}
{{^required}} {{/useBeanValidation}}
} else { } else {
{{#required}}
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
{{/required}}
{{^required}}
{{paramName}} = null; {{paramName}} = null;
}{{/required}} {{/required}}
}
{{/collectionFormat}} {{/collectionFormat}}
{{/bodyParams}} {{/bodyParams}}
{{#queryParams}} {{#queryParams}}
{{#collectionFormat}} {{#collectionFormat}}
List<String> {{paramName}}List = SwaggerUtils.parametersToList("{{collectionFormat}}", request().queryString().get("{{baseName}}")); String[] {{paramName}}Array = request().queryString().get("{{baseName}}");
{{#required}}
if ({{paramName}}Array == null) {
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
}
{{/required}}
List<String> {{paramName}}List = SwaggerUtils.parametersToList("{{collectionFormat}}", {{paramName}}Array);
{{{dataType}}} {{paramName}} = new Array{{{dataType}}}(); {{{dataType}}} {{paramName}} = new Array{{{dataType}}}();
for (String curParam : {{paramName}}List) { for (String curParam : {{paramName}}List) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -80,14 +90,16 @@ public class {{classname}}Controller extends Controller {
{{^collectionFormat}} {{^collectionFormat}}
String value{{paramName}} = request().getQueryString("{{baseName}}"); String value{{paramName}} = request().getQueryString("{{baseName}}");
{{{dataType}}} {{paramName}}; {{{dataType}}} {{paramName}};
{{^required}}
if (value{{paramName}} != null) { if (value{{paramName}} != null) {
{{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};{{/required}} {{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};
{{#required}}{{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};{{/required}}
{{^required}}
} else { } else {
{{#required}}
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
{{/required}}
{{^required}}
{{paramName}} = {{>paramDefaultValue}}; {{paramName}} = {{>paramDefaultValue}};
}{{/required}} {{/required}}
}
{{/collectionFormat}} {{/collectionFormat}}
{{/queryParams}} {{/queryParams}}
{{#formParams}} {{#formParams}}
@ -95,13 +107,19 @@ public class {{classname}}Controller extends Controller {
{{{dataType}}} {{paramName}} = request().body().asMultipartFormData().getFile("{{baseName}}"); {{{dataType}}} {{paramName}} = request().body().asMultipartFormData().getFile("{{baseName}}");
{{#required}} {{#required}}
if (({{paramName}} == null || ((File) {{paramName}}.getFile()).length() == 0)) { if (({{paramName}} == null || ((File) {{paramName}}.getFile()).length() == 0)) {
throw new RuntimeException("File cannot be empty"); throw new IllegalArgumentException("'{{baseName}}' file cannot be empty");
} }
{{/required}} {{/required}}
{{/notFile}} {{/notFile}}
{{#notFile}} {{#notFile}}
{{#collectionFormat}} {{#collectionFormat}}
List<String> {{paramName}}List = SwaggerUtils.parametersToList("{{collectionFormat}}", request().body().asMultipartFormData().asFormUrlEncoded().get("{{baseName}}")); String[] {{paramName}}Array = request().body().asMultipartFormData().asFormUrlEncoded().get("{{baseName}}");
{{#required}}
if ({{paramName}}Array == null) {
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
}
{{/required}}
List<String> {{paramName}}List = SwaggerUtils.parametersToList("{{collectionFormat}}", {{paramName}}Array);
{{{dataType}}} {{paramName}} = new Array{{{dataType}}}(); {{{dataType}}} {{paramName}} = new Array{{{dataType}}}();
for (String curParam : {{paramName}}List) { for (String curParam : {{paramName}}List) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -111,20 +129,28 @@ public class {{classname}}Controller extends Controller {
{{^collectionFormat}} {{^collectionFormat}}
String value{{paramName}} = (request().body().asMultipartFormData().asFormUrlEncoded().get("{{baseName}}"))[0]; String value{{paramName}} = (request().body().asMultipartFormData().asFormUrlEncoded().get("{{baseName}}"))[0];
{{{dataType}}} {{paramName}}; {{{dataType}}} {{paramName}};
{{^required}}
if (value{{paramName}} != null) { if (value{{paramName}} != null) {
{{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};{{/required}} {{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};
{{#required}}{{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};{{/required}}
{{^required}}
} else { } else {
{{#required}}
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
{{/required}}
{{^required}}
{{paramName}} = {{>paramDefaultValue}}; {{paramName}} = {{>paramDefaultValue}};
}{{/required}} {{/required}}
}
{{/collectionFormat}} {{/collectionFormat}}
{{/notFile}} {{/notFile}}
{{/formParams}} {{/formParams}}
{{#headerParams}} {{#headerParams}}
{{#collectionFormat}} {{#collectionFormat}}
List<String> {{paramName}}List = SwaggerUtils.parametersToList("{{collectionFormat}}", request().headers().get("{{baseName}}")); String[] {{paramName}}Array = request().headers().get("{{baseName}}");
{{#required}}
if ({{paramName}}Array == null) {
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
}
{{/required}}
List<String> {{paramName}}List = SwaggerUtils.parametersToList("{{collectionFormat}}", {{paramName}}Array);
{{{dataType}}} {{paramName}} = new Array{{{dataType}}}(); {{{dataType}}} {{paramName}} = new Array{{{dataType}}}();
for (String curParam : {{paramName}}List) { for (String curParam : {{paramName}}List) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -134,14 +160,16 @@ public class {{classname}}Controller extends Controller {
{{^collectionFormat}} {{^collectionFormat}}
String value{{paramName}} = request().getHeader("{{baseName}}"); String value{{paramName}} = request().getHeader("{{baseName}}");
{{{dataType}}} {{paramName}}; {{{dataType}}} {{paramName}};
{{^required}}
if (value{{paramName}} != null) { if (value{{paramName}} != null) {
{{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};{{/required}} {{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};
{{#required}}{{paramName}} = {{>conversionBegin}}value{{paramName}}{{>conversionEnd}};{{/required}}
{{^required}}
} else { } else {
{{#required}}
throw new IllegalArgumentException("'{{baseName}}' parameter is required");
{{/required}}
{{^required}}
{{paramName}} = {{>paramDefaultValue}}; {{paramName}} = {{>paramDefaultValue}};
}{{/required}} {{/required}}
}
{{/collectionFormat}} {{/collectionFormat}}
{{/headerParams}} {{/headerParams}}
{{^controllerOnly}} {{^controllerOnly}}

View File

@ -36,10 +36,12 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
@ -49,7 +51,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -58,7 +59,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -69,7 +74,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -87,10 +96,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
@ -100,7 +111,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -108,7 +118,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -121,7 +130,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -50,10 +50,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
} }

View File

@ -35,10 +35,12 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
@ -46,12 +48,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
@ -59,12 +63,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
@ -82,14 +88,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
return ok(); return ok();
} }
@ -102,10 +112,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
return ok(); return ok();
} }
} }

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },

View File

@ -6,6 +6,7 @@ public class Module extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
bind(AnotherFakeApiControllerImpInterface.class).to(AnotherFakeApiControllerImp.class);
bind(FakeApiControllerImpInterface.class).to(FakeApiControllerImp.class); bind(FakeApiControllerImpInterface.class).to(FakeApiControllerImp.class);
bind(FakeClassnameTags123ApiControllerImpInterface.class).to(FakeClassnameTags123ApiControllerImp.class); bind(FakeClassnameTags123ApiControllerImpInterface.class).to(FakeClassnameTags123ApiControllerImp.class);
bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class); bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class);

View File

@ -0,0 +1,50 @@
package controllers;
import apimodels.Client;
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;
import com.google.inject.Inject;
import java.io.File;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
import javax.validation.constraints.*;
import swagger.SwaggerUtils.ApiAction;
public class AnotherFakeApiController extends Controller {
private final AnotherFakeApiControllerImpInterface imp;
private final ObjectMapper mapper;
@Inject
private AnotherFakeApiController(AnotherFakeApiControllerImpInterface imp) {
this.imp = imp;
mapper = new ObjectMapper();
}
@ApiAction
public Result testSpecialTags() throws Exception {
JsonNode nodebody = request().body().asJson();
Client body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Client.class);
body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Client obj = imp.testSpecialTags(body);
obj.validate();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
}

View File

@ -0,0 +1,19 @@
package controllers;
import apimodels.Client;
import play.mvc.Http;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.io.FileInputStream;
import javax.validation.constraints.*;
public class AnotherFakeApiControllerImp implements AnotherFakeApiControllerImpInterface {
@Override
public Client testSpecialTags(Client body) throws Exception {
//Do your magic!!!
return new Client();
}
}

View File

@ -0,0 +1,16 @@
package controllers;
import apimodels.Client;
import play.mvc.Http;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import javax.validation.constraints.*;
@SuppressWarnings("RedundantThrows")
public interface AnotherFakeApiControllerImpInterface {
Client testSpecialTags(Client body) throws Exception;
}

View File

@ -42,7 +42,6 @@ public class FakeApiController extends Controller {
Boolean body; Boolean body;
if (nodebody != null) { if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Boolean.class); body = mapper.readValue(nodebody.toString(), Boolean.class);
body.validate(); body.validate();
} else { } else {
body = null; body = null;
@ -58,7 +57,6 @@ public class FakeApiController extends Controller {
OuterComposite body; OuterComposite body;
if (nodebody != null) { if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), OuterComposite.class); body = mapper.readValue(nodebody.toString(), OuterComposite.class);
body.validate(); body.validate();
} else { } else {
body = null; body = null;
@ -75,7 +73,6 @@ public class FakeApiController extends Controller {
BigDecimal body; BigDecimal body;
if (nodebody != null) { if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), BigDecimal.class); body = mapper.readValue(nodebody.toString(), BigDecimal.class);
body.validate(); body.validate();
} else { } else {
body = null; body = null;
@ -92,7 +89,6 @@ public class FakeApiController extends Controller {
String body; String body;
if (nodebody != null) { if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), String.class); body = mapper.readValue(nodebody.toString(), String.class);
body.validate(); body.validate();
} else { } else {
body = null; body = null;
@ -106,10 +102,12 @@ public class FakeApiController extends Controller {
public Result testClientModel() throws Exception { public Result testClientModel() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Client body; Client body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Client.class); body = mapper.readValue(nodebody.toString(), Client.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Client obj = imp.testClientModel(body); Client obj = imp.testClientModel(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
@ -122,7 +120,6 @@ public class FakeApiController extends Controller {
Integer integer; Integer integer;
if (valueinteger != null) { if (valueinteger != null) {
integer = Integer.parseInt(valueinteger); integer = Integer.parseInt(valueinteger);
} else { } else {
integer = null; integer = null;
} }
@ -130,7 +127,6 @@ public class FakeApiController extends Controller {
Integer int32; Integer int32;
if (valueint32 != null) { if (valueint32 != null) {
int32 = Integer.parseInt(valueint32); int32 = Integer.parseInt(valueint32);
} else { } else {
int32 = null; int32 = null;
} }
@ -138,51 +134,55 @@ public class FakeApiController extends Controller {
Long int64; Long int64;
if (valueint64 != null) { if (valueint64 != null) {
int64 = Long.parseLong(valueint64); int64 = Long.parseLong(valueint64);
} else { } else {
int64 = null; int64 = null;
} }
String valuenumber = (request().body().asMultipartFormData().asFormUrlEncoded().get("number"))[0]; String valuenumber = (request().body().asMultipartFormData().asFormUrlEncoded().get("number"))[0];
BigDecimal number; BigDecimal number;
if (valuenumber != null) {
number = Float.parseFloat(valuenumber); number = Float.parseFloat(valuenumber);
} else {
throw new IllegalArgumentException("'number' parameter is required");
}
String value_float = (request().body().asMultipartFormData().asFormUrlEncoded().get("float"))[0]; String value_float = (request().body().asMultipartFormData().asFormUrlEncoded().get("float"))[0];
Float _float; Float _float;
if (value_float != null) { if (value_float != null) {
_float = Float.parseFloat(value_float); _float = Float.parseFloat(value_float);
} else { } else {
_float = null; _float = null;
} }
String value_double = (request().body().asMultipartFormData().asFormUrlEncoded().get("double"))[0]; String value_double = (request().body().asMultipartFormData().asFormUrlEncoded().get("double"))[0];
Double _double; Double _double;
if (value_double != null) {
_double = Double.parseDouble(value_double); _double = Double.parseDouble(value_double);
} else {
throw new IllegalArgumentException("'double' parameter is required");
}
String valuestring = (request().body().asMultipartFormData().asFormUrlEncoded().get("string"))[0]; String valuestring = (request().body().asMultipartFormData().asFormUrlEncoded().get("string"))[0];
String string; String string;
if (valuestring != null) { if (valuestring != null) {
string = valuestring; string = valuestring;
} else { } else {
string = null; string = null;
} }
String valuepatternWithoutDelimiter = (request().body().asMultipartFormData().asFormUrlEncoded().get("pattern_without_delimiter"))[0]; String valuepatternWithoutDelimiter = (request().body().asMultipartFormData().asFormUrlEncoded().get("pattern_without_delimiter"))[0];
String patternWithoutDelimiter; String patternWithoutDelimiter;
if (valuepatternWithoutDelimiter != null) {
patternWithoutDelimiter = valuepatternWithoutDelimiter; patternWithoutDelimiter = valuepatternWithoutDelimiter;
} else {
throw new IllegalArgumentException("'pattern_without_delimiter' parameter is required");
}
String value_byte = (request().body().asMultipartFormData().asFormUrlEncoded().get("byte"))[0]; String value_byte = (request().body().asMultipartFormData().asFormUrlEncoded().get("byte"))[0];
byte[] _byte; byte[] _byte;
if (value_byte != null) {
_byte = value_byte; _byte = value_byte;
} else {
throw new IllegalArgumentException("'byte' parameter is required");
}
String valuebinary = (request().body().asMultipartFormData().asFormUrlEncoded().get("binary"))[0]; String valuebinary = (request().body().asMultipartFormData().asFormUrlEncoded().get("binary"))[0];
byte[] binary; byte[] binary;
if (valuebinary != null) { if (valuebinary != null) {
binary = valuebinary; binary = valuebinary;
} else { } else {
binary = null; binary = null;
} }
@ -190,7 +190,6 @@ public class FakeApiController extends Controller {
LocalDate date; LocalDate date;
if (valuedate != null) { if (valuedate != null) {
date = valuedate; date = valuedate;
} else { } else {
date = null; date = null;
} }
@ -198,7 +197,6 @@ public class FakeApiController extends Controller {
OffsetDateTime dateTime; OffsetDateTime dateTime;
if (valuedateTime != null) { if (valuedateTime != null) {
dateTime = OffsetDateTime.parse(valuedateTime); dateTime = OffsetDateTime.parse(valuedateTime);
} else { } else {
dateTime = null; dateTime = null;
} }
@ -206,7 +204,6 @@ public class FakeApiController extends Controller {
String password; String password;
if (valuepassword != null) { if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else { } else {
password = null; password = null;
} }
@ -214,7 +211,6 @@ public class FakeApiController extends Controller {
String paramCallback; String paramCallback;
if (valueparamCallback != null) { if (valueparamCallback != null) {
paramCallback = valueparamCallback; paramCallback = valueparamCallback;
} else { } else {
paramCallback = null; paramCallback = null;
} }
@ -224,7 +220,8 @@ public class FakeApiController extends Controller {
@ApiAction @ApiAction
public Result testEnumParameters() throws Exception { public Result testEnumParameters() throws Exception {
List<String> enumQueryStringArrayList = SwaggerUtils.parametersToList("csv", request().queryString().get("enum_query_string_array")); String[] enumQueryStringArrayArray = request().queryString().get("enum_query_string_array");
List<String> enumQueryStringArrayList = SwaggerUtils.parametersToList("csv", enumQueryStringArrayArray);
List<String> enumQueryStringArray = new ArrayList<String>(); List<String> enumQueryStringArray = new ArrayList<String>();
for (String curParam : enumQueryStringArrayList) { for (String curParam : enumQueryStringArrayList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -234,7 +231,6 @@ public class FakeApiController extends Controller {
String enumQueryString; String enumQueryString;
if (valueenumQueryString != null) { if (valueenumQueryString != null) {
enumQueryString = valueenumQueryString; enumQueryString = valueenumQueryString;
} else { } else {
enumQueryString = "-efg"; enumQueryString = "-efg";
} }
@ -242,11 +238,11 @@ public class FakeApiController extends Controller {
Integer enumQueryInteger; Integer enumQueryInteger;
if (valueenumQueryInteger != null) { if (valueenumQueryInteger != null) {
enumQueryInteger = Integer.parseInt(valueenumQueryInteger); enumQueryInteger = Integer.parseInt(valueenumQueryInteger);
} else { } else {
enumQueryInteger = null; enumQueryInteger = null;
} }
List<String> enumFormStringArrayList = SwaggerUtils.parametersToList("csv", request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array")); String[] enumFormStringArrayArray = request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array");
List<String> enumFormStringArrayList = SwaggerUtils.parametersToList("csv", enumFormStringArrayArray);
List<String> enumFormStringArray = new ArrayList<String>(); List<String> enumFormStringArray = new ArrayList<String>();
for (String curParam : enumFormStringArrayList) { for (String curParam : enumFormStringArrayList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -256,7 +252,6 @@ public class FakeApiController extends Controller {
String enumFormString; String enumFormString;
if (valueenumFormString != null) { if (valueenumFormString != null) {
enumFormString = valueenumFormString; enumFormString = valueenumFormString;
} else { } else {
enumFormString = "-efg"; enumFormString = "-efg";
} }
@ -264,11 +259,11 @@ public class FakeApiController extends Controller {
Double enumQueryDouble; Double enumQueryDouble;
if (valueenumQueryDouble != null) { if (valueenumQueryDouble != null) {
enumQueryDouble = Double.parseDouble(valueenumQueryDouble); enumQueryDouble = Double.parseDouble(valueenumQueryDouble);
} else { } else {
enumQueryDouble = null; enumQueryDouble = null;
} }
List<String> enumHeaderStringArrayList = SwaggerUtils.parametersToList("csv", request().headers().get("enum_header_string_array")); String[] enumHeaderStringArrayArray = request().headers().get("enum_header_string_array");
List<String> enumHeaderStringArrayList = SwaggerUtils.parametersToList("csv", enumHeaderStringArrayArray);
List<String> enumHeaderStringArray = new ArrayList<String>(); List<String> enumHeaderStringArray = new ArrayList<String>();
for (String curParam : enumHeaderStringArrayList) { for (String curParam : enumHeaderStringArrayList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -278,7 +273,6 @@ public class FakeApiController extends Controller {
String enumHeaderString; String enumHeaderString;
if (valueenumHeaderString != null) { if (valueenumHeaderString != null) {
enumHeaderString = valueenumHeaderString; enumHeaderString = valueenumHeaderString;
} else { } else {
enumHeaderString = "-efg"; enumHeaderString = "-efg";
} }
@ -290,14 +284,18 @@ public class FakeApiController extends Controller {
public Result testJsonFormData() throws Exception { public Result testJsonFormData() throws Exception {
String valueparam = (request().body().asMultipartFormData().asFormUrlEncoded().get("param"))[0]; String valueparam = (request().body().asMultipartFormData().asFormUrlEncoded().get("param"))[0];
String param; String param;
if (valueparam != null) {
param = valueparam; param = valueparam;
} else {
throw new IllegalArgumentException("'param' parameter is required");
}
String valueparam2 = (request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0]; String valueparam2 = (request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0];
String param2; String param2;
if (valueparam2 != null) {
param2 = valueparam2; param2 = valueparam2;
} else {
throw new IllegalArgumentException("'param2' parameter is required");
}
imp.testJsonFormData(param, param2); imp.testJsonFormData(param, param2);
return ok(); return ok();
} }

View File

@ -36,10 +36,12 @@ public class FakeClassnameTags123ApiController extends Controller {
public Result testClassname() throws Exception { public Result testClassname() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Client body; Client body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Client.class); body = mapper.readValue(nodebody.toString(), Client.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Client obj = imp.testClassname(body); Client obj = imp.testClassname(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -38,10 +38,12 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -52,7 +54,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -62,7 +63,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -78,7 +83,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -104,10 +113,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -118,7 +129,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -126,7 +136,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -140,7 +149,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -58,10 +58,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -37,10 +37,12 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -49,12 +51,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -63,12 +67,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -91,14 +97,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -114,10 +124,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -5,6 +5,9 @@
GET /api controllers.ApiDocController.api GET /api controllers.ApiDocController.api
#Functions for AnotherFake API
PATCH /v2/another-fake/dummy controllers.AnotherFakeApiController.testSpecialTags()
#Functions for Fake API #Functions for Fake API
POST /v2/fake/outer/boolean controllers.FakeApiController.fakeOuterBooleanSerialize() POST /v2/fake/outer/boolean controllers.FakeApiController.fakeOuterBooleanSerialize()
POST /v2/fake/outer/composite controllers.FakeApiController.fakeOuterCompositeSerialize() POST /v2/fake/outer/composite controllers.FakeApiController.fakeOuterCompositeSerialize()

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },
@ -1087,6 +1087,35 @@
"x-contentType" : "application/json", "x-contentType" : "application/json",
"x-accepts" : "application/json" "x-accepts" : "application/json"
} }
},
"/another-fake/dummy" : {
"patch" : {
"tags" : [ "$another-fake?" ],
"summary" : "To test special tags",
"description" : "To test special tags",
"operationId" : "test_special_tags",
"consumes" : [ "application/json" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "client model",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Client"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Client"
}
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
} }
}, },
"securityDefinitions" : { "securityDefinitions" : {
@ -1744,15 +1773,6 @@
"type" : "string", "type" : "string",
"enum" : [ "placed", "approved", "delivered" ] "enum" : [ "placed", "approved", "delivered" ]
}, },
"OuterNumber" : {
"type" : "number"
},
"OuterString" : {
"type" : "string"
},
"OuterBoolean" : {
"type" : "boolean"
},
"OuterComposite" : { "OuterComposite" : {
"type" : "object", "type" : "object",
"properties" : { "properties" : {
@ -1771,6 +1791,15 @@
"my_number" : { }, "my_number" : { },
"my_boolean" : { } "my_boolean" : { }
} }
},
"OuterNumber" : {
"type" : "number"
},
"OuterString" : {
"type" : "string"
},
"OuterBoolean" : {
"type" : "boolean"
} }
}, },
"externalDocs" : { "externalDocs" : {

View File

@ -37,9 +37,11 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -50,7 +52,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -60,7 +61,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -73,7 +78,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -95,9 +104,11 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -108,7 +119,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -116,7 +126,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -130,7 +139,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -56,9 +56,11 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);

View File

@ -36,9 +36,11 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -47,9 +49,11 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -58,9 +62,11 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -82,14 +88,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -105,9 +115,11 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },

View File

@ -39,10 +39,12 @@ public class PetApiController extends Controller {
public Result addPet() throws IOException { public Result addPet() throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -53,7 +55,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -63,7 +64,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() { public Result findPetsByStatus() {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -79,7 +84,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() { public Result findPetsByTags() {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -105,10 +114,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws IOException { public Result updatePet() throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -119,7 +130,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -127,7 +137,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -141,7 +150,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -59,10 +59,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws IOException { public Result placeOrder() throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -38,10 +38,12 @@ public class UserApiController extends Controller {
public Result createUser() throws IOException { public Result createUser() throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -50,12 +52,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws IOException { public Result createUsersWithArrayInput() throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -64,12 +68,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws IOException { public Result createUsersWithListInput() throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -92,14 +98,18 @@ public class UserApiController extends Controller {
public Result loginUser() { public Result loginUser() {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -115,10 +125,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws IOException { public Result updateUser(String username) throws IOException {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },

View File

@ -38,10 +38,12 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -52,7 +54,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -62,7 +63,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -78,7 +83,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -104,10 +113,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -118,7 +129,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -126,7 +136,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -140,7 +149,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -58,10 +58,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -37,10 +37,12 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -49,12 +51,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -63,12 +67,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -91,14 +97,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -114,10 +124,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },

View File

@ -38,10 +38,12 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -52,7 +54,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -62,7 +63,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -78,7 +83,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -104,10 +113,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -118,7 +129,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -126,7 +136,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -140,7 +149,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -58,10 +58,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -37,10 +37,12 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -49,12 +51,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -63,12 +67,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -91,14 +97,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -114,10 +124,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -37,10 +37,12 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -51,7 +53,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -61,7 +62,11 @@ public class PetApiController extends Controller {
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -77,7 +82,11 @@ public class PetApiController extends Controller {
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -103,10 +112,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -117,7 +128,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -125,7 +135,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -139,7 +148,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -57,10 +57,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -36,10 +36,12 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -48,12 +50,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -62,12 +66,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -90,14 +96,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -113,10 +123,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },

View File

@ -38,10 +38,12 @@ public class PetApiController extends Controller {
public Result addPet() throws Exception { public Result addPet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.addPet(body); imp.addPet(body);
return ok(); return ok();
} }
@ -52,7 +54,6 @@ public class PetApiController extends Controller {
String apiKey; String apiKey;
if (valueapiKey != null) { if (valueapiKey != null) {
apiKey = valueapiKey; apiKey = valueapiKey;
} else { } else {
apiKey = null; apiKey = null;
} }
@ -62,7 +63,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByStatus() throws Exception { public Result findPetsByStatus() throws Exception {
List<String> statusList = SwaggerUtils.parametersToList("csv", request().queryString().get("status")); String[] statusArray = request().queryString().get("status");
if (statusArray == null) {
throw new IllegalArgumentException("'status' parameter is required");
}
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
List<String> status = new ArrayList<String>(); List<String> status = new ArrayList<String>();
for (String curParam : statusList) { for (String curParam : statusList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -78,7 +83,11 @@ public class PetApiController extends Controller {
@ApiAction @ApiAction
public Result findPetsByTags() throws Exception { public Result findPetsByTags() throws Exception {
List<String> tagsList = SwaggerUtils.parametersToList("csv", request().queryString().get("tags")); String[] tagsArray = request().queryString().get("tags");
if (tagsArray == null) {
throw new IllegalArgumentException("'tags' parameter is required");
}
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<String>();
for (String curParam : tagsList) { for (String curParam : tagsList) {
//noinspection UseBulkOperation //noinspection UseBulkOperation
@ -104,10 +113,12 @@ public class PetApiController extends Controller {
public Result updatePet() throws Exception { public Result updatePet() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Pet body; Pet body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Pet.class); body = mapper.readValue(nodebody.toString(), Pet.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updatePet(body); imp.updatePet(body);
return ok(); return ok();
} }
@ -118,7 +129,6 @@ public class PetApiController extends Controller {
String name; String name;
if (valuename != null) { if (valuename != null) {
name = valuename; name = valuename;
} else { } else {
name = null; name = null;
} }
@ -126,7 +136,6 @@ public class PetApiController extends Controller {
String status; String status;
if (valuestatus != null) { if (valuestatus != null) {
status = valuestatus; status = valuestatus;
} else { } else {
status = null; status = null;
} }
@ -140,7 +149,6 @@ public class PetApiController extends Controller {
String additionalMetadata; String additionalMetadata;
if (valueadditionalMetadata != null) { if (valueadditionalMetadata != null) {
additionalMetadata = valueadditionalMetadata; additionalMetadata = valueadditionalMetadata;
} else { } else {
additionalMetadata = null; additionalMetadata = null;
} }

View File

@ -58,10 +58,12 @@ public class StoreApiController extends Controller {
public Result placeOrder() throws Exception { public Result placeOrder() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
Order body; Order body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), Order.class); body = mapper.readValue(nodebody.toString(), Order.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
Order obj = imp.placeOrder(body); Order obj = imp.placeOrder(body);
obj.validate(); obj.validate();
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);

View File

@ -37,10 +37,12 @@ public class UserApiController extends Controller {
public Result createUser() throws Exception { public Result createUser() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUser(body); imp.createUser(body);
return ok(); return ok();
} }
@ -49,12 +51,14 @@ public class UserApiController extends Controller {
public Result createUsersWithArrayInput() throws Exception { public Result createUsersWithArrayInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithArrayInput(body); imp.createUsersWithArrayInput(body);
return ok(); return ok();
} }
@ -63,12 +67,14 @@ public class UserApiController extends Controller {
public Result createUsersWithListInput() throws Exception { public Result createUsersWithListInput() throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
List<User> body; List<User> body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){}); body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
for (User curItem : body) { for (User curItem : body) {
curItem.validate(); curItem.validate();
} }
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.createUsersWithListInput(body); imp.createUsersWithListInput(body);
return ok(); return ok();
} }
@ -91,14 +97,18 @@ public class UserApiController extends Controller {
public Result loginUser() throws Exception { public Result loginUser() throws Exception {
String valueusername = request().getQueryString("username"); String valueusername = request().getQueryString("username");
String username; String username;
if (valueusername != null) {
username = valueusername; username = valueusername;
} else {
throw new IllegalArgumentException("'username' parameter is required");
}
String valuepassword = request().getQueryString("password"); String valuepassword = request().getQueryString("password");
String password; String password;
if (valuepassword != null) {
password = valuepassword; password = valuepassword;
} else {
throw new IllegalArgumentException("'password' parameter is required");
}
String obj = imp.loginUser(username, password); String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj); JsonNode result = mapper.valueToTree(obj);
return ok(result); return ok(result);
@ -114,10 +124,12 @@ public class UserApiController extends Controller {
public Result updateUser(String username) throws Exception { public Result updateUser(String username) throws Exception {
JsonNode nodebody = request().body().asJson(); JsonNode nodebody = request().body().asJson();
User body; User body;
if (nodebody != null) {
body = mapper.readValue(nodebody.toString(), User.class); body = mapper.readValue(nodebody.toString(), User.class);
body.validate(); body.validate();
} else {
throw new IllegalArgumentException("'body' parameter is required");
}
imp.updateUser(username, body); imp.updateUser(username, body);
return ok(); return ok();
} }

View File

@ -9,7 +9,7 @@
"email" : "apiteam@swagger.io" "email" : "apiteam@swagger.io"
}, },
"license" : { "license" : {
"name" : "Apache 2.0", "name" : "Apache-2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html" "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },