From 76d6c19b26a63b15cf2e9c1303fde28108f3d252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Mon, 5 Oct 2020 09:55:31 -0400 Subject: [PATCH 1/5] First iteration to support new mechanism that needs to have the handle of the result. --- .../newApiController.mustache | 73 +--------------- .../newApiInterface.mustache | 78 +++++++++++++++++ .../puppies/store/apis/PetApiController.java | 44 ++-------- .../apis/PetApiControllerImpInterface.java | 60 +++++++++++++ .../store/apis/StoreApiController.java | 21 +---- .../apis/StoreApiControllerImpInterface.java | 29 +++++++ .../puppies/store/apis/UserApiController.java | 29 ++----- .../apis/UserApiControllerImpInterface.java | 45 ++++++++++ .../app/controllers/PetApiController.java | 68 ++------------- .../PetApiControllerImpInterface.java | 84 +++++++++++++++++++ .../app/controllers/StoreApiController.java | 35 +------- .../StoreApiControllerImpInterface.java | 43 ++++++++++ .../app/controllers/UserApiController.java | 49 ++--------- .../UserApiControllerImpInterface.java | 65 ++++++++++++++ .../app/controllers/PetApiController.java | 16 ++-- .../app/controllers/StoreApiController.java | 8 +- .../app/controllers/UserApiController.java | 16 ++-- .../controllers/AnotherFakeApiController.java | 7 +- .../AnotherFakeApiControllerImpInterface.java | 9 ++ .../app/controllers/FakeApiController.java | 56 ++++--------- .../FakeApiControllerImpInterface.java | 84 +++++++++++++++++++ .../FakeClassnameTags123ApiController.java | 7 +- ...snameTags123ApiControllerImpInterface.java | 9 ++ .../app/controllers/PetApiController.java | 51 ++--------- .../PetApiControllerImpInterface.java | 69 +++++++++++++++ .../app/controllers/StoreApiController.java | 21 +---- .../StoreApiControllerImpInterface.java | 29 +++++++ .../app/controllers/UserApiController.java | 29 ++----- .../UserApiControllerImpInterface.java | 45 ++++++++++ .../app/controllers/PetApiController.java | 28 ++----- .../PetApiControllerImpInterface.java | 44 ++++++++++ .../app/controllers/StoreApiController.java | 15 +--- .../StoreApiControllerImpInterface.java | 23 +++++ .../app/controllers/UserApiController.java | 26 ++---- .../UserApiControllerImpInterface.java | 42 ++++++++++ .../app/controllers/PetApiController.java | 44 ++-------- .../PetApiControllerImpInterface.java | 60 +++++++++++++ .../app/controllers/StoreApiController.java | 21 +---- .../StoreApiControllerImpInterface.java | 29 +++++++ .../app/controllers/UserApiController.java | 29 ++----- .../UserApiControllerImpInterface.java | 45 ++++++++++ .../app/controllers/PetApiController.java | 44 ++-------- .../app/controllers/StoreApiController.java | 21 +---- .../app/controllers/UserApiController.java | 29 ++----- .../app/controllers/PetApiController.java | 44 ++-------- .../PetApiControllerImpInterface.java | 60 +++++++++++++ .../app/controllers/StoreApiController.java | 21 +---- .../StoreApiControllerImpInterface.java | 29 +++++++ .../app/controllers/UserApiController.java | 29 ++----- .../UserApiControllerImpInterface.java | 45 ++++++++++ .../app/controllers/PetApiController.java | 44 ++-------- .../PetApiControllerImpInterface.java | 60 +++++++++++++ .../app/controllers/StoreApiController.java | 21 +---- .../StoreApiControllerImpInterface.java | 29 +++++++ .../app/controllers/UserApiController.java | 29 ++----- .../UserApiControllerImpInterface.java | 45 ++++++++++ .../app/controllers/PetApiController.java | 44 ++-------- .../PetApiControllerImpInterface.java | 60 +++++++++++++ .../app/controllers/StoreApiController.java | 21 +---- .../StoreApiControllerImpInterface.java | 29 +++++++ .../app/controllers/UserApiController.java | 29 ++----- .../UserApiControllerImpInterface.java | 45 ++++++++++ .../app/controllers/PetApiController.java | 44 ++-------- .../PetApiControllerImpInterface.java | 60 +++++++++++++ .../app/controllers/StoreApiController.java | 21 +---- .../StoreApiControllerImpInterface.java | 29 +++++++ .../app/controllers/UserApiController.java | 29 ++----- .../UserApiControllerImpInterface.java | 45 ++++++++++ 68 files changed, 1667 insertions(+), 924 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache index 356cdf87e385..1135227d3775 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache @@ -201,81 +201,12 @@ public class {{classname}}Controller extends Controller { } {{/collectionFormat}} {{/headerParams}} - {{^controllerOnly}} - {{^returnType}} {{#supportAsync}} - return CompletableFuture.supplyAsync(() -> { + return CompletableFuture.supplyAsync(() -> imp.{{operationId}}Http(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})); {{/supportAsync}} - {{/returnType}} - {{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}imp.{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}} - {{#returnType}} - {{^isResponseFile}} - {{^returnTypeIsPrimitive}} - {{#useBeanValidation}} {{^supportAsync}} - if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isListContainer}} - for ({{{returnType}}} curItem : obj) { - OpenAPIUtils.validate(curItem); - } - {{/isListContainer}} - {{#isMapContainer}} - for (Map.Entry entry : obj.entrySet()) { - OpenAPIUtils.validate(entry.getValue()); - } - {{/isMapContainer}} - {{^returnContainer}} - OpenAPIUtils.validate(obj); - {{/returnContainer}} - } + return imp.{{operationId}}Http(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/supportAsync}} - {{#supportAsync}} - if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isListContainer}} - for ({{{returnType}}} curItem : obj) { - OpenAPIUtils.validate(curItem); - } - {{/isListContainer}} - {{#isMapContainer}} - for (Map.Entry entry : obj.entrySet()) { - OpenAPIUtils.validate(entry.getValue()); - } - {{/isMapContainer}} - {{^returnContainer}} - OpenAPIUtils.validate(obj); - {{/returnContainer}} - } - {{/supportAsync}} - {{/useBeanValidation}} - {{/returnTypeIsPrimitive}} - {{/isResponseFile}} - {{#supportAsync}} - return obj; - }); - {{/supportAsync}} - {{/returnType}} - {{#returnType}} - {{#supportAsync}} - stage.thenApply(obj -> { - {{/supportAsync}} - {{^isResponseFile}} - {{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj); - {{#supportAsync}} {{/supportAsync}}return ok(result); - {{/isResponseFile}} - {{#isResponseFile}} - {{#supportAsync}} {{/supportAsync}}return ok(obj); - {{/isResponseFile}} - {{/returnType}} - {{^returnType}} - {{#supportAsync}} {{/supportAsync}}return ok(); - {{/returnType}} - {{#supportAsync}} - }); - {{/supportAsync}} - {{/controllerOnly}} - {{#controllerOnly}} - return ok(); - {{/controllerOnly}} } {{/operation}} } diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache index 9b0e4738c873..84d88353e675 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache @@ -20,6 +20,84 @@ import javax.validation.constraints.*; @SuppressWarnings("RedundantThrows") public interface {{classname}}ControllerImpInterface { {{#operation}} + default {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}Http(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { + {{^controllerOnly}} + {{^returnType}} + {{#supportAsync}} + return CompletableFuture.supplyAsync(() -> { + {{/supportAsync}} + {{/returnType}} + {{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}} + {{#returnType}} + {{^isResponseFile}} + {{^returnTypeIsPrimitive}} + {{#useBeanValidation}} + {{^supportAsync}} + if (configuration.getBoolean("useOutputBeanValidation")) { + {{#isListContainer}} + for ({{{returnType}}} curItem : obj) { + OpenAPIUtils.validate(curItem); + } + {{/isListContainer}} + {{#isMapContainer}} + for (Map.Entry entry : obj.entrySet()) { + OpenAPIUtils.validate(entry.getValue()); + } + {{/isMapContainer}} + {{^returnContainer}} + OpenAPIUtils.validate(obj); + {{/returnContainer}} + } + {{/supportAsync}} + {{#supportAsync}} + if (configuration.getBoolean("useOutputBeanValidation")) { + {{#isListContainer}} + for ({{{returnType}}} curItem : obj) { + OpenAPIUtils.validate(curItem); + } + {{/isListContainer}} + {{#isMapContainer}} + for (Map.Entry entry : obj.entrySet()) { + OpenAPIUtils.validate(entry.getValue()); + } + {{/isMapContainer}} + {{^returnContainer}} + OpenAPIUtils.validate(obj); + {{/returnContainer}} + } + {{/supportAsync}} + {{/useBeanValidation}} + {{/returnTypeIsPrimitive}} + {{/isResponseFile}} + {{#supportAsync}} + return obj; + }); + {{/supportAsync}} + {{/returnType}} + {{#returnType}} + {{#supportAsync}} + stage.thenApply(obj -> { + {{/supportAsync}} + {{^isResponseFile}} + {{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj); + {{#supportAsync}} {{/supportAsync}}return ok(result); + {{/isResponseFile}} + {{#isResponseFile}} + {{#supportAsync}} {{/supportAsync}}return ok(obj); + {{/isResponseFile}} + {{/returnType}} + {{^returnType}} + {{#supportAsync}} {{/supportAsync}}return ok(); + {{/returnType}} + {{#supportAsync}} + }); + {{/supportAsync}} + {{/controllerOnly}} + {{#controllerOnly}} + return ok(); + {{/controllerOnly}} + } + {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}}; {{/operation}} diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java index 4c7207fd8f27..9655f1a8dc2a 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java @@ -51,8 +51,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -64,8 +63,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -82,14 +80,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -106,24 +97,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -138,8 +117,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -158,8 +136,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -172,11 +149,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java index f6ca5109af88..b0cc41b524cd 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java @@ -13,20 +13,80 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + List obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java index a41058e9bb00..434334cbe338 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java @@ -40,25 +40,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -73,11 +65,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java index ce5deb59f951..fd6e94711be0 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java index d95f368607f7..1fe8030dd252 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java @@ -50,8 +50,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -68,8 +67,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -86,24 +84,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -122,15 +113,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -145,7 +133,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java index 85ca984afa1e..536c3edfdb99 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java index 2616cd2fd6d4..3e46a8e5b7be 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java @@ -54,10 +54,7 @@ public CompletionStage addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> { - imp.addPet(request, body); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.addPetHttp(request, body)); } @ApiAction @@ -69,10 +66,7 @@ public CompletionStage deletePet(Http.Request request, Long petId) throw } else { apiKey = null; } - return CompletableFuture.supplyAsync(() -> { - imp.deletePet(request, petId, apiKey); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.deletePetHttp(request, petId, apiKey)); } @ApiAction @@ -89,18 +83,7 @@ public CompletionStage findPetsByStatus(Http.Request request) throws Exc status.add(curParam); } } - CompletionStage> stage = imp.findPetsByStatus(request, status).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.findPetsByStatusHttp(request, status)); } @ApiAction @@ -117,32 +100,12 @@ public CompletionStage findPetsByTags(Http.Request request) throws Excep tags.add(curParam); } } - CompletionStage> stage = imp.findPetsByTags(request, tags).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.findPetsByTagsHttp(request, tags)); } @ApiAction public CompletionStage getPetById(Http.Request request, Long petId) throws Exception { - CompletionStage stage = imp.getPetById(request, petId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.getPetByIdHttp(request, petId)); } @ApiAction @@ -157,10 +120,7 @@ public CompletionStage updatePet(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> { - imp.updatePet(request, body); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.updatePetHttp(request, body)); } @ApiAction @@ -179,10 +139,7 @@ public CompletionStage updatePetWithForm(Http.Request request, Long petI } else { status = null; } - return CompletableFuture.supplyAsync(() -> { - imp.updatePetWithForm(request, petId, name, status); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.updatePetWithFormHttp(request, petId, name, status)); } @ApiAction @@ -195,15 +152,6 @@ public CompletionStage uploadFile(Http.Request request, Long petId) thro additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - CompletionStage stage = imp.uploadFile(request, 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); - }); + return CompletableFuture.supplyAsync(() -> imp.uploadFileHttp(request, petId, additionalMetadata, file)); } } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java index cef49b2d231e..92b26edff7ea 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java @@ -15,20 +15,104 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default CompletionStage addPetHttp(Http.Request request, Pet body) throws Exception { + return CompletableFuture.supplyAsync(() -> { + addPet(request, body); + return ok(); + }); + } + void addPet(Http.Request request, Pet body) throws Exception; + default CompletionStage deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + return CompletableFuture.supplyAsync(() -> { + deletePet(request, petId, apiKey); + return ok(); + }); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default CompletionStage findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + CompletionStage> stage = findPetsByStatus(request, status).thenApply(obj -> { + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage> findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + CompletionStage> stage = findPetsByTags(request, tags).thenApply(obj -> { + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage> findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + default CompletionStage getPetByIdHttp(Http.Request request, Long petId) throws Exception { + CompletionStage stage = getPetById(request, petId).thenApply(obj -> { + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage getPetById(Http.Request request, Long petId) throws Exception; + default CompletionStage updatePetHttp(Http.Request request, Pet body) throws Exception { + return CompletableFuture.supplyAsync(() -> { + updatePet(request, body); + return ok(); + }); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default CompletionStage updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + return CompletableFuture.supplyAsync(() -> { + updatePetWithForm(request, petId, name, status); + return ok(); + }); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default CompletionStage uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + CompletionStage stage = uploadFile(request, 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); + }); + } + CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java index 5288f7ea46ca..f3b1ccde675e 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java @@ -43,35 +43,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public CompletionStage deleteOrder(Http.Request request, String orderId) throws Exception { - return CompletableFuture.supplyAsync(() -> { - imp.deleteOrder(request, orderId); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.deleteOrderHttp(request, orderId)); } @ApiAction public CompletionStage getInventory(Http.Request request) throws Exception { - CompletionStage> stage = imp.getInventory(request).thenApply(obj -> { - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.getInventoryHttp(request)); } @ApiAction public CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - CompletionStage stage = imp.getOrderById(request, orderId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.getOrderByIdHttp(request, orderId)); } @ApiAction @@ -86,15 +68,6 @@ public CompletionStage placeOrder(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - CompletionStage stage = imp.placeOrder(request, body).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.placeOrderHttp(request, body)); } } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java index a37df238f637..87c28dc5fa58 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java @@ -14,12 +14,55 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default CompletionStage deleteOrderHttp(Http.Request request, String orderId) throws Exception { + return CompletableFuture.supplyAsync(() -> { + deleteOrder(request, orderId); + return ok(); + }); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default CompletionStage getInventoryHttp(Http.Request request) throws Exception { + CompletionStage> stage = getInventory(request).thenApply(obj -> { + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage> getInventory(Http.Request request) throws Exception; + default CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + CompletionStage stage = getOrderById(request, orderId).thenApply(obj -> { + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default CompletionStage placeOrderHttp(Http.Request request, Order body) throws Exception { + CompletionStage stage = placeOrder(request, body).thenApply(obj -> { + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java index 9e4808d0c12b..972f0cef069a 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java @@ -53,10 +53,7 @@ public CompletionStage createUser(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> { - imp.createUser(request, body); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.createUserHttp(request, body)); } @ApiAction @@ -73,10 +70,7 @@ public CompletionStage createUsersWithArrayInput(Http.Request request) t } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> { - imp.createUsersWithArrayInput(request, body); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.createUsersWithArrayInputHttp(request, body)); } @ApiAction @@ -93,32 +87,17 @@ public CompletionStage createUsersWithListInput(Http.Request request) th } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> { - imp.createUsersWithListInput(request, body); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.createUsersWithListInputHttp(request, body)); } @ApiAction public CompletionStage deleteUser(Http.Request request, String username) throws Exception { - return CompletableFuture.supplyAsync(() -> { - imp.deleteUser(request, username); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.deleteUserHttp(request, username)); } @ApiAction public CompletionStage getUserByName(Http.Request request, String username) throws Exception { - CompletionStage stage = imp.getUserByName(request, username).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.getUserByNameHttp(request, username)); } @ApiAction @@ -137,21 +116,12 @@ public CompletionStage loginUser(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'password' parameter is required"); } - CompletionStage stage = imp.loginUser(request, username, password).thenApply(obj -> { - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return CompletableFuture.supplyAsync(() -> imp.loginUserHttp(request, username, password)); } @ApiAction public CompletionStage logoutUser(Http.Request request) throws Exception { - return CompletableFuture.supplyAsync(() -> { - imp.logoutUser(request); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.logoutUserHttp(request)); } @ApiAction @@ -166,9 +136,6 @@ public CompletionStage updateUser(Http.Request request, String username) } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> { - imp.updateUser(request, username, body); - return ok(); - }); + return CompletableFuture.supplyAsync(() -> imp.updateUserHttp(request, username, body)); } } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java index 32e3f34c9fae..6d9999b747ea 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java @@ -14,20 +14,85 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default CompletionStage createUserHttp(Http.Request request, User body) throws Exception { + return CompletableFuture.supplyAsync(() -> { + createUser(request, body); + return ok(); + }); + } + void createUser(Http.Request request, User body) throws Exception; + default CompletionStage createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + return CompletableFuture.supplyAsync(() -> { + createUsersWithArrayInput(request, body); + return ok(); + }); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default CompletionStage createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + return CompletableFuture.supplyAsync(() -> { + createUsersWithListInput(request, body); + return ok(); + }); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default CompletionStage deleteUserHttp(Http.Request request, String username) throws Exception { + return CompletableFuture.supplyAsync(() -> { + deleteUser(request, username); + return ok(); + }); + } + void deleteUser(Http.Request request, String username) throws Exception; + default CompletionStage getUserByNameHttp(Http.Request request, String username) throws Exception { + CompletionStage stage = getUserByName(request, username).thenApply(obj -> { + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage getUserByName(Http.Request request, String username) throws Exception; + default CompletionStage loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + CompletionStage stage = loginUser(request, username, password).thenApply(obj -> { + return obj; + }); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); + }); + } + CompletionStage loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default CompletionStage logoutUserHttp(Http.Request request) throws Exception { + return CompletableFuture.supplyAsync(() -> { + logoutUser(request); + return ok(); + }); + } + void logoutUser(Http.Request request) throws Exception; + default CompletionStage updateUserHttp(Http.Request request, String username, User body) throws Exception { + return CompletableFuture.supplyAsync(() -> { + updateUser(request, username, body); + return ok(); + }); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java index 1401c062cd31..3fad72d1887b 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java @@ -49,7 +49,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -61,7 +61,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -78,7 +78,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - return ok(); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -95,12 +95,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - return ok(); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - return ok(); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -115,7 +115,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -134,7 +134,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -147,6 +147,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - return ok(); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java index b5226dc51bf6..549b1acb62dd 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java @@ -38,17 +38,17 @@ private StoreApiController(Config configuration) { @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - return ok(); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - return ok(); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -63,6 +63,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java index 5a56614f0f7e..61522dc94246 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java @@ -48,7 +48,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -65,7 +65,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -82,17 +82,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - return ok(); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -111,12 +111,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - return ok(); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -131,6 +131,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java index 91b273f1c6a4..01404a24a6be 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java @@ -49,11 +49,6 @@ public Result call123testSpecialTags(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Client obj = imp.call123testSpecialTags(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.call123testSpecialTagsHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java index 54318801e568..eeb2abb54602 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java @@ -11,6 +11,15 @@ @SuppressWarnings("RedundantThrows") public interface AnotherFakeApiControllerImpInterface { + default Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exception { + Client obj = call123testSpecialTags(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Client call123testSpecialTags(Http.Request request, Client body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java index 2b41da8a9523..5167af4c75f0 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java @@ -58,8 +58,7 @@ public Result createXmlItem(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'XmlItem' parameter is required"); } - imp.createXmlItem(request, xmlItem); - return ok(); + return imp.createXmlItemHttp(request, xmlItem); } @ApiAction @@ -74,9 +73,7 @@ public Result fakeOuterBooleanSerialize(Http.Request request) throws Exception { } else { body = null; } - Boolean obj = imp.fakeOuterBooleanSerialize(request, body); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.fakeOuterBooleanSerializeHttp(request, body); } @ApiAction @@ -91,12 +88,7 @@ public Result fakeOuterCompositeSerialize(Http.Request request) throws Exception } else { body = null; } - OuterComposite obj = imp.fakeOuterCompositeSerialize(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.fakeOuterCompositeSerializeHttp(request, body); } @ApiAction @@ -111,12 +103,7 @@ public Result fakeOuterNumberSerialize(Http.Request request) throws Exception { } else { body = null; } - BigDecimal obj = imp.fakeOuterNumberSerialize(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.fakeOuterNumberSerializeHttp(request, body); } @ApiAction @@ -131,9 +118,7 @@ public Result fakeOuterStringSerialize(Http.Request request) throws Exception { } else { body = null; } - String obj = imp.fakeOuterStringSerialize(request, body); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.fakeOuterStringSerializeHttp(request, body); } @ApiAction @@ -148,8 +133,7 @@ public Result testBodyWithFileSchema(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.testBodyWithFileSchema(request, body); - return ok(); + return imp.testBodyWithFileSchemaHttp(request, body); } @ApiAction @@ -171,8 +155,7 @@ public Result testBodyWithQueryParams(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'query' parameter is required"); } - imp.testBodyWithQueryParams(request, query, body); - return ok(); + return imp.testBodyWithQueryParamsHttp(request, query, body); } @ApiAction @@ -187,12 +170,7 @@ public Result testClientModel(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Client obj = imp.testClientModel(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.testClientModelHttp(request, body); } @ApiAction @@ -289,8 +267,7 @@ public Result testEndpointParameters(Http.Request request) throws Exception { } else { paramCallback = null; } - imp.testEndpointParameters(request, number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); - return ok(); + return imp.testEndpointParametersHttp(request, number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @ApiAction @@ -357,8 +334,7 @@ public Result testEnumParameters(Http.Request request) throws Exception { } else { enumHeaderString = "-efg"; } - imp.testEnumParameters(request, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); - return ok(); + return imp.testEnumParametersHttp(request, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); } @ApiAction @@ -405,8 +381,7 @@ public Result testGroupParameters(Http.Request request) throws Exception { } else { booleanGroup = null; } - imp.testGroupParameters(request, requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); - return ok(); + return imp.testGroupParametersHttp(request, requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); } @ApiAction @@ -423,8 +398,7 @@ public Result testInlineAdditionalProperties(Http.Request request) throws Except } else { throw new IllegalArgumentException("'param' parameter is required"); } - imp.testInlineAdditionalProperties(request, param); - return ok(); + return imp.testInlineAdditionalPropertiesHttp(request, param); } @ApiAction @@ -443,8 +417,7 @@ public Result testJsonFormData(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'param2' parameter is required"); } - imp.testJsonFormData(request, param, param2); - return ok(); + return imp.testJsonFormDataHttp(request, param, param2); } @ApiAction @@ -509,7 +482,6 @@ public Result testQueryParameterCollectionFormat(Http.Request request) throws Ex context.add(curParam); } } - imp.testQueryParameterCollectionFormat(request, pipe, ioutil, http, url, context); - return ok(); + return imp.testQueryParameterCollectionFormatHttp(request, pipe, ioutil, http, url, context); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java index 2d34548a3ba5..0f099e90678b 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java @@ -20,32 +20,116 @@ @SuppressWarnings("RedundantThrows") public interface FakeApiControllerImpInterface { + default Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Exception { + createXmlItem(request, xmlItem); + return ok(); + } + void createXmlItem(Http.Request request, XmlItem xmlItem) throws Exception; + default Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) throws Exception { + Boolean obj = fakeOuterBooleanSerialize(request, body); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Boolean fakeOuterBooleanSerialize(Http.Request request, Boolean body) throws Exception; + default Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body) throws Exception { + OuterComposite obj = fakeOuterCompositeSerialize(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + OuterComposite fakeOuterCompositeSerialize(Http.Request request, OuterComposite body) throws Exception; + default Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throws Exception { + BigDecimal obj = fakeOuterNumberSerialize(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + BigDecimal fakeOuterNumberSerialize(Http.Request request, BigDecimal body) throws Exception; + default Result fakeOuterStringSerializeHttp(Http.Request request, String body) throws Exception { + String obj = fakeOuterStringSerialize(request, body); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String fakeOuterStringSerialize(Http.Request request, String body) throws Exception; + default Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestClass body) throws Exception { + testBodyWithFileSchema(request, body); + return ok(); + } + void testBodyWithFileSchema(Http.Request request, FileSchemaTestClass body) throws Exception; + default Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String query, User body) throws Exception { + testBodyWithQueryParams(request, query, body); + return ok(); + } + void testBodyWithQueryParams(Http.Request request, @NotNull String query, User body) throws Exception; + default Result testClientModelHttp(Http.Request request, Client body) throws Exception { + Client obj = testClientModel(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Client testClientModel(Http.Request request, Client body) throws Exception; + default Result testEndpointParametersHttp(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { + testEndpointParameters(request, number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + return ok(); + } + void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception; + default Result testEnumParametersHttp(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { + testEnumParameters(request, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + return ok(); + } + void testEnumParameters(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception; + default Result testGroupParametersHttp(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception { + testGroupParameters(request, requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); + return ok(); + } + void testGroupParameters(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception; + default Result testInlineAdditionalPropertiesHttp(Http.Request request, Map param) throws Exception { + testInlineAdditionalProperties(request, param); + return ok(); + } + void testInlineAdditionalProperties(Http.Request request, Map param) throws Exception; + default Result testJsonFormDataHttp(Http.Request request, String param, String param2) throws Exception { + testJsonFormData(request, param, param2); + return ok(); + } + void testJsonFormData(Http.Request request, String param, String param2) throws Exception; + default Result testQueryParameterCollectionFormatHttp(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception { + testQueryParameterCollectionFormat(request, pipe, ioutil, http, url, context); + return ok(); + } + void testQueryParameterCollectionFormat(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java index 88f4e6387c3f..a0e4ef303d40 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java @@ -49,11 +49,6 @@ public Result testClassname(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Client obj = imp.testClassname(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.testClassnameHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java index 559e67dc85a8..f1790a297c56 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java @@ -11,6 +11,15 @@ @SuppressWarnings("RedundantThrows") public interface FakeClassnameTags123ApiControllerImpInterface { + default Result testClassnameHttp(Http.Request request, Client body) throws Exception { + Client obj = testClassname(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Client testClassname(Http.Request request, Client body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java index b2aff6a1d952..b0807991b446 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java @@ -52,8 +52,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -65,8 +64,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -83,14 +81,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -107,24 +98,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - Set obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -139,8 +118,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -159,8 +137,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -173,12 +150,7 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } @ApiAction @@ -194,11 +166,6 @@ public Result uploadFileWithRequiredFile(Http.Request request, Long petId) throw if ((requiredFile == null || ((File) requiredFile.getFile()).length() == 0)) { throw new IllegalArgumentException("'requiredFile' file cannot be empty"); } - ModelApiResponse obj = imp.uploadFileWithRequiredFile(request, petId, requiredFile, additionalMetadata); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileWithRequiredFileHttp(request, petId, requiredFile, additionalMetadata); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java index 339c0b60be37..9acbe4995946 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java @@ -14,22 +14,91 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throws Exception { + Set obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Set findPetsByTags(Http.Request request, @NotNull Set tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + default Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { + ModelApiResponse obj = uploadFileWithRequiredFile(request, petId, requiredFile, additionalMetadata); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java index 72c0f37c8064..7694f31c79a4 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java @@ -40,25 +40,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -73,11 +65,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java index 21c2882cee8d..42b1ac676d62 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java index 74f87a826589..18c68559188b 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java @@ -50,8 +50,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -68,8 +67,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -86,24 +84,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -122,15 +113,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -145,7 +133,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java index 4f68a438b4b6..110c0d27e9f0 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java index e3bd0dbb7a2b..2336a8dff759 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java @@ -44,8 +44,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -57,8 +56,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -75,9 +73,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -94,16 +90,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -115,8 +107,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -135,8 +126,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -149,8 +139,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java index 42a76030ad5e..851977944c3c 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java @@ -12,20 +12,64 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, List status) throws Exception { + List obj = findPetsByStatus(request, status); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, List tags) throws Exception { + List obj = findPetsByTags(request, tags); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, List tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java index 51ccde4f843d..97faabdcd4be 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java @@ -36,22 +36,17 @@ private StoreApiController(StoreApiControllerImpInterface imp) { @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -63,8 +58,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java index 153102ae6a74..4f60e61c47e5 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java @@ -11,12 +11,35 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java index d140c89626a4..99a2197113cc 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java @@ -43,8 +43,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -56,8 +55,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -69,21 +67,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -102,15 +96,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -122,7 +113,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java index f71d2f3245d9..179c9e04ee9e 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java @@ -11,20 +11,62 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, String username, String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, String username, String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java index c5cc90d897d2..a990c2bd1833 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java @@ -52,8 +52,7 @@ public Result addPet(Http.Request request) throws IOException { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -65,8 +64,7 @@ public Result deletePet(Http.Request request, Long petId) { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -83,14 +81,7 @@ public Result findPetsByStatus(Http.Request request) { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -107,24 +98,12 @@ public Result findPetsByTags(Http.Request request) { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -139,8 +118,7 @@ public Result updatePet(Http.Request request) throws IOException { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -159,8 +137,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) { } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -173,11 +150,6 @@ public Result uploadFile(Http.Request request, Long petId) { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java index a520ed7dc1f4..4180a28c5fe4 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java @@ -13,20 +13,80 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) ; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) ; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) ; + default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { + List obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, @NotNull List tags) ; + default Result getPetByIdHttp(Http.Request request, Long petId) { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) ; + default Result updatePetHttp(Http.Request request, Pet body) { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) ; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) ; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java index 3fe9ee62e587..ba2a18a31b50 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java @@ -41,25 +41,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public Result deleteOrder(Http.Request request, String orderId) { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -74,11 +66,6 @@ public Result placeOrder(Http.Request request) throws IOException { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java index bf385ce93676..c62268536802 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) ; + default Result getInventoryHttp(Http.Request request) { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) ; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) ; + default Result placeOrderHttp(Http.Request request, Order body) { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java index abde2ad4ce02..101472248819 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java @@ -51,8 +51,7 @@ public Result createUser(Http.Request request) throws IOException { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -69,8 +68,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws IOException } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -87,24 +85,17 @@ public Result createUsersWithListInput(Http.Request request) throws IOException } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -123,15 +114,12 @@ public Result loginUser(Http.Request request) { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -146,7 +134,6 @@ public Result updateUser(Http.Request request, String username) throws IOExcepti } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java index 1c429d4665b9..6534f42539dc 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) ; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) ; + default Result createUsersWithListInputHttp(Http.Request request, List body) { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) ; + default Result deleteUserHttp(Http.Request request, String username) { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) ; + default Result getUserByNameHttp(Http.Request request, String username) { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) ; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) ; + default Result logoutUserHttp(Http.Request request) { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) ; + default Result updateUserHttp(Http.Request request, String username, User body) { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) ; } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java index 65c17d2fe696..e155c6c513b8 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java @@ -51,8 +51,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -64,8 +63,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -82,14 +80,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -106,24 +97,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -138,8 +117,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -158,8 +136,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -172,11 +149,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java index a9eb99e4f0cf..57b28d6aa399 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java @@ -40,25 +40,17 @@ private StoreApiController(Config configuration, StoreApiControllerImp imp) { @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -73,11 +65,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java index 7f74b10c4d80..43cdb02a4685 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java @@ -50,8 +50,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -68,8 +67,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -86,24 +84,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -122,15 +113,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -145,7 +133,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java index 00de0b0a6bc1..2dd0c2ba4122 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java @@ -51,8 +51,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -64,8 +63,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -82,14 +80,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -106,24 +97,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -138,8 +117,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -158,8 +136,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -172,11 +149,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java index 394d8978e0d0..be279281dd77 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java @@ -13,20 +13,80 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + List obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java index 72c0f37c8064..7694f31c79a4 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java @@ -40,25 +40,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -73,11 +65,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java index 21c2882cee8d..42b1ac676d62 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java index 74f87a826589..18c68559188b 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java @@ -50,8 +50,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -68,8 +67,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -86,24 +84,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -122,15 +113,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -145,7 +133,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java index 4f68a438b4b6..110c0d27e9f0 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java index 00de0b0a6bc1..2dd0c2ba4122 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java @@ -51,8 +51,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -64,8 +63,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -82,14 +80,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -106,24 +97,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -138,8 +117,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -158,8 +136,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -172,11 +149,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java index 394d8978e0d0..be279281dd77 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java @@ -13,20 +13,80 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + List obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java index 72c0f37c8064..7694f31c79a4 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java @@ -40,25 +40,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -73,11 +65,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java index 21c2882cee8d..42b1ac676d62 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java index 74f87a826589..18c68559188b 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java @@ -50,8 +50,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -68,8 +67,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -86,24 +84,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -122,15 +113,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -145,7 +133,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java index 4f68a438b4b6..110c0d27e9f0 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java index 739e8bccaef2..41a75d462659 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java @@ -50,8 +50,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @@ -63,8 +62,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @@ -81,14 +79,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @@ -105,24 +96,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @@ -137,8 +116,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @@ -157,8 +135,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @@ -171,11 +148,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java index 394d8978e0d0..be279281dd77 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java @@ -13,20 +13,80 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + List obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java index 394616af2890..52bc0047fe9c 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java @@ -39,25 +39,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @@ -72,11 +64,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java index 21c2882cee8d..42b1ac676d62 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java index 90180c35f680..6307adfe569f 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java @@ -49,8 +49,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @@ -67,8 +66,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @@ -85,24 +83,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @@ -121,15 +112,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @@ -144,7 +132,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java index 4f68a438b4b6..110c0d27e9f0 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java index 00de0b0a6bc1..2dd0c2ba4122 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -51,8 +51,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.addPet(request, body); - return ok(); + return imp.addPetHttp(request, body); } @ApiAction @@ -64,8 +63,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - imp.deletePet(request, petId, apiKey); - return ok(); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -82,14 +80,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - List obj = imp.findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -106,24 +97,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - List obj = imp.findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - Pet obj = imp.getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -138,8 +117,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updatePet(request, body); - return ok(); + return imp.updatePetHttp(request, body); } @ApiAction @@ -158,8 +136,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - imp.updatePetWithForm(request, petId, name, status); - return ok(); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -172,11 +149,6 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java index 394d8978e0d0..be279281dd77 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java @@ -13,20 +13,80 @@ @SuppressWarnings("RedundantThrows") public interface PetApiControllerImpInterface { + default Result addPetHttp(Http.Request request, Pet body) throws Exception { + addPet(request, body); + return ok(); + } + void addPet(Http.Request request, Pet body) throws Exception; + default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + deletePet(request, petId, apiKey); + return ok(); + } + void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + List obj = findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + List obj = findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Pet obj = getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Pet getPetById(Http.Request request, Long petId) throws Exception; + default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + updatePet(request, body); + return ok(); + } + void updatePet(Http.Request request, Pet body) throws Exception; + default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + updatePetWithForm(request, petId, name, status); + return ok(); + } + void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java index 72c0f37c8064..7694f31c79a4 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java @@ -40,25 +40,17 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - imp.deleteOrder(request, orderId); - return ok(); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - Map obj = imp.getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getInventoryHttp(request); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - Order obj = imp.getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -73,11 +65,6 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - Order obj = imp.placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.placeOrderHttp(request, body); } } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java index 21c2882cee8d..42b1ac676d62 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java @@ -12,12 +12,41 @@ @SuppressWarnings("RedundantThrows") public interface StoreApiControllerImpInterface { + default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + deleteOrder(request, orderId); + return ok(); + } + void deleteOrder(Http.Request request, String orderId) throws Exception; + default Result getInventoryHttp(Http.Request request) throws Exception { + Map obj = getInventory(request); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Map getInventory(Http.Request request) throws Exception; + default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Order obj = getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Order obj = placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java index 74f87a826589..18c68559188b 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java @@ -50,8 +50,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUser(request, body); - return ok(); + return imp.createUserHttp(request, body); } @ApiAction @@ -68,8 +67,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithArrayInput(request, body); - return ok(); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -86,24 +84,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.createUsersWithListInput(request, body); - return ok(); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - imp.deleteUser(request, username); - return ok(); + return imp.deleteUserHttp(request, username); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - User obj = imp.getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -122,15 +113,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - String obj = imp.loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); + return imp.loginUserHttp(request, username, password); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - imp.logoutUser(request); - return ok(); + return imp.logoutUserHttp(request); } @ApiAction @@ -145,7 +133,6 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - imp.updateUser(request, username, body); - return ok(); + return imp.updateUserHttp(request, username, body); } } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java index 4f68a438b4b6..110c0d27e9f0 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java @@ -12,20 +12,65 @@ @SuppressWarnings("RedundantThrows") public interface UserApiControllerImpInterface { + default Result createUserHttp(Http.Request request, User body) throws Exception { + createUser(request, body); + return ok(); + } + void createUser(Http.Request request, User body) throws Exception; + default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + createUsersWithArrayInput(request, body); + return ok(); + } + void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + createUsersWithListInput(request, body); + return ok(); + } + void createUsersWithListInput(Http.Request request, List body) throws Exception; + default Result deleteUserHttp(Http.Request request, String username) throws Exception { + deleteUser(request, username); + return ok(); + } + void deleteUser(Http.Request request, String username) throws Exception; + default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + User obj = getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + User getUserByName(Http.Request request, String username) throws Exception; + default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + String obj = loginUser(request, username, password); + JsonNode result = mapper.valueToTree(obj); + return ok(result); + } + String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + default Result logoutUserHttp(Http.Request request) throws Exception { + logoutUser(request); + return ok(); + } + void logoutUser(Http.Request request) throws Exception; + default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + updateUser(request, username, body); + return ok(); + } + void updateUser(Http.Request request, String username, User body) throws Exception; } From 3d2a866f6160499808c2bc1f45635009a44857c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Mon, 5 Oct 2020 15:25:30 -0400 Subject: [PATCH 2/5] Most of the samples now build except "async". Also, everything is messed up.. need to understand the mustache way to handle this. --- .../JavaPlayFramework/newApi.mustache | 2 +- .../newApiController.mustache | 15 +- .../newApiInterface.mustache | 99 +++--------- .../responseToResult.mustache | 75 ++++++++++ .../puppies/store/apis/PetApiController.java | 3 +- .../store/apis/PetApiControllerImp.java | 2 +- .../apis/PetApiControllerImpInterface.java | 107 +++++++------ .../store/apis/StoreApiController.java | 3 +- .../store/apis/StoreApiControllerImp.java | 2 +- .../apis/StoreApiControllerImpInterface.java | 61 +++++--- .../puppies/store/apis/UserApiController.java | 3 +- .../store/apis/UserApiControllerImp.java | 2 +- .../apis/UserApiControllerImpInterface.java | 81 ++++++---- .../app/controllers/PetApiController.java | 19 ++- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 80 ++++++---- .../app/controllers/StoreApiController.java | 11 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 89 ++++++----- .../app/controllers/UserApiController.java | 19 ++- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 121 ++++++++------- .../app/controllers/PetApiController.java | 19 ++- .../app/controllers/StoreApiController.java | 11 +- .../app/controllers/UserApiController.java | 19 ++- .../controllers/AnotherFakeApiController.java | 3 +- .../AnotherFakeApiControllerImp.java | 2 +- .../AnotherFakeApiControllerImpInterface.java | 30 +++- .../app/controllers/FakeApiController.java | 3 +- .../app/controllers/FakeApiControllerImp.java | 2 +- .../FakeApiControllerImpInterface.java | 141 +++++++++++------- .../FakeClassnameTags123ApiController.java | 3 +- .../FakeClassnameTags123ApiControllerImp.java | 2 +- ...snameTags123ApiControllerImpInterface.java | 30 +++- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 122 ++++++++------- .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 61 +++++--- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 81 ++++++---- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 77 ++++++---- .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 47 ++++-- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 73 +++++---- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 107 +++++++------ .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 61 +++++--- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 81 ++++++---- .../app/controllers/PetApiController.java | 55 +++++-- .../app/controllers/StoreApiController.java | 28 +++- .../app/controllers/UserApiController.java | 40 +++-- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 107 +++++++------ .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 61 +++++--- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 81 ++++++---- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 107 +++++++------ .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 61 +++++--- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 81 ++++++---- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 107 +++++++------ .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 61 +++++--- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 81 ++++++---- .../app/controllers/PetApiController.java | 3 +- .../app/controllers/PetApiControllerImp.java | 2 +- .../PetApiControllerImpInterface.java | 107 +++++++------ .../app/controllers/StoreApiController.java | 3 +- .../controllers/StoreApiControllerImp.java | 2 +- .../StoreApiControllerImpInterface.java | 61 +++++--- .../app/controllers/UserApiController.java | 3 +- .../app/controllers/UserApiControllerImp.java | 2 +- .../UserApiControllerImpInterface.java | 81 ++++++---- 100 files changed, 1819 insertions(+), 1180 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache index d9dd20aaf92b..f9cc05ec295b 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache @@ -18,7 +18,7 @@ import javax.validation.constraints.*; {{/useBeanValidation}} {{>generatedAnnotation}} {{#operations}} -public class {{classname}}ControllerImp {{#useInterfaces}}implements {{classname}}ControllerImpInterface{{/useInterfaces}} { +public class {{classname}}ControllerImp {{#useInterfaces}}extends {{classname}}ControllerImpInterface{{/useInterfaces}} { {{#operation}} {{#useInterfaces}}@Override{{/useInterfaces}} public {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache index 1135227d3775..5f0e62b07160 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache @@ -38,7 +38,6 @@ import openapitools.OpenAPIUtils.ApiAction; {{>generatedAnnotation}} {{#operations}} public class {{classname}}Controller extends Controller { - {{^controllerOnly}} private final {{classname}}ControllerImp{{#useInterfaces}}Interface{{/useInterfaces}} imp; {{/controllerOnly}} @@ -59,7 +58,6 @@ public class {{classname}}Controller extends Controller { } {{#operation}} - {{#wrapCalls}}@ApiAction{{/wrapCalls}} public {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}(Http.Request request{{#hasPathParams}}, {{/hasPathParams}}{{#pathParams}}{{>pathParams}}{{#hasMore}},{{/hasMore}}{{/pathParams}}) {{^handleExceptions}}{{#bodyParams}}throws IOException{{/bodyParams}}{{/handleExceptions}}{{#handleExceptions}}throws Exception{{/handleExceptions}} { {{#bodyParams}} @@ -201,13 +199,24 @@ public class {{classname}}Controller extends Controller { } {{/collectionFormat}} {{/headerParams}} + {{#useInterfaces}} + {{#controllerOnly}} + return ok(); + {{/controllerOnly}} + {{^controllerOnly}} {{#supportAsync}} - return CompletableFuture.supplyAsync(() -> imp.{{operationId}}Http(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})); + return imp.{{operationId}}Http(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/supportAsync}} {{^supportAsync}} return imp.{{operationId}}Http(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/supportAsync}} + {{/controllerOnly}} + {{/useInterfaces}} + {{^useInterfaces}} + {{>responseToResult}} + {{/useInterfaces}} } + {{/operation}} } {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache index 84d88353e675..c6af478283ac 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache @@ -3,10 +3,19 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; {{#supportAsync}} import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; @@ -17,88 +26,22 @@ import javax.validation.constraints.*; {{/useBeanValidation}} {{#operations}} +{{#useBeanValidation}} +@Singleton +{{/useBeanValidation}} @SuppressWarnings("RedundantThrows") -public interface {{classname}}ControllerImpInterface { +public abstract class {{classname}}ControllerImpInterface { + {{#useBeanValidation}} + @Inject private Config configuration; + {{/useBeanValidation}} + private ObjectMapper mapper = new ObjectMapper(); + {{#operation}} - default {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}Http(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { - {{^controllerOnly}} - {{^returnType}} - {{#supportAsync}} - return CompletableFuture.supplyAsync(() -> { - {{/supportAsync}} - {{/returnType}} - {{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}} - {{#returnType}} - {{^isResponseFile}} - {{^returnTypeIsPrimitive}} - {{#useBeanValidation}} - {{^supportAsync}} - if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isListContainer}} - for ({{{returnType}}} curItem : obj) { - OpenAPIUtils.validate(curItem); - } - {{/isListContainer}} - {{#isMapContainer}} - for (Map.Entry entry : obj.entrySet()) { - OpenAPIUtils.validate(entry.getValue()); - } - {{/isMapContainer}} - {{^returnContainer}} - OpenAPIUtils.validate(obj); - {{/returnContainer}} - } - {{/supportAsync}} - {{#supportAsync}} - if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isListContainer}} - for ({{{returnType}}} curItem : obj) { - OpenAPIUtils.validate(curItem); - } - {{/isListContainer}} - {{#isMapContainer}} - for (Map.Entry entry : obj.entrySet()) { - OpenAPIUtils.validate(entry.getValue()); - } - {{/isMapContainer}} - {{^returnContainer}} - OpenAPIUtils.validate(obj); - {{/returnContainer}} - } - {{/supportAsync}} - {{/useBeanValidation}} - {{/returnTypeIsPrimitive}} - {{/isResponseFile}} - {{#supportAsync}} - return obj; - }); - {{/supportAsync}} - {{/returnType}} - {{#returnType}} - {{#supportAsync}} - stage.thenApply(obj -> { - {{/supportAsync}} - {{^isResponseFile}} - {{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj); - {{#supportAsync}} {{/supportAsync}}return ok(result); - {{/isResponseFile}} - {{#isResponseFile}} - {{#supportAsync}} {{/supportAsync}}return ok(obj); - {{/isResponseFile}} - {{/returnType}} - {{^returnType}} - {{#supportAsync}} {{/supportAsync}}return ok(); - {{/returnType}} - {{#supportAsync}} - }); - {{/supportAsync}} - {{/controllerOnly}} - {{#controllerOnly}} - return ok(); - {{/controllerOnly}} + {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}Http(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { + {{>responseToResult}} } - {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}}; + abstract {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}}; {{/operation}} } diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache new file mode 100644 index 000000000000..cb99d86dedd2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache @@ -0,0 +1,75 @@ +{{^controllerOnly}} +{{^returnType}} +{{#supportAsync}} +return CompletableFuture.supplyAsync(() -> { +{{/supportAsync}} +{{/returnType}} +{{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{^useInterfaces}}imp.{{/useInterfaces}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}} +{{#returnType}} +{{^isResponseFile}} +{{^returnTypeIsPrimitive}} +{{#useBeanValidation}} +{{^supportAsync}} + if (configuration.getBoolean("useOutputBeanValidation")) { + {{#isListContainer}} + for ({{{returnType}}} curItem : obj) { + OpenAPIUtils.validate(curItem); + } + {{/isListContainer}} + {{#isMapContainer}} + for (Map.Entry entry : obj.entrySet()) { + OpenAPIUtils.validate(entry.getValue()); + } + {{/isMapContainer}} + {{^returnContainer}} + OpenAPIUtils.validate(obj); + {{/returnContainer}} + } +{{/supportAsync}} +{{#supportAsync}} + if (configuration.getBoolean("useOutputBeanValidation")) { + {{#isListContainer}} + for ({{{returnType}}} curItem : obj) { + OpenAPIUtils.validate(curItem); + } + {{/isListContainer}} + {{#isMapContainer}} + for (Map.Entry entry : obj.entrySet()) { + OpenAPIUtils.validate(entry.getValue()); + } + {{/isMapContainer}} + {{^returnContainer}} + OpenAPIUtils.validate(obj); + {{/returnContainer}} + } +{{/supportAsync}} +{{/useBeanValidation}} +{{/returnTypeIsPrimitive}} +{{/isResponseFile}} +{{#supportAsync}} + return obj; +}); +{{/supportAsync}} +{{/returnType}} +{{#returnType}} +{{#supportAsync}} + stage.thenApply(obj -> { +{{/supportAsync}} +{{^isResponseFile}} +{{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj); +{{#supportAsync}} {{/supportAsync}}return ok(result); +{{/isResponseFile}} +{{#isResponseFile}} +{{#supportAsync}} {{/supportAsync}}return ok(obj); +{{/isResponseFile}} +{{/returnType}} +{{^returnType}} +{{#supportAsync}} {{/supportAsync}}return ok(); +{{/returnType}} +{{#supportAsync}} +}); +{{/supportAsync}} +{{/controllerOnly}} +{{#controllerOnly}} +return ok(); +{{/controllerOnly}} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java index 9655f1a8dc2a..cdc6d67f9313 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -151,4 +149,5 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java index 95181dafd17b..791fd630ab89 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java @@ -12,7 +12,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java index b0cc41b524cd..7d675f11d855 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java @@ -4,89 +4,110 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Pet getPetById(Http.Request request, Long petId) throws Exception; + } + + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java index 434334cbe338..77901f4016ef 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -67,4 +65,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java index 3ecdb8f6a795..30c57d55a00f 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java index fd6e94711be0..ed89a347a0b6 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java index 1fe8030dd252..7afb389f01e1 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -135,4 +133,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java index 49dd68502442..5457c9bb4316 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java index 536c3edfdb99..54545ead3b8d 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) throws Exception; + } + + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java index 3e46a8e5b7be..86384e0c11a1 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java @@ -29,7 +29,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -41,7 +40,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public CompletionStage addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -54,7 +52,7 @@ public CompletionStage addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.addPetHttp(request, body)); + return imp.addPetHttp(request, body); } @ApiAction @@ -66,7 +64,7 @@ public CompletionStage deletePet(Http.Request request, Long petId) throw } else { apiKey = null; } - return CompletableFuture.supplyAsync(() -> imp.deletePetHttp(request, petId, apiKey)); + return imp.deletePetHttp(request, petId, apiKey); } @ApiAction @@ -83,7 +81,7 @@ public CompletionStage findPetsByStatus(Http.Request request) throws Exc status.add(curParam); } } - return CompletableFuture.supplyAsync(() -> imp.findPetsByStatusHttp(request, status)); + return imp.findPetsByStatusHttp(request, status); } @ApiAction @@ -100,12 +98,12 @@ public CompletionStage findPetsByTags(Http.Request request) throws Excep tags.add(curParam); } } - return CompletableFuture.supplyAsync(() -> imp.findPetsByTagsHttp(request, tags)); + return imp.findPetsByTagsHttp(request, tags); } @ApiAction public CompletionStage getPetById(Http.Request request, Long petId) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.getPetByIdHttp(request, petId)); + return imp.getPetByIdHttp(request, petId); } @ApiAction @@ -120,7 +118,7 @@ public CompletionStage updatePet(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.updatePetHttp(request, body)); + return imp.updatePetHttp(request, body); } @ApiAction @@ -139,7 +137,7 @@ public CompletionStage updatePetWithForm(Http.Request request, Long petI } else { status = null; } - return CompletableFuture.supplyAsync(() -> imp.updatePetWithFormHttp(request, petId, name, status)); + return imp.updatePetWithFormHttp(request, petId, name, status); } @ApiAction @@ -152,6 +150,7 @@ public CompletionStage uploadFile(Http.Request request, Long petId) thro additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - return CompletableFuture.supplyAsync(() -> imp.uploadFileHttp(request, petId, additionalMetadata, file)); + return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java index d4c55be8a23c..a24f118c0229 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java @@ -14,7 +14,7 @@ import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java index 92b26edff7ea..22aaf8a9aa02 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java @@ -4,59 +4,72 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default CompletionStage addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + CompletionStage addPetHttp(Http.Request request, Pet body) throws Exception { return CompletableFuture.supplyAsync(() -> { addPet(request, body); return ok(); }); } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default CompletionStage deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + CompletionStage deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { return CompletableFuture.supplyAsync(() -> { deletePet(request, petId, apiKey); return ok(); }); } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default CompletionStage findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + CompletionStage findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { CompletionStage> stage = findPetsByStatus(request, status).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } return obj; }); - stage.thenApply(obj -> { + stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); } - CompletionStage> findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract CompletionStage> findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { CompletionStage> stage = findPetsByTags(request, tags).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } } - } return obj; }); stage.thenApply(obj -> { @@ -65,46 +78,47 @@ default CompletionStage findPetsByTagsHttp(Http.Request request, @NotNul }); } - CompletionStage> findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + abstract CompletionStage> findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - default CompletionStage getPetByIdHttp(Http.Request request, Long petId) throws Exception { + CompletionStage getPetByIdHttp(Http.Request request, Long petId) throws Exception { CompletionStage stage = getPetById(request, petId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } return obj; }); - stage.thenApply(obj -> { + stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); + } - CompletionStage getPetById(Http.Request request, Long petId) throws Exception; + abstract CompletionStage getPetById(Http.Request request, Long petId) throws Exception; - default CompletionStage updatePetHttp(Http.Request request, Pet body) throws Exception { + CompletionStage updatePetHttp(Http.Request request, Pet body) throws Exception { return CompletableFuture.supplyAsync(() -> { updatePet(request, body); return ok(); }); } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default CompletionStage updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + CompletionStage updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { return CompletableFuture.supplyAsync(() -> { updatePetWithForm(request, petId, name, status); return ok(); }); } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default CompletionStage uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + CompletionStage uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { CompletionStage stage = uploadFile(request, petId, additionalMetadata, file).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } return obj; }); stage.thenApply(obj -> { @@ -113,6 +127,6 @@ default CompletionStage uploadFileHttp(Http.Request request, Long petId, }); } - CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java index f3b1ccde675e..73bd6055c5c0 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java @@ -28,7 +28,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -40,20 +39,19 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public CompletionStage deleteOrder(Http.Request request, String orderId) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.deleteOrderHttp(request, orderId)); + return imp.deleteOrderHttp(request, orderId); } @ApiAction public CompletionStage getInventory(Http.Request request) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.getInventoryHttp(request)); + return imp.getInventoryHttp(request); } @ApiAction public CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.getOrderByIdHttp(request, orderId)); + return imp.getOrderByIdHttp(request, orderId); } @ApiAction @@ -68,6 +66,7 @@ public CompletionStage placeOrder(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.placeOrderHttp(request, body)); + return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java index faa02abb54f2..f24a68517350 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java @@ -13,7 +13,7 @@ import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java index 87c28dc5fa58..32a2d8e56a87 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java @@ -3,66 +3,83 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default CompletionStage deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + CompletionStage deleteOrderHttp(Http.Request request, String orderId) throws Exception { return CompletableFuture.supplyAsync(() -> { - deleteOrder(request, orderId); - return ok(); - }); + deleteOrder(request, orderId); + return ok(); +}); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default CompletionStage getInventoryHttp(Http.Request request) throws Exception { + CompletionStage getInventoryHttp(Http.Request request) throws Exception { CompletionStage> stage = getInventory(request).thenApply(obj -> { - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return obj; +}); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); + } - CompletionStage> getInventory(Http.Request request) throws Exception; + abstract CompletionStage> getInventory(Http.Request request) throws Exception; - default CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { CompletionStage stage = getOrderById(request, orderId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } + return obj; +}); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); - CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default CompletionStage placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + CompletionStage placeOrderHttp(Http.Request request, Order body) throws Exception { CompletionStage stage = placeOrder(request, body).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; +}); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); + } - CompletionStage placeOrder(Http.Request request, Order body) throws Exception; + abstract CompletionStage placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java index 972f0cef069a..7d818ab8958e 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java @@ -28,7 +28,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -40,7 +39,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public CompletionStage createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -53,7 +51,7 @@ public CompletionStage createUser(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.createUserHttp(request, body)); + return imp.createUserHttp(request, body); } @ApiAction @@ -70,7 +68,7 @@ public CompletionStage createUsersWithArrayInput(Http.Request request) t } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.createUsersWithArrayInputHttp(request, body)); + return imp.createUsersWithArrayInputHttp(request, body); } @ApiAction @@ -87,17 +85,17 @@ public CompletionStage createUsersWithListInput(Http.Request request) th } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.createUsersWithListInputHttp(request, body)); + return imp.createUsersWithListInputHttp(request, body); } @ApiAction public CompletionStage deleteUser(Http.Request request, String username) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.deleteUserHttp(request, username)); + return imp.deleteUserHttp(request, username); } @ApiAction public CompletionStage getUserByName(Http.Request request, String username) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.getUserByNameHttp(request, username)); + return imp.getUserByNameHttp(request, username); } @ApiAction @@ -116,12 +114,12 @@ public CompletionStage loginUser(Http.Request request) throws Exception } else { throw new IllegalArgumentException("'password' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.loginUserHttp(request, username, password)); + return imp.loginUserHttp(request, username, password); } @ApiAction public CompletionStage logoutUser(Http.Request request) throws Exception { - return CompletableFuture.supplyAsync(() -> imp.logoutUserHttp(request)); + return imp.logoutUserHttp(request); } @ApiAction @@ -136,6 +134,7 @@ public CompletionStage updateUser(Http.Request request, String username) } else { throw new IllegalArgumentException("'body' parameter is required"); } - return CompletableFuture.supplyAsync(() -> imp.updateUserHttp(request, username, body)); + return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java index f5092a77f63f..0b7fc71524ce 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java @@ -13,7 +13,7 @@ import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java index 6d9999b747ea..64c739873660 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java @@ -3,96 +3,117 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default CompletionStage createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + CompletionStage createUserHttp(Http.Request request, User body) throws Exception { return CompletableFuture.supplyAsync(() -> { - createUser(request, body); - return ok(); - }); + createUser(request, body); + return ok(); +}); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default CompletionStage createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + CompletionStage createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { return CompletableFuture.supplyAsync(() -> { - createUsersWithArrayInput(request, body); - return ok(); - }); + createUsersWithArrayInput(request, body); + return ok(); +}); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default CompletionStage createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + CompletionStage createUsersWithListInputHttp(Http.Request request, List body) throws Exception { return CompletableFuture.supplyAsync(() -> { - createUsersWithListInput(request, body); - return ok(); - }); + createUsersWithListInput(request, body); + return ok(); +}); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default CompletionStage deleteUserHttp(Http.Request request, String username) throws Exception { + CompletionStage deleteUserHttp(Http.Request request, String username) throws Exception { return CompletableFuture.supplyAsync(() -> { - deleteUser(request, username); - return ok(); - }); + deleteUser(request, username); + return ok(); +}); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default CompletionStage getUserByNameHttp(Http.Request request, String username) throws Exception { + CompletionStage getUserByNameHttp(Http.Request request, String username) throws Exception { CompletionStage stage = getUserByName(request, username).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } + return obj; +}); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); - CompletionStage getUserByName(Http.Request request, String username) throws Exception; + } + + abstract CompletionStage getUserByName(Http.Request request, String username) throws Exception; - default CompletionStage loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + CompletionStage loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { CompletionStage stage = loginUser(request, username, password).thenApply(obj -> { - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + return obj; +}); + stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); + } - CompletionStage loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract CompletionStage loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default CompletionStage logoutUserHttp(Http.Request request) throws Exception { + CompletionStage logoutUserHttp(Http.Request request) throws Exception { return CompletableFuture.supplyAsync(() -> { - logoutUser(request); - return ok(); - }); + logoutUser(request); + return ok(); +}); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default CompletionStage updateUserHttp(Http.Request request, String username, User body) throws Exception { + CompletionStage updateUserHttp(Http.Request request, String username, User body) throws Exception { return CompletableFuture.supplyAsync(() -> { - updateUser(request, username, body); - return ok(); - }); + updateUser(request, username, body); + return ok(); +}); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java index 3fad72d1887b..90bbaa43bf75 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final ObjectMapper mapper; private final Config configuration; @@ -36,7 +35,6 @@ private PetApiController(Config configuration) { this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -49,7 +47,7 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.addPetHttp(request, body); + return ok(); } @ApiAction @@ -61,7 +59,7 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - return imp.deletePetHttp(request, petId, apiKey); + return ok(); } @ApiAction @@ -78,7 +76,7 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - return imp.findPetsByStatusHttp(request, status); + return ok(); } @ApiAction @@ -95,12 +93,12 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - return imp.findPetsByTagsHttp(request, tags); + return ok(); } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - return imp.getPetByIdHttp(request, petId); + return ok(); } @ApiAction @@ -115,7 +113,7 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.updatePetHttp(request, body); + return ok(); } @ApiAction @@ -134,7 +132,7 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - return imp.updatePetWithFormHttp(request, petId, name, status); + return ok(); } @ApiAction @@ -147,6 +145,7 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - return imp.uploadFileHttp(request, petId, additionalMetadata, file); + return ok(); } + } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java index 549b1acb62dd..09f250cfb8ab 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final ObjectMapper mapper; private final Config configuration; @@ -35,20 +34,19 @@ private StoreApiController(Config configuration) { this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - return imp.deleteOrderHttp(request, orderId); + return ok(); } @ApiAction public Result getInventory(Http.Request request) throws Exception { - return imp.getInventoryHttp(request); + return ok(); } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - return imp.getOrderByIdHttp(request, orderId); + return ok(); } @ApiAction @@ -63,6 +61,7 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.placeOrderHttp(request, body); + return ok(); } + } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java index 61522dc94246..acc7e7e6f606 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final ObjectMapper mapper; private final Config configuration; @@ -35,7 +34,6 @@ private UserApiController(Config configuration) { this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -48,7 +46,7 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.createUserHttp(request, body); + return ok(); } @ApiAction @@ -65,7 +63,7 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.createUsersWithArrayInputHttp(request, body); + return ok(); } @ApiAction @@ -82,17 +80,17 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.createUsersWithListInputHttp(request, body); + return ok(); } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - return imp.deleteUserHttp(request, username); + return ok(); } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - return imp.getUserByNameHttp(request, username); + return ok(); } @ApiAction @@ -111,12 +109,12 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - return imp.loginUserHttp(request, username, password); + return ok(); } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - return imp.logoutUserHttp(request); + return ok(); } @ApiAction @@ -131,6 +129,7 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.updateUserHttp(request, username, body); + return ok(); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java index 01404a24a6be..48824023b7c7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java @@ -24,7 +24,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class AnotherFakeApiController extends Controller { - private final AnotherFakeApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -36,7 +35,6 @@ private AnotherFakeApiController(Config configuration, AnotherFakeApiControllerI this.configuration = configuration; } - @ApiAction public Result call123testSpecialTags(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -51,4 +49,5 @@ public Result call123testSpecialTags(Http.Request request) throws Exception { } return imp.call123testSpecialTagsHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java index fd2f431c5b87..dd33684e55de 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java @@ -10,7 +10,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class AnotherFakeApiControllerImp implements AnotherFakeApiControllerImpInterface { +public class AnotherFakeApiControllerImp extends AnotherFakeApiControllerImpInterface { @Override public Client call123testSpecialTags(Http.Request request, Client body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java index eeb2abb54602..be2df8205364 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java @@ -2,24 +2,38 @@ import apimodels.Client; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface AnotherFakeApiControllerImpInterface { - default Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exception { +public abstract class AnotherFakeApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exception { Client obj = call123testSpecialTags(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Client call123testSpecialTags(Http.Request request, Client body) throws Exception; + abstract Client call123testSpecialTags(Http.Request request, Client body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java index 5167af4c75f0..c95771c401fa 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java @@ -33,7 +33,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class FakeApiController extends Controller { - private final FakeApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -45,7 +44,6 @@ private FakeApiController(Config configuration, FakeApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createXmlItem(Http.Request request) throws Exception { JsonNode nodexmlItem = request.body().asJson(); @@ -484,4 +482,5 @@ public Result testQueryParameterCollectionFormat(Http.Request request) throws Ex } return imp.testQueryParameterCollectionFormatHttp(request, pipe, ioutil, http, url, context); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java index 7eb83b8bc0e0..553fa0b2186a 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java @@ -19,7 +19,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class FakeApiControllerImp implements FakeApiControllerImpInterface { +public class FakeApiControllerImp extends FakeApiControllerImpInterface { @Override public void createXmlItem(Http.Request request, XmlItem xmlItem) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java index 0f099e90678b..4b6e9fa591cf 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java @@ -11,125 +11,152 @@ import apimodels.User; import apimodels.XmlItem; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface FakeApiControllerImpInterface { - default Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Exception { +public abstract class FakeApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Exception { createXmlItem(request, xmlItem); - return ok(); +return ok(); + } - void createXmlItem(Http.Request request, XmlItem xmlItem) throws Exception; + abstract void createXmlItem(Http.Request request, XmlItem xmlItem) throws Exception; - default Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) throws Exception { + Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) throws Exception { Boolean obj = fakeOuterBooleanSerialize(request, body); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Boolean fakeOuterBooleanSerialize(Http.Request request, Boolean body) throws Exception; + abstract Boolean fakeOuterBooleanSerialize(Http.Request request, Boolean body) throws Exception; - default Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body) throws Exception { + Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body) throws Exception { OuterComposite obj = fakeOuterCompositeSerialize(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - OuterComposite fakeOuterCompositeSerialize(Http.Request request, OuterComposite body) throws Exception; + abstract OuterComposite fakeOuterCompositeSerialize(Http.Request request, OuterComposite body) throws Exception; - default Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throws Exception { + Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throws Exception { BigDecimal obj = fakeOuterNumberSerialize(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - BigDecimal fakeOuterNumberSerialize(Http.Request request, BigDecimal body) throws Exception; + } + + abstract BigDecimal fakeOuterNumberSerialize(Http.Request request, BigDecimal body) throws Exception; - default Result fakeOuterStringSerializeHttp(Http.Request request, String body) throws Exception { + Result fakeOuterStringSerializeHttp(Http.Request request, String body) throws Exception { String obj = fakeOuterStringSerialize(request, body); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String fakeOuterStringSerialize(Http.Request request, String body) throws Exception; + abstract String fakeOuterStringSerialize(Http.Request request, String body) throws Exception; - default Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestClass body) throws Exception { + Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestClass body) throws Exception { testBodyWithFileSchema(request, body); - return ok(); +return ok(); + } - void testBodyWithFileSchema(Http.Request request, FileSchemaTestClass body) throws Exception; + abstract void testBodyWithFileSchema(Http.Request request, FileSchemaTestClass body) throws Exception; - default Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String query, User body) throws Exception { + Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String query, User body) throws Exception { testBodyWithQueryParams(request, query, body); - return ok(); +return ok(); + } - void testBodyWithQueryParams(Http.Request request, @NotNull String query, User body) throws Exception; + abstract void testBodyWithQueryParams(Http.Request request, @NotNull String query, User body) throws Exception; - default Result testClientModelHttp(Http.Request request, Client body) throws Exception { + Result testClientModelHttp(Http.Request request, Client body) throws Exception { Client obj = testClientModel(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Client testClientModel(Http.Request request, Client body) throws Exception; + abstract Client testClientModel(Http.Request request, Client body) throws Exception; - default Result testEndpointParametersHttp(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { + Result testEndpointParametersHttp(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { testEndpointParameters(request, number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); - return ok(); +return ok(); + } - void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception; + abstract void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception; - default Result testEnumParametersHttp(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { + Result testEnumParametersHttp(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { testEnumParameters(request, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); - return ok(); +return ok(); + } - void testEnumParameters(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception; + abstract void testEnumParameters(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception; - default Result testGroupParametersHttp(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception { + Result testGroupParametersHttp(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception { testGroupParameters(request, requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); - return ok(); +return ok(); + } - void testGroupParameters(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception; + abstract void testGroupParameters(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception; - default Result testInlineAdditionalPropertiesHttp(Http.Request request, Map param) throws Exception { + Result testInlineAdditionalPropertiesHttp(Http.Request request, Map param) throws Exception { testInlineAdditionalProperties(request, param); - return ok(); +return ok(); + } - void testInlineAdditionalProperties(Http.Request request, Map param) throws Exception; + abstract void testInlineAdditionalProperties(Http.Request request, Map param) throws Exception; - default Result testJsonFormDataHttp(Http.Request request, String param, String param2) throws Exception { + Result testJsonFormDataHttp(Http.Request request, String param, String param2) throws Exception { testJsonFormData(request, param, param2); - return ok(); +return ok(); + } - void testJsonFormData(Http.Request request, String param, String param2) throws Exception; + abstract void testJsonFormData(Http.Request request, String param, String param2) throws Exception; - default Result testQueryParameterCollectionFormatHttp(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception { + Result testQueryParameterCollectionFormatHttp(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception { testQueryParameterCollectionFormat(request, pipe, ioutil, http, url, context); - return ok(); +return ok(); + } - void testQueryParameterCollectionFormat(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception; + abstract void testQueryParameterCollectionFormat(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java index a0e4ef303d40..c45673f152a3 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java @@ -24,7 +24,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class FakeClassnameTags123ApiController extends Controller { - private final FakeClassnameTags123ApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -36,7 +35,6 @@ private FakeClassnameTags123ApiController(Config configuration, FakeClassnameTag this.configuration = configuration; } - @ApiAction public Result testClassname(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -51,4 +49,5 @@ public Result testClassname(Http.Request request) throws Exception { } return imp.testClassnameHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java index 78c3ad6b6f19..43d76c2417ae 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java @@ -10,7 +10,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class FakeClassnameTags123ApiControllerImp implements FakeClassnameTags123ApiControllerImpInterface { +public class FakeClassnameTags123ApiControllerImp extends FakeClassnameTags123ApiControllerImpInterface { @Override public Client testClassname(Http.Request request, Client body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java index f1790a297c56..6d4ae1ec894e 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java @@ -2,24 +2,38 @@ import apimodels.Client; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface FakeClassnameTags123ApiControllerImpInterface { - default Result testClassnameHttp(Http.Request request, Client body) throws Exception { +public abstract class FakeClassnameTags123ApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result testClassnameHttp(Http.Request request, Client body) throws Exception { Client obj = testClassname(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Client testClassname(Http.Request request, Client body) throws Exception; + abstract Client testClassname(Http.Request request, Client body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java index b0807991b446..3cc2768b31ab 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java @@ -27,7 +27,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -39,7 +38,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -168,4 +166,5 @@ public Result uploadFileWithRequiredFile(Http.Request request, Long petId) throw } return imp.uploadFileWithRequiredFileHttp(request, petId, requiredFile, additionalMetadata); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java index 74250653bee2..a9e517ce2a7e 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java @@ -13,7 +13,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java index 9acbe4995946..ec9bd2c22267 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java @@ -5,100 +5,122 @@ import apimodels.Pet; import java.util.Set; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throws Exception { Set obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Set findPetsByTags(Http.Request request, @NotNull Set tags) throws Exception; + } + + abstract Set findPetsByTags(Http.Request request, @NotNull Set tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Pet getPetById(Http.Request request, Long petId) throws Exception; + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + } - default Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + + Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { ModelApiResponse obj = uploadFileWithRequiredFile(request, petId, requiredFile, additionalMetadata); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception; + abstract ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java index 7694f31c79a4..b4334fb6cba7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -67,4 +65,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java index 5f10e1c1087c..efd481cb1861 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java index 42b1ac676d62..809bd598a064 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java index 18c68559188b..473cd4168149 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -135,4 +133,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java index 6297e93df654..d14d5b540b2d 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java index 110c0d27e9f0..bee1867d8520 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) throws Exception; + } + + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java index 2336a8dff759..fa926e3ef97c 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java @@ -24,7 +24,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; @@ -34,7 +33,6 @@ private PetApiController(PetApiControllerImpInterface imp) { mapper = new ObjectMapper(); } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -141,4 +139,5 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java index 1fd9d9d73243..1a209419a7ba 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java @@ -11,7 +11,7 @@ import java.util.LinkedHashSet; import java.io.FileInputStream; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java index 851977944c3c..9c2317cecc70 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java @@ -4,72 +4,91 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, List status) throws Exception { List obj = findPetsByStatus(request, status); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, List tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, List tags) throws Exception { List obj = findPetsByTags(request, tags); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, List tags) throws Exception; + abstract List findPetsByTags(Http.Request request, List tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Pet getPetById(Http.Request request, Long petId) throws Exception; + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java index 97faabdcd4be..be0d131d2891 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java @@ -23,7 +23,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; @@ -33,7 +32,6 @@ private StoreApiController(StoreApiControllerImpInterface imp) { mapper = new ObjectMapper(); } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -60,4 +58,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java index 46ede7123602..dd3a261926ab 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java @@ -10,7 +10,7 @@ import java.util.LinkedHashSet; import java.io.FileInputStream; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java index 4f60e61c47e5..1ad9a149b983 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java @@ -3,43 +3,58 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order getOrderById(Http.Request request, Long orderId) throws Exception; + abstract Order getOrderById(Http.Request request, Long orderId) throws Exception; - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java index 99a2197113cc..163d72c70cfe 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java @@ -23,7 +23,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; @@ -33,7 +32,6 @@ private UserApiController(UserApiControllerImpInterface imp) { mapper = new ObjectMapper(); } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -115,4 +113,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java index f51f8b1bd55a..925fbf30b9ef 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java @@ -10,7 +10,7 @@ import java.util.LinkedHashSet; import java.io.FileInputStream; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java index 179c9e04ee9e..b23132d3425b 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java @@ -3,70 +3,89 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - User getUserByName(Http.Request request, String username) throws Exception; + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, String username, String password) throws Exception { + Result loginUserHttp(Http.Request request, String username, String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, String username, String password) throws Exception; + abstract String loginUser(Http.Request request, String username, String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java index a990c2bd1833..4c57a2913489 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java @@ -27,7 +27,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -39,7 +38,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws IOException { JsonNode nodebody = request.body().asJson(); @@ -152,4 +150,5 @@ public Result uploadFile(Http.Request request, Long petId) { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java index cbed4103b88f..b2bcacdd852d 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java @@ -12,7 +12,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java index 4180a28c5fe4..563094963e9d 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java @@ -4,89 +4,110 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) ; + abstract void addPet(Http.Request request, Pet body) ; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) ; + abstract void deletePet(Http.Request request, Long petId, String apiKey) ; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) ; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) ; - default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { + Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, @NotNull List tags) ; + abstract List findPetsByTags(Http.Request request, @NotNull List tags) ; - default Result getPetByIdHttp(Http.Request request, Long petId) { + Result getPetByIdHttp(Http.Request request, Long petId) { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Pet getPetById(Http.Request request, Long petId) ; + } + + abstract Pet getPetById(Http.Request request, Long petId) ; - default Result updatePetHttp(Http.Request request, Pet body) { + Result updatePetHttp(Http.Request request, Pet body) { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) ; + abstract void updatePet(Http.Request request, Pet body) ; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) ; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) ; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) ; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java index ba2a18a31b50..82ce1deb243c 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) { return imp.deleteOrderHttp(request, orderId); @@ -68,4 +66,5 @@ public Result placeOrder(Http.Request request) throws IOException { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java index 2abf5ca13f55..d8d630ca42c1 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java index c62268536802..6fcb5c6e66b6 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) ; + abstract void deleteOrder(Http.Request request, String orderId) ; - default Result getInventoryHttp(Http.Request request) { + Result getInventoryHttp(Http.Request request) { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) ; + abstract Map getInventory(Http.Request request) ; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) ; + } - default Result placeOrderHttp(Http.Request request, Order body) { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) ; + + Result placeOrderHttp(Http.Request request, Order body) { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) ; + abstract Order placeOrder(Http.Request request, Order body) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java index 101472248819..e9ab364be959 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws IOException { JsonNode nodebody = request.body().asJson(); @@ -136,4 +134,5 @@ public Result updateUser(Http.Request request, String username) throws IOExcepti } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java index f119c308f86d..f938ee7d19d9 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java index 6534f42539dc..b86a27cfd6f1 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) ; + abstract void createUser(Http.Request request, User body) ; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) { + Result createUsersWithArrayInputHttp(Http.Request request, List body) { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) ; + abstract void createUsersWithArrayInput(Http.Request request, List body) ; - default Result createUsersWithListInputHttp(Http.Request request, List body) { + Result createUsersWithListInputHttp(Http.Request request, List body) { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) ; + abstract void createUsersWithListInput(Http.Request request, List body) ; - default Result deleteUserHttp(Http.Request request, String username) { + Result deleteUserHttp(Http.Request request, String username) { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) ; + abstract void deleteUser(Http.Request request, String username) ; - default Result getUserByNameHttp(Http.Request request, String username) { + Result getUserByNameHttp(Http.Request request, String username) { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) ; + } + + abstract User getUserByName(Http.Request request, String username) ; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) ; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) ; - default Result logoutUserHttp(Http.Request request) { + Result logoutUserHttp(Http.Request request) { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) ; + abstract void logoutUser(Http.Request request) ; - default Result updateUserHttp(Http.Request request, String username, User body) { + Result updateUserHttp(Http.Request request, String username, User body) { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) ; + abstract void updateUser(Http.Request request, String username, User body) ; } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java index e155c6c513b8..656f63b6723a 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImp imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private PetApiController(Config configuration, PetApiControllerImp imp) { this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -51,7 +49,9 @@ public Result addPet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.addPetHttp(request, body); + imp.addPet(request, body); +return ok(); + } @ApiAction @@ -63,7 +63,9 @@ public Result deletePet(Http.Request request, Long petId) throws Exception { } else { apiKey = null; } - return imp.deletePetHttp(request, petId, apiKey); + imp.deletePet(request, petId, apiKey); +return ok(); + } @ApiAction @@ -80,7 +82,15 @@ public Result findPetsByStatus(Http.Request request) throws Exception { status.add(curParam); } } - return imp.findPetsByStatusHttp(request, status); + List obj = imp.findPetsByStatus(request, status); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction @@ -97,12 +107,26 @@ public Result findPetsByTags(Http.Request request) throws Exception { tags.add(curParam); } } - return imp.findPetsByTagsHttp(request, tags); + List obj = imp.findPetsByTags(request, tags); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction public Result getPetById(Http.Request request, Long petId) throws Exception { - return imp.getPetByIdHttp(request, petId); + Pet obj = imp.getPetById(request, petId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction @@ -117,7 +141,9 @@ public Result updatePet(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.updatePetHttp(request, body); + imp.updatePet(request, body); +return ok(); + } @ApiAction @@ -136,7 +162,9 @@ public Result updatePetWithForm(Http.Request request, Long petId) throws Excepti } else { status = null; } - return imp.updatePetWithFormHttp(request, petId, name, status); + imp.updatePetWithForm(request, petId, name, status); +return ok(); + } @ApiAction @@ -149,6 +177,13 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { additionalMetadata = null; } Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); - return imp.uploadFileHttp(request, petId, additionalMetadata, file); + ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } + } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java index 57b28d6aa399..fa9b041347bd 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImp imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,20 +36,30 @@ private StoreApiController(Config configuration, StoreApiControllerImp imp) { this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { - return imp.deleteOrderHttp(request, orderId); + imp.deleteOrder(request, orderId); +return ok(); + } @ApiAction public Result getInventory(Http.Request request) throws Exception { - return imp.getInventoryHttp(request); + Map obj = imp.getInventory(request); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction public Result getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { - return imp.getOrderByIdHttp(request, orderId); + Order obj = imp.getOrderById(request, orderId); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction @@ -65,6 +74,13 @@ public Result placeOrder(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.placeOrderHttp(request, body); + Order obj = imp.placeOrder(request, body); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } + } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java index 43cdb02a4685..2300d02e2b87 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImp imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private UserApiController(Config configuration, UserApiControllerImp imp) { this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -50,7 +48,9 @@ public Result createUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.createUserHttp(request, body); + imp.createUser(request, body); +return ok(); + } @ApiAction @@ -67,7 +67,9 @@ public Result createUsersWithArrayInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.createUsersWithArrayInputHttp(request, body); + imp.createUsersWithArrayInput(request, body); +return ok(); + } @ApiAction @@ -84,17 +86,27 @@ public Result createUsersWithListInput(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.createUsersWithListInputHttp(request, body); + imp.createUsersWithListInput(request, body); +return ok(); + } @ApiAction public Result deleteUser(Http.Request request, String username) throws Exception { - return imp.deleteUserHttp(request, username); + imp.deleteUser(request, username); +return ok(); + } @ApiAction public Result getUserByName(Http.Request request, String username) throws Exception { - return imp.getUserByNameHttp(request, username); + User obj = imp.getUserByName(request, username); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction @@ -113,12 +125,17 @@ public Result loginUser(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'password' parameter is required"); } - return imp.loginUserHttp(request, username, password); + String obj = imp.loginUser(request, username, password); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } @ApiAction public Result logoutUser(Http.Request request) throws Exception { - return imp.logoutUserHttp(request); + imp.logoutUser(request); +return ok(); + } @ApiAction @@ -133,6 +150,9 @@ public Result updateUser(Http.Request request, String username) throws Exception } else { throw new IllegalArgumentException("'body' parameter is required"); } - return imp.updateUserHttp(request, username, body); + imp.updateUser(request, username, body); +return ok(); + } + } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java index 2dd0c2ba4122..07abcaa84b3b 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -151,4 +149,5 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java index 5a638f0392c0..62dc0bcdbc73 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java @@ -12,7 +12,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java index be279281dd77..11f5c78c385c 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java @@ -4,89 +4,110 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Pet getPetById(Http.Request request, Long petId) throws Exception; + } + + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java index 7694f31c79a4..b4334fb6cba7 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -67,4 +65,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java index 5f10e1c1087c..efd481cb1861 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java index 42b1ac676d62..809bd598a064 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java index 18c68559188b..473cd4168149 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -135,4 +133,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java index 6297e93df654..d14d5b540b2d 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java index 110c0d27e9f0..bee1867d8520 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) throws Exception; + } + + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java index 2dd0c2ba4122..07abcaa84b3b 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -151,4 +149,5 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java index 5a638f0392c0..62dc0bcdbc73 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java @@ -12,7 +12,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java index be279281dd77..11f5c78c385c 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java @@ -4,89 +4,110 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Pet getPetById(Http.Request request, Long petId) throws Exception; + } + + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java index 7694f31c79a4..b4334fb6cba7 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -67,4 +65,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java index 5f10e1c1087c..efd481cb1861 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java index 42b1ac676d62..809bd598a064 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java index 18c68559188b..473cd4168149 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -135,4 +133,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java index 6297e93df654..d14d5b540b2d 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java index 110c0d27e9f0..bee1867d8520 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) throws Exception; + } + + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java index 41a75d462659..f7462991ab98 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -150,4 +148,5 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java index 5a638f0392c0..62dc0bcdbc73 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java @@ -12,7 +12,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java index be279281dd77..11f5c78c385c 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java @@ -4,89 +4,110 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Pet getPetById(Http.Request request, Long petId) throws Exception; + } + + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java index 52bc0047fe9c..59977ab01482 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java @@ -24,7 +24,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -36,7 +35,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -66,4 +64,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java index 5f10e1c1087c..efd481cb1861 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java index 42b1ac676d62..809bd598a064 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java index 6307adfe569f..218ff716e276 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java @@ -24,7 +24,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -36,7 +35,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -134,4 +132,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java index 6297e93df654..d14d5b540b2d 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java index 110c0d27e9f0..bee1867d8520 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) throws Exception; + } + + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java index 2dd0c2ba4122..07abcaa84b3b 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -26,7 +26,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiController extends Controller { - private final PetApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -38,7 +37,6 @@ private PetApiController(Config configuration, PetApiControllerImpInterface imp) this.configuration = configuration; } - @ApiAction public Result addPet(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -151,4 +149,5 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } + } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java index 5a638f0392c0..62dc0bcdbc73 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java @@ -12,7 +12,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class PetApiControllerImp implements PetApiControllerImpInterface { +public class PetApiControllerImp extends PetApiControllerImpInterface { @Override public void addPet(Http.Request request, Pet body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java index be279281dd77..11f5c78c385c 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java @@ -4,89 +4,110 @@ import apimodels.ModelApiResponse; import apimodels.Pet; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface PetApiControllerImpInterface { - default Result addPetHttp(Http.Request request, Pet body) throws Exception { +public abstract class PetApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); - return ok(); +return ok(); + } - void addPet(Http.Request request, Pet body) throws Exception; + abstract void addPet(Http.Request request, Pet body) throws Exception; - default Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); - return ok(); +return ok(); + } - void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - default Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - default Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - default Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Pet getPetById(Http.Request request, Long petId) throws Exception; + } + + abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - default Result updatePetHttp(Http.Request request, Pet body) throws Exception { + Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); - return ok(); +return ok(); + } - void updatePet(Http.Request request, Pet body) throws Exception; + abstract void updatePet(Http.Request request, Pet body) throws Exception; - default Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); - return ok(); +return ok(); + } - void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - default Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java index 7694f31c79a4..b4334fb6cba7 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiController extends Controller { - private final StoreApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private StoreApiController(Config configuration, StoreApiControllerImpInterface this.configuration = configuration; } - @ApiAction public Result deleteOrder(Http.Request request, String orderId) throws Exception { return imp.deleteOrderHttp(request, orderId); @@ -67,4 +65,5 @@ public Result placeOrder(Http.Request request) throws Exception { } return imp.placeOrderHttp(request, body); } + } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java index 5f10e1c1087c..efd481cb1861 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class StoreApiControllerImp implements StoreApiControllerImpInterface { +public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override public void deleteOrder(Http.Request request, String orderId) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java index 42b1ac676d62..809bd598a064 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java @@ -3,50 +3,67 @@ import java.util.Map; import apimodels.Order; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface StoreApiControllerImpInterface { - default Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { +public abstract class StoreApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); - return ok(); +return ok(); + } - void deleteOrder(Http.Request request, String orderId) throws Exception; + abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - default Result getInventoryHttp(Http.Request request) throws Exception { + Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Map getInventory(Http.Request request) throws Exception; + abstract Map getInventory(Http.Request request) throws Exception; - default Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + } - default Result placeOrderHttp(Http.Request request, Order body) throws Exception { + abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + + Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - Order placeOrder(Http.Request request, Order body) throws Exception; + abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java index 18c68559188b..473cd4168149 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java @@ -25,7 +25,6 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiController extends Controller { - private final UserApiControllerImpInterface imp; private final ObjectMapper mapper; private final Config configuration; @@ -37,7 +36,6 @@ private UserApiController(Config configuration, UserApiControllerImpInterface im this.configuration = configuration; } - @ApiAction public Result createUser(Http.Request request) throws Exception { JsonNode nodebody = request.body().asJson(); @@ -135,4 +133,5 @@ public Result updateUser(Http.Request request, String username) throws Exception } return imp.updateUserHttp(request, username, body); } + } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java index 6297e93df654..d14d5b540b2d 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java @@ -11,7 +11,7 @@ import java.io.FileInputStream; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") -public class UserApiControllerImp implements UserApiControllerImpInterface { +public class UserApiControllerImp extends UserApiControllerImpInterface { @Override public void createUser(Http.Request request, User body) throws Exception { //Do your magic!!! diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java index 110c0d27e9f0..bee1867d8520 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java @@ -3,74 +3,95 @@ import java.util.List; import apimodels.User; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.typesafe.config.Config; +import play.mvc.Controller; import play.mvc.Http; import java.util.List; import java.util.ArrayList; import java.util.HashMap; +import play.mvc.Result; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import openapitools.OpenAPIUtils; +import static play.mvc.Results.ok; import javax.validation.constraints.*; +@Singleton @SuppressWarnings("RedundantThrows") -public interface UserApiControllerImpInterface { - default Result createUserHttp(Http.Request request, User body) throws Exception { +public abstract class UserApiControllerImpInterface { + @Inject private Config configuration; + private ObjectMapper mapper = new ObjectMapper(); + + Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); - return ok(); +return ok(); + } - void createUser(Http.Request request, User body) throws Exception; + abstract void createUser(Http.Request request, User body) throws Exception; - default Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); - return ok(); +return ok(); + } - void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - default Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); - return ok(); +return ok(); + } - void createUsersWithListInput(Http.Request request, List body) throws Exception; + abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - default Result deleteUserHttp(Http.Request request, String username) throws Exception { + Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); - return ok(); +return ok(); + } - void deleteUser(Http.Request request, String username) throws Exception; + abstract void deleteUser(Http.Request request, String username) throws Exception; - default Result getUserByNameHttp(Http.Request request, String username) throws Exception { + Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - JsonNode result = mapper.valueToTree(obj); - return ok(result); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); } +JsonNode result = mapper.valueToTree(obj); +return ok(result); - User getUserByName(Http.Request request, String username) throws Exception; + } + + abstract User getUserByName(Http.Request request, String username) throws Exception; - default Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); - JsonNode result = mapper.valueToTree(obj); - return ok(result); +JsonNode result = mapper.valueToTree(obj); +return ok(result); + } - String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - default Result logoutUserHttp(Http.Request request) throws Exception { + Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); - return ok(); +return ok(); + } - void logoutUser(Http.Request request) throws Exception; + abstract void logoutUser(Http.Request request) throws Exception; - default Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); - return ok(); +return ok(); + } - void updateUser(Http.Request request, String username, User body) throws Exception; + abstract void updateUser(Http.Request request, String username, User body) throws Exception; } From 57f7023fdf432b3fc7a2150a482aaa70b32018e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Fri, 30 Oct 2020 14:35:57 -0400 Subject: [PATCH 3/5] New version to support play 2.8 --- .../languages/JavaPlayFrameworkCodegen.java | 4 +- .../JavaPlayFramework/apiCall.mustache | 4 +- .../JavaPlayFramework/newApi.mustache | 1 + .../newApiController.mustache | 6 +- .../newApiInterface.mustache | 9 +- .../JavaPlayFramework/plugins.mustache | 2 +- .../responseToResult.mustache | 2 +- .../puppies/store/apis/PetApiController.java | 4 +- .../store/apis/PetApiControllerImp.java | 3 +- .../apis/PetApiControllerImpInterface.java | 35 ++--- .../store/apis/StoreApiController.java | 1 + .../store/apis/StoreApiControllerImp.java | 1 + .../apis/StoreApiControllerImpInterface.java | 19 ++- .../puppies/store/apis/UserApiController.java | 1 + .../store/apis/UserApiControllerImp.java | 1 + .../apis/UserApiControllerImpInterface.java | 35 ++--- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 146 +++++++++--------- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 25 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 39 +++-- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/StoreApiController.java | 1 + .../app/controllers/UserApiController.java | 1 + .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../controllers/AnotherFakeApiController.java | 1 + .../AnotherFakeApiControllerImp.java | 1 + .../AnotherFakeApiControllerImpInterface.java | 7 +- .../app/controllers/FakeApiController.java | 4 +- .../app/controllers/FakeApiControllerImp.java | 3 +- .../FakeApiControllerImpInterface.java | 59 ++++--- .../FakeClassnameTags123ApiController.java | 1 + .../FakeClassnameTags123ApiControllerImp.java | 1 + ...snameTags123ApiControllerImpInterface.java | 7 +- .../app/controllers/PetApiController.java | 9 +- .../app/controllers/PetApiControllerImp.java | 5 +- .../PetApiControllerImpInterface.java | 39 +++-- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 19 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 35 ++--- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 34 ++-- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 18 +-- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 34 ++-- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 35 ++--- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 19 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 35 ++--- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 35 ++--- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 19 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 35 ++--- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 35 ++--- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 19 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 35 ++--- .../app/openapitools/ApiCall.java | 4 +- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 35 ++--- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 19 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 35 ++--- .../project/plugins.sbt | 2 +- .../app/controllers/PetApiController.java | 4 +- .../app/controllers/PetApiControllerImp.java | 3 +- .../PetApiControllerImpInterface.java | 35 ++--- .../app/controllers/StoreApiController.java | 1 + .../controllers/StoreApiControllerImp.java | 1 + .../StoreApiControllerImpInterface.java | 19 ++- .../app/controllers/UserApiController.java | 1 + .../app/controllers/UserApiControllerImp.java | 1 + .../UserApiControllerImpInterface.java | 35 ++--- .../app/openapitools/ApiCall.java | 4 +- .../java-play-framework/project/plugins.sbt | 2 +- 127 files changed, 641 insertions(+), 579 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java index 1cfd2e63ad93..38c06150c56e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java @@ -297,13 +297,13 @@ public Map postProcessOperationsWithModels(Map o for (CodegenParameter param : operation.allParams) { if (param.isFormParam && param.isFile) { - param.dataType = "Http.MultipartFormData.FilePart"; + param.dataType = "Http.MultipartFormData.FilePart"; } } for (CodegenParameter param : operation.formParams) { if (param.isFile) { - param.dataType = "Http.MultipartFormData.FilePart"; + param.dataType = "Http.MultipartFormData.FilePart"; } } diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache index 7f7d3f78484b..7a74f4e67162 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache index f9cc05ec295b..9236d00f63f2 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApi.mustache @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; {{#supportAsync}} import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache index 5f0e62b07160..28fc1a9da079 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; {{^handleExceptions}} import java.io.IOException; {{/handleExceptions}} @@ -127,9 +128,10 @@ public class {{classname}}Controller extends Controller { {{/queryParams}} {{#formParams}} {{#isFile}} - {{{dataType}}} {{paramName}} = request.body().asMultipartFormData().getFile("{{baseName}}"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + {{{dataType}}} {{paramName}} = body.getFile("{{baseName}}"); {{#required}} - if (({{paramName}} == null || ((File) {{paramName}}.getFile()).length() == 0)) { + if (({{paramName}} == null || {{paramName}}.getFileSize() == 0)) { throw new IllegalArgumentException("'{{baseName}}' file cannot be empty"); } {{/required}} diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache index c6af478283ac..8802c16a7be5 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiInterface.mustache @@ -4,7 +4,6 @@ package {{package}}; {{/imports}} import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; {{#supportAsync}} import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; @@ -26,9 +26,6 @@ import javax.validation.constraints.*; {{/useBeanValidation}} {{#operations}} -{{#useBeanValidation}} -@Singleton -{{/useBeanValidation}} @SuppressWarnings("RedundantThrows") public abstract class {{classname}}ControllerImpInterface { {{#useBeanValidation}} @@ -37,11 +34,11 @@ public abstract class {{classname}}ControllerImpInterface { private ObjectMapper mapper = new ObjectMapper(); {{#operation}} - {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}Http(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { + public {{#supportAsync}}CompletionStage<{{/supportAsync}}Result{{#supportAsync}}>{{/supportAsync}} {{operationId}}Http(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}} { {{>responseToResult}} } - abstract {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}}; + public abstract {{^returnType}}void{{/returnType}}{{#returnType}}{{#supportAsync}}CompletionStage<{{/supportAsync}}{{>returnTypesNoVoid}}{{#supportAsync}}>{{/supportAsync}}{{/returnType}} {{operationId}}(Http.Request request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{>pathParams}}{{>queryParams}}{{>bodyParams}}{{>formParams}}{{>headerParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#handleExceptions}}throws Exception{{/handleExceptions}}; {{/operation}} } diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/plugins.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/plugins.mustache index 23a36aef596a..318672226e33 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/plugins.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/plugins.mustache @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache index cb99d86dedd2..f4175748b888 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache @@ -53,7 +53,7 @@ return CompletableFuture.supplyAsync(() -> { {{/returnType}} {{#returnType}} {{#supportAsync}} - stage.thenApply(obj -> { +stage.thenApply(obj -> { {{/supportAsync}} {{^isResponseFile}} {{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj); diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java index cdc6d67f9313..4b24b34f2b62 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -146,7 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java index 791fd630ab89..fc544e94a8a9 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java index 7d675f11d855..04b819b64196 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,32 +16,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -54,9 +53,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -68,9 +67,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) thro } - abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + public abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -80,25 +79,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -108,6 +107,6 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java index 77901f4016ef..938275ae86ab 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java index 30c57d55a00f..a2023ed961e1 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java index ed89a347a0b6..74de37a82860 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) thro } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) throws Exception { } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java index 7afb389f01e1..4ed309b5ccbf 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java index 5457c9bb4316..f9c327a7df64 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java index 54545ead3b8d..7598a69e94e3 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) throws Exception } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-api-package-override/project/plugins.sbt b/samples/server/petstore/java-play-framework-api-package-override/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-api-package-override/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java index 86384e0c11a1..504f9cf52fd6 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -149,7 +150,8 @@ public CompletionStage uploadFile(Http.Request request, Long petId) thro } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java index a24f118c0229..840de8c10c0e 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; @@ -60,7 +61,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return CompletableFuture.supplyAsync(() -> { return new ModelApiResponse(); diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java index 22aaf8a9aa02..5c1864e46b95 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,116 +16,123 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - CompletionStage addPetHttp(Http.Request request, Pet body) throws Exception { + public CompletionStage addPetHttp(Http.Request request, Pet body) throws Exception { return CompletableFuture.supplyAsync(() -> { - addPet(request, body); - return ok(); - }); + addPet(request, body); + return ok(); +}); + } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - CompletionStage deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public CompletionStage deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { return CompletableFuture.supplyAsync(() -> { - deletePet(request, petId, apiKey); - return ok(); - }); + deletePet(request, petId, apiKey); + return ok(); +}); + } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - CompletionStage findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public CompletionStage findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { CompletionStage> stage = findPetsByStatus(request, status).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + return obj; +}); +stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); + } - abstract CompletionStage> findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract CompletionStage> findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + public CompletionStage findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { CompletionStage> stage = findPetsByTags(request, tags).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - for (Pet curItem : obj) { - OpenAPIUtils.validate(curItem); - } - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + for (Pet curItem : obj) { + OpenAPIUtils.validate(curItem); + } + } + return obj; +}); +stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); + } - abstract CompletionStage> findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + public abstract CompletionStage> findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - CompletionStage getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public CompletionStage getPetByIdHttp(Http.Request request, Long petId) throws Exception { CompletionStage stage = getPetById(request, petId).thenApply(obj -> { - if (configuration.getBoolean("useOutputBeanValidation")) { - OpenAPIUtils.validate(obj); - } - return obj; - }); - stage.thenApply(obj -> { - JsonNode result = mapper.valueToTree(obj); - return ok(result); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; +}); +stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); } - abstract CompletionStage getPetById(Http.Request request, Long petId) throws Exception; + public abstract CompletionStage getPetById(Http.Request request, Long petId) throws Exception; - CompletionStage updatePetHttp(Http.Request request, Pet body) throws Exception { + public CompletionStage updatePetHttp(Http.Request request, Pet body) throws Exception { return CompletableFuture.supplyAsync(() -> { - updatePet(request, body); - return ok(); - }); + updatePet(request, body); + return ok(); +}); + } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - CompletionStage updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public CompletionStage updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { return CompletableFuture.supplyAsync(() -> { - updatePetWithForm(request, petId, name, status); - return ok(); - }); + updatePetWithForm(request, petId, name, status); + return ok(); +}); + } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - CompletionStage uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public CompletionStage uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { CompletionStage stage = uploadFile(request, 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); - }); + if (configuration.getBoolean("useOutputBeanValidation")) { + OpenAPIUtils.validate(obj); + } + return obj; +}); +stage.thenApply(obj -> { + JsonNode result = mapper.valueToTree(obj); + return ok(result); +}); + } - abstract CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract CompletionStage uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java index 73bd6055c5c0..3ef234d8197f 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java index f24a68517350..bc81c623fe1b 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java index 32a2d8e56a87..3c59e23a74ef 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,18 +15,18 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - CompletionStage deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public CompletionStage deleteOrderHttp(Http.Request request, String orderId) throws Exception { return CompletableFuture.supplyAsync(() -> { deleteOrder(request, orderId); return ok(); @@ -35,51 +34,51 @@ CompletionStage deleteOrderHttp(Http.Request request, String orderId) th } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - CompletionStage getInventoryHttp(Http.Request request) throws Exception { + public CompletionStage getInventoryHttp(Http.Request request) throws Exception { CompletionStage> stage = getInventory(request).thenApply(obj -> { return obj; }); - stage.thenApply(obj -> { +stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); } - abstract CompletionStage> getInventory(Http.Request request) throws Exception; + public abstract CompletionStage> getInventory(Http.Request request) throws Exception; - CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public CompletionStage getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { CompletionStage stage = getOrderById(request, orderId).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); } return obj; }); - stage.thenApply(obj -> { +stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); } - abstract CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract CompletionStage getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - CompletionStage placeOrderHttp(Http.Request request, Order body) throws Exception { + public CompletionStage placeOrderHttp(Http.Request request, Order body) throws Exception { CompletionStage stage = placeOrder(request, body).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); } return obj; }); - stage.thenApply(obj -> { +stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); } - abstract CompletionStage placeOrder(Http.Request request, Order body) throws Exception; + public abstract CompletionStage placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java index 7d818ab8958e..e69c5acae5ae 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java index 0b7fc71524ce..ab320c969cf4 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java index 64c739873660..62e6468f672f 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,18 +15,18 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - CompletionStage createUserHttp(Http.Request request, User body) throws Exception { + public CompletionStage createUserHttp(Http.Request request, User body) throws Exception { return CompletableFuture.supplyAsync(() -> { createUser(request, body); return ok(); @@ -35,9 +34,9 @@ CompletionStage createUserHttp(Http.Request request, User body) throws E } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - CompletionStage createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public CompletionStage createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { return CompletableFuture.supplyAsync(() -> { createUsersWithArrayInput(request, body); return ok(); @@ -45,9 +44,9 @@ CompletionStage createUsersWithArrayInputHttp(Http.Request request, List } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - CompletionStage createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public CompletionStage createUsersWithListInputHttp(Http.Request request, List body) throws Exception { return CompletableFuture.supplyAsync(() -> { createUsersWithListInput(request, body); return ok(); @@ -55,9 +54,9 @@ CompletionStage createUsersWithListInputHttp(Http.Request request, List< } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - CompletionStage deleteUserHttp(Http.Request request, String username) throws Exception { + public CompletionStage deleteUserHttp(Http.Request request, String username) throws Exception { return CompletableFuture.supplyAsync(() -> { deleteUser(request, username); return ok(); @@ -65,38 +64,38 @@ CompletionStage deleteUserHttp(Http.Request request, String username) th } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - CompletionStage getUserByNameHttp(Http.Request request, String username) throws Exception { + public CompletionStage getUserByNameHttp(Http.Request request, String username) throws Exception { CompletionStage stage = getUserByName(request, username).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); } return obj; }); - stage.thenApply(obj -> { +stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); } - abstract CompletionStage getUserByName(Http.Request request, String username) throws Exception; + public abstract CompletionStage getUserByName(Http.Request request, String username) throws Exception; - CompletionStage loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public CompletionStage loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { CompletionStage stage = loginUser(request, username, password).thenApply(obj -> { return obj; }); - stage.thenApply(obj -> { +stage.thenApply(obj -> { JsonNode result = mapper.valueToTree(obj); return ok(result); }); } - abstract CompletionStage loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract CompletionStage loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - CompletionStage logoutUserHttp(Http.Request request) throws Exception { + public CompletionStage logoutUserHttp(Http.Request request) throws Exception { return CompletableFuture.supplyAsync(() -> { logoutUser(request); return ok(); @@ -104,9 +103,9 @@ CompletionStage logoutUserHttp(Http.Request request) throws Exception { } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - CompletionStage updateUserHttp(Http.Request request, String username, User body) throws Exception { + public CompletionStage updateUserHttp(Http.Request request, String username, User body) throws Exception { return CompletableFuture.supplyAsync(() -> { updateUser(request, username, body); return ok(); @@ -114,6 +113,6 @@ CompletionStage updateUserHttp(Http.Request request, String username, Us } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-async/project/plugins.sbt b/samples/server/petstore/java-play-framework-async/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-async/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-async/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java index 90bbaa43bf75..33f91f104b2d 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -144,7 +145,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return ok(); } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java index 09f250cfb8ab..78a5e62deb08 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java index acc7e7e6f606..8abbdf5b326b 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-controller-only/project/plugins.sbt b/samples/server/petstore/java-play-framework-controller-only/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-controller-only/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-controller-only/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java index 48824023b7c7..7d3a96cc0bd1 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiController.java @@ -14,6 +14,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java index dd33684e55de..3aa93fff1666 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImp.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class AnotherFakeApiControllerImp extends AnotherFakeApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java index be2df8205364..6be777ea58d7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/AnotherFakeApiControllerImpInterface.java @@ -3,7 +3,6 @@ import apimodels.Client; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -15,16 +14,16 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class AnotherFakeApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exception { + public Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exception { Client obj = call123testSpecialTags(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -34,6 +33,6 @@ Result call123testSpecialTagsHttp(Http.Request request, Client body) throws Exce } - abstract Client call123testSpecialTags(Http.Request request, Client body) throws Exception; + public abstract Client call123testSpecialTags(Http.Request request, Client body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java index c95771c401fa..e47e2d19ae9a 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -236,7 +237,8 @@ public Result testEndpointParameters(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'byte' parameter is required"); } - Http.MultipartFormData.FilePart binary = request.body().asMultipartFormData().getFile("binary"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart binary = body.getFile("binary"); String valuedate = (request.body().asMultipartFormData().asFormUrlEncoded().get("date"))[0]; LocalDate date; if (valuedate != null) { diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java index 553fa0b2186a..d57b5250c990 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImp.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class FakeApiControllerImp extends FakeApiControllerImpInterface { @@ -66,7 +67,7 @@ public Client testClientModel(Http.Request request, Client body) throws Exceptio } @Override - public void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { + public void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { //Do your magic!!! } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java index 4b6e9fa591cf..ae8cb9d6b06c 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiControllerImpInterface.java @@ -12,7 +12,6 @@ import apimodels.XmlItem; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -24,33 +23,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class FakeApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Exception { + public Result createXmlItemHttp(Http.Request request, XmlItem xmlItem) throws Exception { createXmlItem(request, xmlItem); return ok(); } - abstract void createXmlItem(Http.Request request, XmlItem xmlItem) throws Exception; + public abstract void createXmlItem(Http.Request request, XmlItem xmlItem) throws Exception; - Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) throws Exception { + public Result fakeOuterBooleanSerializeHttp(Http.Request request, Boolean body) throws Exception { Boolean obj = fakeOuterBooleanSerialize(request, body); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Boolean fakeOuterBooleanSerialize(Http.Request request, Boolean body) throws Exception; + public abstract Boolean fakeOuterBooleanSerialize(Http.Request request, Boolean body) throws Exception; - Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body) throws Exception { + public Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body) throws Exception { OuterComposite obj = fakeOuterCompositeSerialize(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -60,9 +59,9 @@ Result fakeOuterCompositeSerializeHttp(Http.Request request, OuterComposite body } - abstract OuterComposite fakeOuterCompositeSerialize(Http.Request request, OuterComposite body) throws Exception; + public abstract OuterComposite fakeOuterCompositeSerialize(Http.Request request, OuterComposite body) throws Exception; - Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throws Exception { + public Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throws Exception { BigDecimal obj = fakeOuterNumberSerialize(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -72,34 +71,34 @@ Result fakeOuterNumberSerializeHttp(Http.Request request, BigDecimal body) throw } - abstract BigDecimal fakeOuterNumberSerialize(Http.Request request, BigDecimal body) throws Exception; + public abstract BigDecimal fakeOuterNumberSerialize(Http.Request request, BigDecimal body) throws Exception; - Result fakeOuterStringSerializeHttp(Http.Request request, String body) throws Exception { + public Result fakeOuterStringSerializeHttp(Http.Request request, String body) throws Exception { String obj = fakeOuterStringSerialize(request, body); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String fakeOuterStringSerialize(Http.Request request, String body) throws Exception; + public abstract String fakeOuterStringSerialize(Http.Request request, String body) throws Exception; - Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestClass body) throws Exception { + public Result testBodyWithFileSchemaHttp(Http.Request request, FileSchemaTestClass body) throws Exception { testBodyWithFileSchema(request, body); return ok(); } - abstract void testBodyWithFileSchema(Http.Request request, FileSchemaTestClass body) throws Exception; + public abstract void testBodyWithFileSchema(Http.Request request, FileSchemaTestClass body) throws Exception; - Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String query, User body) throws Exception { + public Result testBodyWithQueryParamsHttp(Http.Request request, @NotNull String query, User body) throws Exception { testBodyWithQueryParams(request, query, body); return ok(); } - abstract void testBodyWithQueryParams(Http.Request request, @NotNull String query, User body) throws Exception; + public abstract void testBodyWithQueryParams(Http.Request request, @NotNull String query, User body) throws Exception; - Result testClientModelHttp(Http.Request request, Client body) throws Exception { + public Result testClientModelHttp(Http.Request request, Client body) throws Exception { Client obj = testClientModel(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -109,54 +108,54 @@ Result testClientModelHttp(Http.Request request, Client body) throws Exception { } - abstract Client testClientModel(Http.Request request, Client body) throws Exception; + public abstract Client testClientModel(Http.Request request, Client body) throws Exception; - Result testEndpointParametersHttp(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { + public Result testEndpointParametersHttp(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception { testEndpointParameters(request, number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); return ok(); } - abstract void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception; + public abstract void testEndpointParameters(Http.Request request, BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception; - Result testEnumParametersHttp(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { + public Result testEnumParametersHttp(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { testEnumParameters(request, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); return ok(); } - abstract void testEnumParameters(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception; + public abstract void testEnumParameters(Http.Request request, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception; - Result testGroupParametersHttp(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception { + public Result testGroupParametersHttp(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception { testGroupParameters(request, requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); return ok(); } - abstract void testGroupParameters(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception; + public abstract void testGroupParameters(Http.Request request, @NotNull Integer requiredStringGroup, Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws Exception; - Result testInlineAdditionalPropertiesHttp(Http.Request request, Map param) throws Exception { + public Result testInlineAdditionalPropertiesHttp(Http.Request request, Map param) throws Exception { testInlineAdditionalProperties(request, param); return ok(); } - abstract void testInlineAdditionalProperties(Http.Request request, Map param) throws Exception; + public abstract void testInlineAdditionalProperties(Http.Request request, Map param) throws Exception; - Result testJsonFormDataHttp(Http.Request request, String param, String param2) throws Exception { + public Result testJsonFormDataHttp(Http.Request request, String param, String param2) throws Exception { testJsonFormData(request, param, param2); return ok(); } - abstract void testJsonFormData(Http.Request request, String param, String param2) throws Exception; + public abstract void testJsonFormData(Http.Request request, String param, String param2) throws Exception; - Result testQueryParameterCollectionFormatHttp(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception { + public Result testQueryParameterCollectionFormatHttp(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception { testQueryParameterCollectionFormat(request, pipe, ioutil, http, url, context); return ok(); } - abstract void testQueryParameterCollectionFormat(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception; + public abstract void testQueryParameterCollectionFormat(Http.Request request, @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java index c45673f152a3..dbc96b742daa 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiController.java @@ -14,6 +14,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java index 43d76c2417ae..142ab1945db9 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImp.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class FakeClassnameTags123ApiControllerImp extends FakeClassnameTags123ApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java index 6d4ae1ec894e..b7da5f12db21 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeClassnameTags123ApiControllerImpInterface.java @@ -3,7 +3,6 @@ import apimodels.Client; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -15,16 +14,16 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class FakeClassnameTags123ApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result testClassnameHttp(Http.Request request, Client body) throws Exception { + public Result testClassnameHttp(Http.Request request, Client body) throws Exception { Client obj = testClassname(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -34,6 +33,6 @@ Result testClassnameHttp(Http.Request request, Client body) throws Exception { } - abstract Client testClassname(Http.Request request, Client body) throws Exception; + public abstract Client testClassname(Http.Request request, Client body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java index 3cc2768b31ab..dbaa7848466d 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -147,7 +148,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } @@ -160,8 +162,9 @@ public Result uploadFileWithRequiredFile(Http.Request request, Long petId) throw } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart requiredFile = request.body().asMultipartFormData().getFile("requiredFile"); - if ((requiredFile == null || ((File) requiredFile.getFile()).length() == 0)) { + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart requiredFile = body.getFile("requiredFile"); + if ((requiredFile == null || requiredFile.getFileSize() == 0)) { throw new IllegalArgumentException("'requiredFile' file cannot be empty"); } return imp.uploadFileWithRequiredFileHttp(request, petId, requiredFile, additionalMetadata); diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java index a9e517ce2a7e..990bbda51519 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImp.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -53,13 +54,13 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } @Override - public ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { + public ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java index ec9bd2c22267..537ce582ac22 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiControllerImpInterface.java @@ -6,7 +6,6 @@ import java.util.Set; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -18,32 +17,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -55,9 +54,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throws Exception { Set obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -69,9 +68,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull Set tags) throw } - abstract Set findPetsByTags(Http.Request request, @NotNull Set tags) throws Exception; + public abstract Set findPetsByTags(Http.Request request, @NotNull Set tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -81,25 +80,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -109,9 +108,9 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; - Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { + public Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception { ModelApiResponse obj = uploadFileWithRequiredFile(request, petId, requiredFile, additionalMetadata); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -121,6 +120,6 @@ Result uploadFileWithRequiredFileHttp(Http.Request request, Long petId, Http.Mul } - abstract ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception; + public abstract ModelApiResponse uploadFileWithRequiredFile(Http.Request request, Long petId, Http.MultipartFormData.FilePart requiredFile, String additionalMetadata) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java index b4334fb6cba7..c8734ebe8ea3 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java index efd481cb1861..1715aeba67c6 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java index 809bd598a064..2d15d750c2ca 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) thro } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) throws Exception { } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java index 473cd4168149..22e303ad3fe7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java index d14d5b540b2d..267c4636db86 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java index bee1867d8520..e1f0e030b1c8 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) throws Exception } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/project/plugins.sbt b/samples/server/petstore/java-play-framework-fake-endpoints/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-fake-endpoints/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java index fa926e3ef97c..40d7dd68e9a5 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -136,7 +137,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java index 1a209419a7ba..f368184ed7c9 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @Override @@ -51,7 +52,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java index 9c2317cecc70..f004f765d734 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,78 +16,79 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, List status) throws Exception { List obj = findPetsByStatus(request, status); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract List findPetsByStatus(Http.Request request, List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, List tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, List tags) throws Exception { List obj = findPetsByTags(request, tags); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract List findPetsByTags(Http.Request request, List tags) throws Exception; + public abstract List findPetsByTags(Http.Request request, List tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java index be0d131d2891..b7f19acfb5a7 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java index dd3a261926ab..fe1818353526 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { @Override diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java index 1ad9a149b983..8f5156786730 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,45 +15,46 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, Long orderId) throws Exception { Order obj = getOrderById(request, orderId); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Order getOrderById(Http.Request request, Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java index 163d72c70cfe..0aa5d8580ea9 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java index 925fbf30b9ef..be409ef3526b 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { @Override diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java index b23132d3425b..ac972fe05d89 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,76 +15,77 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, String username, String password) throws Exception { + public Result loginUserHttp(Http.Request request, String username, String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, String username, String password) throws Exception; + public abstract String loginUser(Http.Request request, String username, String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/project/plugins.sbt b/samples/server/petstore/java-play-framework-no-bean-validation/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-no-bean-validation/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java index 4c57a2913489..96b3dec08727 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import java.io.IOException; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -147,7 +148,8 @@ public Result uploadFile(Http.Request request, Long petId) { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java index b2bcacdd852d..2657785e743c 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java index 563094963e9d..df09f44ef894 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,32 +16,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) { + public Result addPetHttp(Http.Request request, Pet body) { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) ; + public abstract void addPet(Http.Request request, Pet body) ; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) ; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) ; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -54,9 +53,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) ; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) ; - Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { + public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { List obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -68,9 +67,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) { } - abstract List findPetsByTags(Http.Request request, @NotNull List tags) ; + public abstract List findPetsByTags(Http.Request request, @NotNull List tags) ; - Result getPetByIdHttp(Http.Request request, Long petId) { + public Result getPetByIdHttp(Http.Request request, Long petId) { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -80,25 +79,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) { } - abstract Pet getPetById(Http.Request request, Long petId) ; + public abstract Pet getPetById(Http.Request request, Long petId) ; - Result updatePetHttp(Http.Request request, Pet body) { + public Result updatePetHttp(Http.Request request, Pet body) { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) ; + public abstract void updatePet(Http.Request request, Pet body) ; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) ; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) ; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -108,6 +107,6 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) ; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java index 82ce1deb243c..9fb9ce6fd4ad 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import java.io.IOException; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java index d8d630ca42c1..c9c4f5b2d4ae 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java index 6fcb5c6e66b6..54e3aa358ce1 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) { + public Result deleteOrderHttp(Http.Request request, String orderId) { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) ; + public abstract void deleteOrder(Http.Request request, String orderId) ; - Result getInventoryHttp(Http.Request request) { + public Result getInventoryHttp(Http.Request request) { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) ; + public abstract Map getInventory(Http.Request request) ; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) { } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) ; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) ; - Result placeOrderHttp(Http.Request request, Order body) { + public Result placeOrderHttp(Http.Request request, Order body) { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) { } - abstract Order placeOrder(Http.Request request, Order body) ; + public abstract Order placeOrder(Http.Request request, Order body) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java index e9ab364be959..177eb4c00002 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import java.io.IOException; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java index f938ee7d19d9..591e2971e51d 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java index b86a27cfd6f1..84b3ee88addd 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) { + public Result createUserHttp(Http.Request request, User body) { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) ; + public abstract void createUser(Http.Request request, User body) ; - Result createUsersWithArrayInputHttp(Http.Request request, List body) { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) ; + public abstract void createUsersWithArrayInput(Http.Request request, List body) ; - Result createUsersWithListInputHttp(Http.Request request, List body) { + public Result createUsersWithListInputHttp(Http.Request request, List body) { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) ; + public abstract void createUsersWithListInput(Http.Request request, List body) ; - Result deleteUserHttp(Http.Request request, String username) { + public Result deleteUserHttp(Http.Request request, String username) { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) ; + public abstract void deleteUser(Http.Request request, String username) ; - Result getUserByNameHttp(Http.Request request, String username) { + public Result getUserByNameHttp(Http.Request request, String username) { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) { } - abstract User getUserByName(Http.Request request, String username) ; + public abstract User getUserByName(Http.Request request, String username) ; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) ; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) ; - Result logoutUserHttp(Http.Request request) { + public Result logoutUserHttp(Http.Request request) { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) ; + public abstract void logoutUser(Http.Request request) ; - Result updateUserHttp(Http.Request request, String username, User body) { + public Result updateUserHttp(Http.Request request, String username, User body) { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) ; + public abstract void updateUser(Http.Request request, String username, User body) ; } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/project/plugins.sbt b/samples/server/petstore/java-play-framework-no-exception-handling/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-no-exception-handling/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java index 656f63b6723a..42b66b0084f7 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -176,7 +177,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiControllerImp.java index 3ef89adebbf7..6f84547fbd40 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java index fa9b041347bd..4d8f7fb8f7a0 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiControllerImp.java index 843796289264..f531e3267e83 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp { diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java index 2300d02e2b87..31db7bd333ce 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiControllerImp.java index 93ecadd555e5..0c7ef76b2c8d 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp { diff --git a/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-no-interface/project/plugins.sbt b/samples/server/petstore/java-play-framework-no-interface/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-no-interface/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-no-interface/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java index 07abcaa84b3b..2e121c19ef1c 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -146,7 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java index 62dc0bcdbc73..6686efa026c4 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java index 11f5c78c385c..d1d2d9eb73a8 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,32 +16,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -54,9 +53,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -68,9 +67,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) thro } - abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + public abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -80,25 +79,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -108,6 +107,6 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java index b4334fb6cba7..c8734ebe8ea3 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java index efd481cb1861..1715aeba67c6 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java index 809bd598a064..2d15d750c2ca 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) thro } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) throws Exception { } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java index 473cd4168149..22e303ad3fe7 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java index d14d5b540b2d..267c4636db86 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java index bee1867d8520..e1f0e030b1c8 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) throws Exception } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-no-nullable/project/plugins.sbt b/samples/server/petstore/java-play-framework-no-nullable/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-no-nullable/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java index 07abcaa84b3b..2e121c19ef1c 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -146,7 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java index 62dc0bcdbc73..6686efa026c4 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java index 11f5c78c385c..d1d2d9eb73a8 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,32 +16,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -54,9 +53,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -68,9 +67,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) thro } - abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + public abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -80,25 +79,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -108,6 +107,6 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java index b4334fb6cba7..c8734ebe8ea3 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java index efd481cb1861..1715aeba67c6 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java index 809bd598a064..2d15d750c2ca 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) thro } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) throws Exception { } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java index 473cd4168149..22e303ad3fe7 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java index d14d5b540b2d..267c4636db86 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java index bee1867d8520..e1f0e030b1c8 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) throws Exception } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/project/plugins.sbt b/samples/server/petstore/java-play-framework-no-swagger-ui/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java index f7462991ab98..df85dc2e7861 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -145,7 +146,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java index 62dc0bcdbc73..6686efa026c4 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java index 11f5c78c385c..d1d2d9eb73a8 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,32 +16,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -54,9 +53,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -68,9 +67,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) thro } - abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + public abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -80,25 +79,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -108,6 +107,6 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java index 59977ab01482..2243e9dc58d8 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java index efd481cb1861..1715aeba67c6 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java index 809bd598a064..2d15d750c2ca 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) thro } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) throws Exception { } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java index 218ff716e276..731fc1361550 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java index d14d5b540b2d..267c4636db86 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java index bee1867d8520..e1f0e030b1c8 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) throws Exception } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/project/plugins.sbt b/samples/server/petstore/java-play-framework-no-wrap-calls/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java index 07abcaa84b3b..2e121c19ef1c 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; @@ -146,7 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData.FilePart file = request.body().asMultipartFormData().getFile("file"); + Http.MultipartFormData body = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = body.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java index 62dc0bcdbc73..6686efa026c4 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImp.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class PetApiControllerImp extends PetApiControllerImpInterface { @@ -52,7 +53,7 @@ public void updatePetWithForm(Http.Request request, Long petId, String name, Str } @Override - public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { //Do your magic!!! return new ModelApiResponse(); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java index 11f5c78c385c..d1d2d9eb73a8 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiControllerImpInterface.java @@ -5,7 +5,6 @@ import apimodels.Pet; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -17,32 +16,32 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class PetApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result addPetHttp(Http.Request request, Pet body) throws Exception { + public Result addPetHttp(Http.Request request, Pet body) throws Exception { addPet(request, body); return ok(); } - abstract void addPet(Http.Request request, Pet body) throws Exception; + public abstract void addPet(Http.Request request, Pet body) throws Exception; - Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { + public Result deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception { deletePet(request, petId, apiKey); return ok(); } - abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; + public abstract void deletePet(Http.Request request, Long petId, String apiKey) throws Exception; - Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { + public Result findPetsByStatusHttp(Http.Request request, @NotNull List status) throws Exception { List obj = findPetsByStatus(request, status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -54,9 +53,9 @@ Result findPetsByStatusHttp(Http.Request request, @NotNull List status) } - abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; + public abstract List findPetsByStatus(Http.Request request, @NotNull List status) throws Exception; - Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { + public Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) throws Exception { List obj = findPetsByTags(request, tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { @@ -68,9 +67,9 @@ Result findPetsByTagsHttp(Http.Request request, @NotNull List tags) thro } - abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; + public abstract List findPetsByTags(Http.Request request, @NotNull List tags) throws Exception; - Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { + public Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { Pet obj = getPetById(request, petId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -80,25 +79,25 @@ Result getPetByIdHttp(Http.Request request, Long petId) throws Exception { } - abstract Pet getPetById(Http.Request request, Long petId) throws Exception; + public abstract Pet getPetById(Http.Request request, Long petId) throws Exception; - Result updatePetHttp(Http.Request request, Pet body) throws Exception { + public Result updatePetHttp(Http.Request request, Pet body) throws Exception { updatePet(request, body); return ok(); } - abstract void updatePet(Http.Request request, Pet body) throws Exception; + public abstract void updatePet(Http.Request request, Pet body) throws Exception; - Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { + public Result updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception { updatePetWithForm(request, petId, name, status); return ok(); } - abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; + public abstract void updatePetWithForm(Http.Request request, Long petId, String name, String status) throws Exception; - Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { + public Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception { ModelApiResponse obj = uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -108,6 +107,6 @@ Result uploadFileHttp(Http.Request request, Long petId, String additionalMetadat } - abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; + public abstract ModelApiResponse uploadFile(Http.Request request, Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java index b4334fb6cba7..c8734ebe8ea3 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java index efd481cb1861..1715aeba67c6 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class StoreApiControllerImp extends StoreApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java index 809bd598a064..2d15d750c2ca 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.Order; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,33 +15,33 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class StoreApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { + public Result deleteOrderHttp(Http.Request request, String orderId) throws Exception { deleteOrder(request, orderId); return ok(); } - abstract void deleteOrder(Http.Request request, String orderId) throws Exception; + public abstract void deleteOrder(Http.Request request, String orderId) throws Exception; - Result getInventoryHttp(Http.Request request) throws Exception { + public Result getInventoryHttp(Http.Request request) throws Exception { Map obj = getInventory(request); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract Map getInventory(Http.Request request) throws Exception; + public abstract Map getInventory(Http.Request request) throws Exception; - Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { + public Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception { Order obj = getOrderById(request, orderId); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -52,9 +51,9 @@ Result getOrderByIdHttp(Http.Request request, @Min(1) @Max(5)Long orderId) thro } - abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; + public abstract Order getOrderById(Http.Request request, @Min(1) @Max(5)Long orderId) throws Exception; - Result placeOrderHttp(Http.Request request, Order body) throws Exception { + public Result placeOrderHttp(Http.Request request, Order body) throws Exception { Order obj = placeOrder(request, body); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -64,6 +63,6 @@ Result placeOrderHttp(Http.Request request, Order body) throws Exception { } - abstract Order placeOrder(Http.Request request, Order body) throws Exception; + public abstract Order placeOrder(Http.Request request, Order body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java index 473cd4168149..22e303ad3fe7 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; +import play.api.libs.Files.TemporaryFile; import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java index d14d5b540b2d..267c4636db86 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImp.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.io.FileInputStream; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaPlayFrameworkCodegen") public class UserApiControllerImp extends UserApiControllerImpInterface { diff --git a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java index bee1867d8520..e1f0e030b1c8 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiControllerImpInterface.java @@ -4,7 +4,6 @@ import apimodels.User; import com.google.inject.Inject; -import com.google.inject.Singleton; import com.typesafe.config.Config; import play.mvc.Controller; import play.mvc.Http; @@ -16,48 +15,48 @@ import com.fasterxml.jackson.databind.JsonNode; import openapitools.OpenAPIUtils; import static play.mvc.Results.ok; +import play.api.libs.Files.TemporaryFile; import javax.validation.constraints.*; -@Singleton @SuppressWarnings("RedundantThrows") public abstract class UserApiControllerImpInterface { @Inject private Config configuration; private ObjectMapper mapper = new ObjectMapper(); - Result createUserHttp(Http.Request request, User body) throws Exception { + public Result createUserHttp(Http.Request request, User body) throws Exception { createUser(request, body); return ok(); } - abstract void createUser(Http.Request request, User body) throws Exception; + public abstract void createUser(Http.Request request, User body) throws Exception; - Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithArrayInputHttp(Http.Request request, List body) throws Exception { createUsersWithArrayInput(request, body); return ok(); } - abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithArrayInput(Http.Request request, List body) throws Exception; - Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { + public Result createUsersWithListInputHttp(Http.Request request, List body) throws Exception { createUsersWithListInput(request, body); return ok(); } - abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; + public abstract void createUsersWithListInput(Http.Request request, List body) throws Exception; - Result deleteUserHttp(Http.Request request, String username) throws Exception { + public Result deleteUserHttp(Http.Request request, String username) throws Exception { deleteUser(request, username); return ok(); } - abstract void deleteUser(Http.Request request, String username) throws Exception; + public abstract void deleteUser(Http.Request request, String username) throws Exception; - Result getUserByNameHttp(Http.Request request, String username) throws Exception { + public Result getUserByNameHttp(Http.Request request, String username) throws Exception { User obj = getUserByName(request, username); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); @@ -67,31 +66,31 @@ Result getUserByNameHttp(Http.Request request, String username) throws Exception } - abstract User getUserByName(Http.Request request, String username) throws Exception; + public abstract User getUserByName(Http.Request request, String username) throws Exception; - Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { + public Result loginUserHttp(Http.Request request, @NotNull String username, @NotNull String password) throws Exception { String obj = loginUser(request, username, password); JsonNode result = mapper.valueToTree(obj); return ok(result); } - abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; + public abstract String loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception; - Result logoutUserHttp(Http.Request request) throws Exception { + public Result logoutUserHttp(Http.Request request) throws Exception { logoutUser(request); return ok(); } - abstract void logoutUser(Http.Request request) throws Exception; + public abstract void logoutUser(Http.Request request) throws Exception; - Result updateUserHttp(Http.Request request, String username, User body) throws Exception { + public Result updateUserHttp(Http.Request request, String username, User body) throws Exception { updateUser(request, username, body); return ok(); } - abstract void updateUser(Http.Request request, String username, User body) throws Exception; + public abstract void updateUser(Http.Request request, String username, User body) throws Exception; } diff --git a/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java index 7f7d3f78484b..7a74f4e67162 100644 --- a/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java +++ b/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java @@ -13,10 +13,10 @@ public class ApiCall extends Action { @Inject private ApiCall() {} - public CompletionStage call(Http.Context ctx) { + public CompletionStage call(Http.Request request) { try { //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); + return delegate.call(request); } catch (Throwable t) { //TODO: log the error in your metric diff --git a/samples/server/petstore/java-play-framework/project/plugins.sbt b/samples/server/petstore/java-play-framework/project/plugins.sbt index 23a36aef596a..318672226e33 100644 --- a/samples/server/petstore/java-play-framework/project/plugins.sbt +++ b/samples/server/petstore/java-play-framework/project/plugins.sbt @@ -1,2 +1,2 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") \ No newline at end of file +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") \ No newline at end of file From 8abedaf6defcdbe11b340c111c9385ad6af66ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Mon, 2 Nov 2020 10:02:23 -0500 Subject: [PATCH 4/5] Fix conflict --- .../JavaPlayFramework/responseToResult.mustache | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache index f4175748b888..1ffc3bbe73b7 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/responseToResult.mustache @@ -11,16 +11,16 @@ return CompletableFuture.supplyAsync(() -> { {{#useBeanValidation}} {{^supportAsync}} if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isListContainer}} + {{#isArray}} for ({{{returnType}}} curItem : obj) { OpenAPIUtils.validate(curItem); } - {{/isListContainer}} - {{#isMapContainer}} + {{/isArray}} + {{#isMap}} for (Map.Entry entry : obj.entrySet()) { OpenAPIUtils.validate(entry.getValue()); } - {{/isMapContainer}} + {{/isMap}} {{^returnContainer}} OpenAPIUtils.validate(obj); {{/returnContainer}} @@ -28,16 +28,16 @@ return CompletableFuture.supplyAsync(() -> { {{/supportAsync}} {{#supportAsync}} if (configuration.getBoolean("useOutputBeanValidation")) { - {{#isListContainer}} + {{#isArray}} for ({{{returnType}}} curItem : obj) { OpenAPIUtils.validate(curItem); } - {{/isListContainer}} - {{#isMapContainer}} + {{/isArray}} + {{#isMap}} for (Map.Entry entry : obj.entrySet()) { OpenAPIUtils.validate(entry.getValue()); } - {{/isMapContainer}} + {{/isMap}} {{^returnContainer}} OpenAPIUtils.validate(obj); {{/returnContainer}} From 12d56e3a92b9bd22d57c7898def65c3c530402b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Mon, 2 Nov 2020 14:47:50 -0500 Subject: [PATCH 5/5] Fix error when multiple file in forms --- .../resources/JavaPlayFramework/newApiController.mustache | 4 ++-- .../app/com/puppies/store/apis/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/FakeApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 8 ++++---- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- .../app/controllers/PetApiController.java | 4 ++-- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache index ce4d52fbbf13..277751a30840 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/newApiController.mustache @@ -128,8 +128,8 @@ public class {{classname}}Controller extends Controller { {{/queryParams}} {{#formParams}} {{#isFile}} - Http.MultipartFormData body = request.body().asMultipartFormData(); - {{{dataType}}} {{paramName}} = body.getFile("{{baseName}}"); + Http.MultipartFormData body{{paramName}} = request.body().asMultipartFormData(); + {{{dataType}}} {{paramName}} = body{{paramName}}.getFile("{{baseName}}"); {{#required}} if (({{paramName}} == null || {{paramName}}.getFileSize() == 0)) { throw new IllegalArgumentException("'{{baseName}}' file cannot be empty"); diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java index 4b24b34f2b62..bf698553c72c 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/com/puppies/store/apis/PetApiController.java @@ -147,8 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java index 504f9cf52fd6..e319357a0dad 100644 --- a/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-async/app/controllers/PetApiController.java @@ -150,8 +150,8 @@ public CompletionStage uploadFile(Http.Request request, Long petId) thro } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java index 33f91f104b2d..9d3581ada51c 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/controllers/PetApiController.java @@ -145,8 +145,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return ok(); } diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java index e47e2d19ae9a..2009aaef9890 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/FakeApiController.java @@ -237,8 +237,8 @@ public Result testEndpointParameters(Http.Request request) throws Exception { } else { throw new IllegalArgumentException("'byte' parameter is required"); } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart binary = body.getFile("binary"); + Http.MultipartFormData bodybinary = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart binary = bodybinary.getFile("binary"); String valuedate = (request.body().asMultipartFormData().asFormUrlEncoded().get("date"))[0]; LocalDate date; if (valuedate != null) { diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java index dbaa7848466d..19a05c08f8c1 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/controllers/PetApiController.java @@ -148,8 +148,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } @@ -162,8 +162,8 @@ public Result uploadFileWithRequiredFile(Http.Request request, Long petId) throw } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart requiredFile = body.getFile("requiredFile"); + Http.MultipartFormData bodyrequiredFile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart requiredFile = bodyrequiredFile.getFile("requiredFile"); if ((requiredFile == null || requiredFile.getFileSize() == 0)) { throw new IllegalArgumentException("'requiredFile' file cannot be empty"); } diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java index 40d7dd68e9a5..08339f1c5794 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/controllers/PetApiController.java @@ -137,8 +137,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java index 96b3dec08727..80bdb1834f15 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/controllers/PetApiController.java @@ -148,8 +148,8 @@ public Result uploadFile(Http.Request request, Long petId) { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java index 42b66b0084f7..bff360b2ad9e 100644 --- a/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-interface/app/controllers/PetApiController.java @@ -177,8 +177,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); ModelApiResponse obj = imp.uploadFile(request, petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { OpenAPIUtils.validate(obj); diff --git a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java index 2e121c19ef1c..ddf45c00f584 100644 --- a/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-nullable/app/controllers/PetApiController.java @@ -147,8 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java index 2e121c19ef1c..ddf45c00f584 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/controllers/PetApiController.java @@ -147,8 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java index df85dc2e7861..283df7f591b9 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/controllers/PetApiController.java @@ -146,8 +146,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); } diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java index 2e121c19ef1c..ddf45c00f584 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -147,8 +147,8 @@ public Result uploadFile(Http.Request request, Long petId) throws Exception { } else { additionalMetadata = null; } - Http.MultipartFormData body = request.body().asMultipartFormData(); - Http.MultipartFormData.FilePart file = body.getFile("file"); + Http.MultipartFormData bodyfile = request.body().asMultipartFormData(); + Http.MultipartFormData.FilePart file = bodyfile.getFile("file"); return imp.uploadFileHttp(request, petId, additionalMetadata, file); }