openapitools.OpenAPIUtils.ApiAction Java Examples

The following examples show how to use openapitools.OpenAPIUtils.ApiAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result updatePetWithForm(Long petId) throws Exception {
    String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
    String name;
    if (valuename != null) {
        name = valuename;
    } else {
        name = null;
    }
    String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
    String status;
    if (valuestatus != null) {
        status = valuestatus;
    } else {
        status = null;
    }
    return ok();
}
 
Example #2
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByTags() throws Exception {
    String[] tagsArray = request().queryString().get("tags");
    if (tagsArray == null) {
        throw new IllegalArgumentException("'tags' parameter is required");
    }
    List<String> tagsList = OpenAPIUtils.parametersToList("csv", tagsArray);
    List<String> tags = new ArrayList<>();
    for (String curParam : tagsList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            tags.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByTags(tags);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #3
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByStatus() throws Exception {
    String[] statusArray = request().queryString().get("status");
    if (statusArray == null) {
        throw new IllegalArgumentException("'status' parameter is required");
    }
    List<String> statusList = OpenAPIUtils.parametersToList("csv", statusArray);
    List<String> status = new ArrayList<>();
    for (String curParam : statusList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            status.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByStatus(status);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #4
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public CompletionStage<Result> uploadFile(Long petId) throws Exception {
    String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
    String additionalMetadata;
    if (valueadditionalMetadata != null) {
        additionalMetadata = valueadditionalMetadata;
    } else {
        additionalMetadata = null;
    }
    Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
    CompletionStage<ModelApiResponse> stage = imp.uploadFile(petId, additionalMetadata, file).thenApply(obj -> { 
        if (configuration.getBoolean("useOutputBeanValidation")) {
            OpenAPIUtils.validate(obj);
        }
        return obj;
    });
    stage.thenApply(obj -> {
        JsonNode result = mapper.valueToTree(obj);
        return ok(result);
    });
}
 
Example #5
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result loginUser() throws Exception {
    String valueusername = request().getQueryString("username");
    String username;
    if (valueusername != null) {
        username = valueusername;
    } else {
        throw new IllegalArgumentException("'username' parameter is required");
    }
    String valuepassword = request().getQueryString("password");
    String password;
    if (valuepassword != null) {
        password = valuepassword;
    } else {
        throw new IllegalArgumentException("'password' parameter is required");
    }
    String obj = imp.loginUser(username, password);
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #6
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByTags()  {
    String[] tagsArray = request().queryString().get("tags");
    if (tagsArray == null) {
        throw new IllegalArgumentException("'tags' parameter is required");
    }
    List<String> tagsList = OpenAPIUtils.parametersToList("csv", tagsArray);
    List<String> tags = new ArrayList<>();
    for (String curParam : tagsList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            tags.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByTags(tags);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #7
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public CompletionStage<Result> createUser() throws Exception {
    JsonNode nodebody = request().body().asJson();
    User body;
    if (nodebody != null) {
        body = mapper.readValue(nodebody.toString(), User.class);
        if (configuration.getBoolean("useInputBeanValidation")) {
            OpenAPIUtils.validate(body);
        }
    } else {
        throw new IllegalArgumentException("'body' parameter is required");
    }
    return CompletableFuture.supplyAsync(() -> {
        imp.createUser(body)
        return ok();
    });
}
 
Example #8
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result updatePetWithForm(Long petId) throws Exception {
    String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
    String name;
    if (valuename != null) {
        name = valuename;
    } else {
        name = null;
    }
    String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
    String status;
    if (valuestatus != null) {
        status = valuestatus;
    } else {
        status = null;
    }
    imp.updatePetWithForm(petId, name, status);
    return ok();
}
 
Example #9
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result updatePetWithForm(Long petId)  {
    String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
    String name;
    if (valuename != null) {
        name = valuename;
    } else {
        name = null;
    }
    String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
    String status;
    if (valuestatus != null) {
        status = valuestatus;
    } else {
        status = null;
    }
    imp.updatePetWithForm(petId, name, status);
    return ok();
}
 
Example #10
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result loginUser() throws Exception {
    String valueusername = request().getQueryString("username");
    String username;
    if (valueusername != null) {
        username = valueusername;
    } else {
        throw new IllegalArgumentException("'username' parameter is required");
    }
    String valuepassword = request().getQueryString("password");
    String password;
    if (valuepassword != null) {
        password = valuepassword;
    } else {
        throw new IllegalArgumentException("'password' parameter is required");
    }
    String obj = imp.loginUser(username, password);
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #11
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result updatePetWithForm(Long petId) throws Exception {
    String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
    String name;
    if (valuename != null) {
        name = valuename;
    } else {
        name = null;
    }
    String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
    String status;
    if (valuestatus != null) {
        status = valuestatus;
    } else {
        status = null;
    }
    imp.updatePetWithForm(petId, name, status);
    return ok();
}
 
Example #12
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result uploadFile(Long petId) throws Exception {
    String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
    String additionalMetadata;
    if (valueadditionalMetadata != null) {
        additionalMetadata = valueadditionalMetadata;
    } else {
        additionalMetadata = null;
    }
    Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
    ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        OpenAPIUtils.validate(obj);
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #13
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public CompletionStage<Result> updatePet() throws Exception {
    JsonNode nodebody = request().body().asJson();
    Pet body;
    if (nodebody != null) {
        body = mapper.readValue(nodebody.toString(), Pet.class);
        if (configuration.getBoolean("useInputBeanValidation")) {
            OpenAPIUtils.validate(body);
        }
    } else {
        throw new IllegalArgumentException("'body' parameter is required");
    }
    return CompletableFuture.supplyAsync(() -> {
        imp.updatePet(body)
        return ok();
    });
}
 
Example #14
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result loginUser() throws Exception {
    String valueusername = request().getQueryString("username");
    String username;
    if (valueusername != null) {
        username = valueusername;
    } else {
        throw new IllegalArgumentException("'username' parameter is required");
    }
    String valuepassword = request().getQueryString("password");
    String password;
    if (valuepassword != null) {
        password = valuepassword;
    } else {
        throw new IllegalArgumentException("'password' parameter is required");
    }
    String obj = imp.loginUser(username, password);
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #15
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByStatus() throws Exception {
    String[] statusArray = request().queryString().get("status");
    if (statusArray == null) {
        throw new IllegalArgumentException("'status' parameter is required");
    }
    List<String> statusList = OpenAPIUtils.parametersToList("csv", statusArray);
    List<String> status = new ArrayList<>();
    for (String curParam : statusList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            status.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByStatus(status);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #16
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result uploadFile(Long petId)  {
    String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
    String additionalMetadata;
    if (valueadditionalMetadata != null) {
        additionalMetadata = valueadditionalMetadata;
    } else {
        additionalMetadata = null;
    }
    Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
    ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        OpenAPIUtils.validate(obj);
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #17
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result updatePetWithForm(Long petId) throws Exception {
    String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
    String name;
    if (valuename != null) {
        name = valuename;
    } else {
        name = null;
    }
    String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
    String status;
    if (valuestatus != null) {
        status = valuestatus;
    } else {
        status = null;
    }
    imp.updatePetWithForm(petId, name, status);
    return ok();
}
 
Example #18
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByTags() throws Exception {
    String[] tagsArray = request().queryString().get("tags");
    if (tagsArray == null) {
        throw new IllegalArgumentException("'tags' parameter is required");
    }
    List<String> tagsList = OpenAPIUtils.parametersToList("csv", tagsArray);
    List<String> tags = new ArrayList<>();
    for (String curParam : tagsList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            tags.add(curParam);
        }
    }
    return ok();
}
 
Example #19
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public CompletionStage<Result> createUsersWithListInput() throws Exception {
    JsonNode nodebody = request().body().asJson();
    List<User> body;
    if (nodebody != null) {
        body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
        if (configuration.getBoolean("useInputBeanValidation")) {
            for (User curItem : body) {
                OpenAPIUtils.validate(curItem);
            }
        }
    } else {
        throw new IllegalArgumentException("'body' parameter is required");
    }
    return CompletableFuture.supplyAsync(() -> {
        imp.createUsersWithListInput(body)
        return ok();
    });
}
 
Example #20
Source File: FakeApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result testInlineAdditionalProperties() throws Exception {
    JsonNode nodeparam = request().body().asJson();
    Map<String, String> param;
    if (nodeparam != null) {
        param = mapper.readValue(nodeparam.toString(), new TypeReference<Map<String, String>>(){});
        if (configuration.getBoolean("useInputBeanValidation")) {
            for (Map.Entry<String, String> entry : param.entrySet()) {
                OpenAPIUtils.validate(entry.getValue());
            }
        }
    } else {
        throw new IllegalArgumentException("'param' parameter is required");
    }
    imp.testInlineAdditionalProperties(param);
    return ok();
}
 
Example #21
Source File: FakeApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result testJsonFormData() throws Exception {
    String valueparam = (request().body().asMultipartFormData().asFormUrlEncoded().get("param"))[0];
    String param;
    if (valueparam != null) {
        param = valueparam;
    } else {
        throw new IllegalArgumentException("'param' parameter is required");
    }
    String valueparam2 = (request().body().asMultipartFormData().asFormUrlEncoded().get("param2"))[0];
    String param2;
    if (valueparam2 != null) {
        param2 = valueparam2;
    } else {
        throw new IllegalArgumentException("'param2' parameter is required");
    }
    imp.testJsonFormData(param, param2);
    return ok();
}
 
Example #22
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result uploadFile(Long petId) throws Exception {
    String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
    String additionalMetadata;
    if (valueadditionalMetadata != null) {
        additionalMetadata = valueadditionalMetadata;
    } else {
        additionalMetadata = null;
    }
    Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
    ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        OpenAPIUtils.validate(obj);
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #23
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public CompletionStage<Result> createUsersWithArrayInput() throws Exception {
    JsonNode nodebody = request().body().asJson();
    List<User> body;
    if (nodebody != null) {
        body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
        if (configuration.getBoolean("useInputBeanValidation")) {
            for (User curItem : body) {
                OpenAPIUtils.validate(curItem);
            }
        }
    } else {
        throw new IllegalArgumentException("'body' parameter is required");
    }
    return CompletableFuture.supplyAsync(() -> {
        imp.createUsersWithArrayInput(body)
        return ok();
    });
}
 
Example #24
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result updatePetWithForm(Long petId) throws Exception {
    String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
    String name;
    if (valuename != null) {
        name = valuename;
    } else {
        name = null;
    }
    String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
    String status;
    if (valuestatus != null) {
        status = valuestatus;
    } else {
        status = null;
    }
    imp.updatePetWithForm(petId, name, status);
    return ok();
}
 
Example #25
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByStatus() throws Exception {
    String[] statusArray = request().queryString().get("status");
    if (statusArray == null) {
        throw new IllegalArgumentException("'status' parameter is required");
    }
    List<String> statusList = OpenAPIUtils.parametersToList("csv", statusArray);
    List<String> status = new ArrayList<>();
    for (String curParam : statusList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            status.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByStatus(status);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #26
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByTags() throws Exception {
    String[] tagsArray = request().queryString().get("tags");
    if (tagsArray == null) {
        throw new IllegalArgumentException("'tags' parameter is required");
    }
    List<String> tagsList = OpenAPIUtils.parametersToList("csv", tagsArray);
    Set<String> tags = new LinkedHashSet<>();
    for (String curParam : tagsList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            tags.add(curParam);
        }
    }
    Set<Pet> obj = imp.findPetsByTags(tags);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #27
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result uploadFile(Long petId) throws Exception {
    String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
    String additionalMetadata;
    if (valueadditionalMetadata != null) {
        additionalMetadata = valueadditionalMetadata;
    } else {
        additionalMetadata = null;
    }
    Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
    ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        OpenAPIUtils.validate(obj);
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #28
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByTags() throws Exception {
    String[] tagsArray = request().queryString().get("tags");
    if (tagsArray == null) {
        throw new IllegalArgumentException("'tags' parameter is required");
    }
    List<String> tagsList = OpenAPIUtils.parametersToList("csv", tagsArray);
    List<String> tags = new ArrayList<>();
    for (String curParam : tagsList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            tags.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByTags(tags);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #29
Source File: PetApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result findPetsByStatus() throws Exception {
    String[] statusArray = request().queryString().get("status");
    if (statusArray == null) {
        throw new IllegalArgumentException("'status' parameter is required");
    }
    List<String> statusList = OpenAPIUtils.parametersToList("csv", statusArray);
    List<String> status = new ArrayList<>();
    for (String curParam : statusList) {
        if (!curParam.isEmpty()) {
            //noinspection UseBulkOperation
            status.add(curParam);
        }
    }
    List<Pet> obj = imp.findPetsByStatus(status);
    if (configuration.getBoolean("useOutputBeanValidation")) {
        for (Pet curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
    }
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}
 
Example #30
Source File: UserApiController.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@ApiAction
public Result loginUser() throws Exception {
    String valueusername = request().getQueryString("username");
    String username;
    if (valueusername != null) {
        username = valueusername;
    } else {
        throw new IllegalArgumentException("'username' parameter is required");
    }
    String valuepassword = request().getQueryString("password");
    String password;
    if (valuepassword != null) {
        password = valuepassword;
    } else {
        throw new IllegalArgumentException("'password' parameter is required");
    }
    String obj = imp.loginUser(username, password);
    JsonNode result = mapper.valueToTree(obj);
    return ok(result);
}