diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache index fdb6e797ad0..7f7d3f78484 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/apiCall.mustache @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import com.google.inject.Inject; import play.mvc.Action; diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/errorHandler.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/errorHandler.mustache index 2c813411a5e..cee7a1c4308 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/errorHandler.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/errorHandler.mustache @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.*; diff --git a/modules/openapi-generator/src/main/resources/JavaPlayFramework/openapiUtils.mustache b/modules/openapi-generator/src/main/resources/JavaPlayFramework/openapiUtils.mustache index 81042ff7c6e..24091812020 100644 --- a/modules/openapi-generator/src/main/resources/JavaPlayFramework/openapiUtils.mustache +++ b/modules/openapi-generator/src/main/resources/JavaPlayFramework/openapiUtils.mustache @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; 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 58a1a9af755..7932fea7b2a 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -44,7 +44,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -72,7 +72,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -83,7 +83,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -96,7 +96,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -107,7 +107,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -118,7 +118,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -131,7 +131,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -172,7 +172,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 497847a698b..2aaae94f8df 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -53,7 +53,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -66,14 +66,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 7710d81ea2e..8190c6f6f6a 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -43,7 +43,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -60,7 +60,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -78,7 +78,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -98,7 +98,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -138,7 +138,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java similarity index 88% rename from samples/server/petstore/java-play-framework-api-package-override/app/swagger/ApiCall.java rename to samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java index 2ca308045b6..7f7d3f78484 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/swagger/ApiCall.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ApiCall.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import com.google.inject.Inject; import play.mvc.Action; @@ -8,7 +8,7 @@ import play.mvc.Result; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -public class ApiCall extends Action { +public class ApiCall extends Action { @Inject private ApiCall() {} diff --git a/samples/server/petstore/java-play-framework-async/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ErrorHandler.java similarity index 98% rename from samples/server/petstore/java-play-framework-async/app/swagger/ErrorHandler.java rename to samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ErrorHandler.java index 2c813411a5e..cee7a1c4308 100644 --- a/samples/server/petstore/java-play-framework-async/app/swagger/ErrorHandler.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/ErrorHandler.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.*; diff --git a/samples/server/petstore/java-play-framework-async/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/OpenAPIUtils.java similarity index 98% rename from samples/server/petstore/java-play-framework-async/app/swagger/SwaggerUtils.java rename to samples/server/petstore/java-play-framework-api-package-override/app/openapitools/OpenAPIUtils.java index d4900e02167..c707ca74ac7 100644 --- a/samples/server/petstore/java-play-framework-async/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-api-package-override/app/openapitools/OpenAPIUtils.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; @@ -14,7 +14,7 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -public class SwaggerUtils { +public class OpenAPIUtils { @With(ApiCall.class) @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/samples/server/petstore/java-play-framework-api-package-override/conf/application.conf b/samples/server/petstore/java-play-framework-api-package-override/conf/application.conf index bcd07672dc1..fcc5c0499a2 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/conf/application.conf +++ b/samples/server/petstore/java-play-framework-api-package-override/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-async/public/swagger.json b/samples/server/petstore/java-play-framework-api-package-override/public/openapi.json similarity index 99% rename from samples/server/petstore/java-play-framework-async/public/swagger.json rename to samples/server/petstore/java-play-framework-api-package-override/public/openapi.json index 01499dcfd25..085c36fa397 100644 --- a/samples/server/petstore/java-play-framework-async/public/swagger.json +++ b/samples/server/petstore/java-play-framework-api-package-override/public/openapi.json @@ -1017,7 +1017,12 @@ "type" : "string" } }, - "description" : "Describes the result of uploading an image resource" + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } } }, "securitySchemes" : { 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 c0d089023ec..0dd34c6888f 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 @@ -14,7 +14,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.concurrent.CompletionStage; @@ -23,7 +23,7 @@ import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -47,7 +47,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -79,7 +79,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -90,7 +90,7 @@ public class PetApiController extends Controller { CompletionStage> stage = imp.findPetsByStatus(status).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } return obj; @@ -107,7 +107,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -118,7 +118,7 @@ public class PetApiController extends Controller { CompletionStage> stage = imp.findPetsByTags(tags).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } return obj; @@ -133,7 +133,7 @@ public class PetApiController extends Controller { public CompletionStage getPetById(Long petId) throws Exception { CompletionStage stage = imp.getPetById(petId).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } return obj; }); @@ -150,7 +150,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -195,7 +195,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); CompletionStage stage = imp.uploadFile(petId, additionalMetadata, file).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } return obj; }); 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 daf1bc417b8..9c112f2e9d6 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 @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.concurrent.CompletionStage; @@ -22,7 +22,7 @@ import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -62,7 +62,7 @@ public class StoreApiController extends Controller { public CompletionStage getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { CompletionStage stage = imp.getOrderById(orderId).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } return obj; }); @@ -79,14 +79,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } CompletionStage stage = imp.placeOrder(order).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } return obj; }); 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 a9dd74dd4fa..35c1134b0f4 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 @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.concurrent.CompletionStage; @@ -22,7 +22,7 @@ import java.util.concurrent.CompletableFuture; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -46,7 +46,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -65,7 +65,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -85,7 +85,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -109,7 +109,7 @@ public class UserApiController extends Controller { public CompletionStage getUserByName(String username) throws Exception { CompletionStage stage = imp.getUserByName(username).thenApply(obj -> { if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } return obj; }); @@ -159,7 +159,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); diff --git a/samples/server/petstore/java-play-framework-async/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java similarity index 88% rename from samples/server/petstore/java-play-framework-async/app/swagger/ApiCall.java rename to samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java index 2ca308045b6..7f7d3f78484 100644 --- a/samples/server/petstore/java-play-framework-async/app/swagger/ApiCall.java +++ b/samples/server/petstore/java-play-framework-async/app/openapitools/ApiCall.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import com.google.inject.Inject; import play.mvc.Action; @@ -8,7 +8,7 @@ import play.mvc.Result; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -public class ApiCall extends Action { +public class ApiCall extends Action { @Inject private ApiCall() {} diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-async/app/openapitools/ErrorHandler.java similarity index 98% rename from samples/server/petstore/java-play-framework-api-package-override/app/swagger/ErrorHandler.java rename to samples/server/petstore/java-play-framework-async/app/openapitools/ErrorHandler.java index 2c813411a5e..cee7a1c4308 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/swagger/ErrorHandler.java +++ b/samples/server/petstore/java-play-framework-async/app/openapitools/ErrorHandler.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.*; diff --git a/samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-async/app/openapitools/OpenAPIUtils.java similarity index 98% rename from samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java rename to samples/server/petstore/java-play-framework-async/app/openapitools/OpenAPIUtils.java index d4900e02167..c707ca74ac7 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-async/app/openapitools/OpenAPIUtils.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; @@ -14,7 +14,7 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -public class SwaggerUtils { +public class OpenAPIUtils { @With(ApiCall.class) @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/samples/server/petstore/java-play-framework-async/conf/application.conf b/samples/server/petstore/java-play-framework-async/conf/application.conf index bcd07672dc1..fcc5c0499a2 100644 --- a/samples/server/petstore/java-play-framework-async/conf/application.conf +++ b/samples/server/petstore/java-play-framework-async/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-controller-only/public/swagger.json b/samples/server/petstore/java-play-framework-async/public/openapi.json similarity index 99% rename from samples/server/petstore/java-play-framework-controller-only/public/swagger.json rename to samples/server/petstore/java-play-framework-async/public/openapi.json index 01499dcfd25..085c36fa397 100644 --- a/samples/server/petstore/java-play-framework-controller-only/public/swagger.json +++ b/samples/server/petstore/java-play-framework-async/public/openapi.json @@ -1017,7 +1017,12 @@ "type" : "string" } }, - "description" : "Describes the result of uploading an image resource" + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } } }, "securitySchemes" : { 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 e5082ae7acf..916fd313b61 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -42,7 +42,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -68,7 +68,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -85,7 +85,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -108,7 +108,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); 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 a7320a1c734..928173a5b55 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -56,7 +56,7 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); 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 a905c7d9c8e..58bebfd7e1e 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -41,7 +41,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -57,7 +57,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -74,7 +74,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -124,7 +124,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); diff --git a/samples/server/petstore/java-play-framework-controller-only/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java similarity index 88% rename from samples/server/petstore/java-play-framework-controller-only/app/swagger/ApiCall.java rename to samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java index 2ca308045b6..7f7d3f78484 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/swagger/ApiCall.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ApiCall.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import com.google.inject.Inject; import play.mvc.Action; @@ -8,7 +8,7 @@ import play.mvc.Result; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -public class ApiCall extends Action { +public class ApiCall extends Action { @Inject private ApiCall() {} diff --git a/samples/server/petstore/java-play-framework-controller-only/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ErrorHandler.java similarity index 98% rename from samples/server/petstore/java-play-framework-controller-only/app/swagger/ErrorHandler.java rename to samples/server/petstore/java-play-framework-controller-only/app/openapitools/ErrorHandler.java index 2c813411a5e..cee7a1c4308 100644 --- a/samples/server/petstore/java-play-framework-controller-only/app/swagger/ErrorHandler.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/ErrorHandler.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.*; diff --git a/samples/server/petstore/java-play-framework-api-package-override/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/OpenAPIUtils.java similarity index 98% rename from samples/server/petstore/java-play-framework-api-package-override/app/swagger/SwaggerUtils.java rename to samples/server/petstore/java-play-framework-controller-only/app/openapitools/OpenAPIUtils.java index d4900e02167..c707ca74ac7 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-controller-only/app/openapitools/OpenAPIUtils.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; @@ -14,7 +14,7 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -public class SwaggerUtils { +public class OpenAPIUtils { @With(ApiCall.class) @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/samples/server/petstore/java-play-framework-controller-only/conf/application.conf b/samples/server/petstore/java-play-framework-controller-only/conf/application.conf index a6680d1c487..ffb628cd848 100644 --- a/samples/server/petstore/java-play-framework-controller-only/conf/application.conf +++ b/samples/server/petstore/java-play-framework-controller-only/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/public/swagger.json b/samples/server/petstore/java-play-framework-controller-only/public/openapi.json similarity index 99% rename from samples/server/petstore/java-play-framework-no-bean-validation/public/swagger.json rename to samples/server/petstore/java-play-framework-controller-only/public/openapi.json index 01499dcfd25..085c36fa397 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/public/swagger.json +++ b/samples/server/petstore/java-play-framework-controller-only/public/openapi.json @@ -1017,7 +1017,12 @@ "type" : "string" } }, - "description" : "Describes the result of uploading an image resource" + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } } }, "securitySchemes" : { 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 5c541575d0a..3056c5a319a 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 @@ -12,13 +12,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class AnotherFakeApiController extends Controller { @@ -42,14 +42,14 @@ public class AnotherFakeApiController extends Controller { if (nodeclient != null) { client = mapper.readValue(nodeclient.toString(), Client.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(client); + OpenAPIUtils.validate(client); } } else { throw new IllegalArgumentException("'Client' parameter is required"); } Client obj = imp.testSpecialTags(client); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 ef66b9b0dda..81e00479c36 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 @@ -19,13 +19,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class FakeApiController extends Controller { @@ -49,7 +49,7 @@ public class FakeApiController extends Controller { if (nodebody != null) { body = mapper.readValue(nodebody.toString(), Boolean.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(body); + OpenAPIUtils.validate(body); } } else { body = null; @@ -66,14 +66,14 @@ public class FakeApiController extends Controller { if (nodeouterComposite != null) { outerComposite = mapper.readValue(nodeouterComposite.toString(), OuterComposite.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(outerComposite); + OpenAPIUtils.validate(outerComposite); } } else { outerComposite = null; } OuterComposite obj = imp.fakeOuterCompositeSerialize(outerComposite); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -86,14 +86,14 @@ public class FakeApiController extends Controller { if (nodebody != null) { body = mapper.readValue(nodebody.toString(), BigDecimal.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(body); + OpenAPIUtils.validate(body); } } else { body = null; } BigDecimal obj = imp.fakeOuterNumberSerialize(body); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -106,7 +106,7 @@ public class FakeApiController extends Controller { if (nodebody != null) { body = mapper.readValue(nodebody.toString(), String.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(body); + OpenAPIUtils.validate(body); } } else { body = null; @@ -123,7 +123,7 @@ public class FakeApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -146,14 +146,14 @@ public class FakeApiController extends Controller { if (nodeclient != null) { client = mapper.readValue(nodeclient.toString(), Client.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(client); + OpenAPIUtils.validate(client); } } else { throw new IllegalArgumentException("'Client' parameter is required"); } Client obj = imp.testClientModel(client); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -260,7 +260,7 @@ public class FakeApiController extends Controller { @ApiAction public Result testEnumParameters() throws Exception { String[] enumQueryStringArrayArray = request().queryString().get("enum_query_string_array"); - List enumQueryStringArrayList = SwaggerUtils.parametersToList("csv", enumQueryStringArrayArray); + List enumQueryStringArrayList = OpenAPIUtils.parametersToList("csv", enumQueryStringArrayArray); List enumQueryStringArray = new ArrayList(); for (String curParam : enumQueryStringArrayList) { if (!curParam.isEmpty()) { @@ -290,11 +290,11 @@ public class FakeApiController extends Controller { enumQueryDouble = null; } String valueenumFormStringArray = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array"))[0]; - List enumFormStringArray; + String enumFormStringArray; if (valueenumFormStringArray != null) { enumFormStringArray = valueenumFormStringArray; } else { - enumFormStringArray = new ArrayList<>(); + enumFormStringArray = "$"; } String valueenumFormString = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string"))[0]; String enumFormString; @@ -304,7 +304,7 @@ public class FakeApiController extends Controller { enumFormString = "-efg"; } String[] enumHeaderStringArrayArray = request().headers().get("enum_header_string_array"); - List enumHeaderStringArrayList = SwaggerUtils.parametersToList("csv", enumHeaderStringArrayArray); + List enumHeaderStringArrayList = OpenAPIUtils.parametersToList("csv", enumHeaderStringArrayArray); List enumHeaderStringArray = new ArrayList(); for (String curParam : enumHeaderStringArrayList) { if (!curParam.isEmpty()) { @@ -331,7 +331,7 @@ public class FakeApiController extends Controller { requestBody = mapper.readValue(noderequestBody.toString(), new TypeReference(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (Map.Entry entry : requestBody.entrySet()) { - SwaggerUtils.validate(entry.getValue()); + OpenAPIUtils.validate(entry.getValue()); } } } else { 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 3477b31872a..684ff8caff9 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 @@ -58,7 +58,7 @@ public class FakeApiControllerImp implements FakeApiControllerImpInterface { } @Override - public void testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception { + public void testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, String enumFormStringArray, String enumFormString) 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 eded5423c86..03b54d0c825 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 @@ -32,7 +32,7 @@ public interface FakeApiControllerImpInterface { void testEndpointParameters(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; - void testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws Exception; + void testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, String enumFormStringArray, String enumFormString) throws Exception; void testInlineAdditionalProperties(String requestBody) 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 38922db6fd4..748cb9f2af4 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 @@ -12,13 +12,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class FakeClassnameTags123ApiController extends Controller { @@ -42,14 +42,14 @@ public class FakeClassnameTags123ApiController extends Controller { if (nodeclient != null) { client = mapper.readValue(nodeclient.toString(), Client.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(client); + OpenAPIUtils.validate(client); } } else { throw new IllegalArgumentException("'Client' parameter is required"); } Client obj = imp.testClassname(client); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 cf849cefa79..8dff1940237 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -44,7 +44,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -72,7 +72,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -83,7 +83,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -96,7 +96,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -107,7 +107,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -118,7 +118,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -131,7 +131,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -172,7 +172,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 991820880b2..03d64c1346c 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -53,7 +53,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -66,14 +66,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 2e6a30b8f17..439fa190f58 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -43,7 +43,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -60,7 +60,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -78,7 +78,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -98,7 +98,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -138,7 +138,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java similarity index 88% rename from samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/ApiCall.java rename to samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java index 2ca308045b6..7f7d3f78484 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/ApiCall.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ApiCall.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import com.google.inject.Inject; import play.mvc.Action; @@ -8,7 +8,7 @@ import play.mvc.Result; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -public class ApiCall extends Action { +public class ApiCall extends Action { @Inject private ApiCall() {} diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ErrorHandler.java similarity index 98% rename from samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/ErrorHandler.java rename to samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ErrorHandler.java index 2c813411a5e..cee7a1c4308 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/ErrorHandler.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/ErrorHandler.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.*; diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/OpenAPIUtils.java similarity index 98% rename from samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java rename to samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/OpenAPIUtils.java index d4900e02167..c707ca74ac7 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-fake-endpoints/app/openapitools/OpenAPIUtils.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; @@ -14,7 +14,7 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -public class SwaggerUtils { +public class OpenAPIUtils { @With(ApiCall.class) @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf b/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf index bcd07672dc1..fcc5c0499a2 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf +++ b/samples/server/petstore/java-play-framework-fake-endpoints/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json b/samples/server/petstore/java-play-framework-fake-endpoints/public/openapi.json similarity index 99% rename from samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json rename to samples/server/petstore/java-play-framework-fake-endpoints/public/openapi.json index 889be253ac6..0715444d3fd 100644 --- a/samples/server/petstore/java-play-framework-fake-endpoints/public/swagger.json +++ b/samples/server/petstore/java-play-framework-fake-endpoints/public/openapi.json @@ -1483,6 +1483,11 @@ "message" : { "type" : "string" } + }, + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" } }, "Name" : { 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 e6fcc827e63..63ed0f01c34 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 @@ -14,11 +14,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -65,7 +65,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -84,7 +84,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { 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 f7a6badf987..214a6a6afb4 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 @@ -13,11 +13,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { 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 213c2f650e8..03e8392793c 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 @@ -13,11 +13,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { 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 new file mode 100644 index 00000000000..7f7d3f78484 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ApiCall.java @@ -0,0 +1,27 @@ +package openapitools; + +import com.google.inject.Inject; +import play.mvc.Action; +import play.mvc.Http; +import play.mvc.Result; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +public class ApiCall extends Action { + + @Inject + private ApiCall() {} + + public CompletionStage call(Http.Context ctx) { + try { + //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) + return delegate.call(ctx); + } catch (Throwable t) { + //TODO: log the error in your metric + + //We rethrow this error so it will be caught in the ErrorHandler + throw t; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ErrorHandler.java new file mode 100644 index 00000000000..cee7a1c4308 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/ErrorHandler.java @@ -0,0 +1,49 @@ +package openapitools; + + +import play.*; +import play.api.OptionalSourceMapper; +import play.api.UsefulException; +import play.api.routing.Router; +import play.http.DefaultHttpErrorHandler; +import play.mvc.Http.*; +import play.mvc.*; + +import javax.inject.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import static play.mvc.Results.*; + +@Singleton +public class ErrorHandler extends DefaultHttpErrorHandler { + + @Inject + public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { + super(configuration, environment, sourceMapper, routes); + } + + @Override + protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected void logServerError(RequestHeader request, UsefulException usefulException) { + //Since the error is already handled, we don't want to print anything on the console + //But if you want to have the error printed in the console, just delete this override + } + + private Result handleExceptions(Throwable t) { + //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) + return ok(); + } +} diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/OpenAPIUtils.java similarity index 97% rename from samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java rename to samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/OpenAPIUtils.java index 831a59d70be..0fdd8c3cb4a 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-bean-validation/app/openapitools/OpenAPIUtils.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; @@ -10,7 +10,7 @@ import java.text.SimpleDateFormat; import java.util.*; -public class SwaggerUtils { +public class OpenAPIUtils { @With(ApiCall.class) @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/ApiCall.java deleted file mode 100644 index 2ca308045b6..00000000000 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/ApiCall.java +++ /dev/null @@ -1,27 +0,0 @@ -package swagger; - -import com.google.inject.Inject; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; - -public class ApiCall extends Action { - - @Inject - private ApiCall() {} - - public CompletionStage call(Http.Context ctx) { - try { - //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); - } catch (Throwable t) { - //TODO: log the error in your metric - - //We rethrow this error so it will be caught in the ErrorHandler - throw t; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/ErrorHandler.java deleted file mode 100644 index 2c813411a5e..00000000000 --- a/samples/server/petstore/java-play-framework-no-bean-validation/app/swagger/ErrorHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package swagger; - - -import play.*; -import play.api.OptionalSourceMapper; -import play.api.UsefulException; -import play.api.routing.Router; -import play.http.DefaultHttpErrorHandler; -import play.mvc.Http.*; -import play.mvc.*; - -import javax.inject.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import static play.mvc.Results.*; - -@Singleton -public class ErrorHandler extends DefaultHttpErrorHandler { - - @Inject - public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { - super(configuration, environment, sourceMapper, routes); - } - - @Override - protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected void logServerError(RequestHeader request, UsefulException usefulException) { - //Since the error is already handled, we don't want to print anything on the console - //But if you want to have the error printed in the console, just delete this override - } - - private Result handleExceptions(Throwable t) { - //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) - return ok(); - } -} diff --git a/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf b/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf index 9c25177ad1f..613212fe707 100644 --- a/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-bean-validation/conf/application.conf @@ -18,7 +18,7 @@ play.filters.headers.contentSecurityPolicy=null -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-api-package-override/public/swagger.json b/samples/server/petstore/java-play-framework-no-bean-validation/public/openapi.json similarity index 99% rename from samples/server/petstore/java-play-framework-api-package-override/public/swagger.json rename to samples/server/petstore/java-play-framework-no-bean-validation/public/openapi.json index 01499dcfd25..085c36fa397 100644 --- a/samples/server/petstore/java-play-framework-api-package-override/public/swagger.json +++ b/samples/server/petstore/java-play-framework-no-bean-validation/public/openapi.json @@ -1017,7 +1017,12 @@ "type" : "string" } }, - "description" : "Describes the result of uploading an image resource" + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } } }, "securitySchemes" : { 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 d6af94e2bf5..3bbbe36662a 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 @@ -15,13 +15,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; import java.io.IOException; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -45,7 +45,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -73,7 +73,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -84,7 +84,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -97,7 +97,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -108,7 +108,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -119,7 +119,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -132,7 +132,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -173,7 +173,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 7f5a0da16a7..0a29344d5ea 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; import java.io.IOException; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -54,7 +54,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -67,14 +67,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 494262a046e..1b5d4522954 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; import java.io.IOException; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -44,7 +44,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -61,7 +61,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -79,7 +79,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -99,7 +99,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -139,7 +139,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); 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 new file mode 100644 index 00000000000..7f7d3f78484 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/ApiCall.java @@ -0,0 +1,27 @@ +package openapitools; + +import com.google.inject.Inject; +import play.mvc.Action; +import play.mvc.Http; +import play.mvc.Result; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +public class ApiCall extends Action { + + @Inject + private ApiCall() {} + + public CompletionStage call(Http.Context ctx) { + try { + //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) + return delegate.call(ctx); + } catch (Throwable t) { + //TODO: log the error in your metric + + //We rethrow this error so it will be caught in the ErrorHandler + throw t; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/OpenAPIUtils.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/OpenAPIUtils.java new file mode 100644 index 00000000000..c707ca74ac7 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-exception-handling/app/openapitools/OpenAPIUtils.java @@ -0,0 +1,103 @@ +package openapitools; + +import play.mvc.With; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +public class OpenAPIUtils { + + @With(ApiCall.class) + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + public @interface ApiAction { + } + + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + + public static List parametersToList(String collectionFormat, String[] values){ + List params = new ArrayList<>(); + + if (values == null) { + return params; + } + + if (values.length >= 1 && collectionFormat.equals("multi")) { + params.addAll(Arrays.asList(values)); + } else { + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + String delimiter = ","; + + switch(collectionFormat) { + case "csv": { + delimiter = ","; + break; + } + case "ssv": { + delimiter = " "; + break; + } + case "tsv": { + delimiter = "\t"; + break; + } + case "pipes": { + delimiter = "|"; + break; + } + } + + params = Arrays.asList(values[0].split(delimiter)); + } + + return params; + } + + public static String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDatetime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection)param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + + return b.toString(); + } else { + return String.valueOf(param); + } + } + + public static String formatDatetime(Date date) { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/ApiCall.java deleted file mode 100644 index 2ca308045b6..00000000000 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/ApiCall.java +++ /dev/null @@ -1,27 +0,0 @@ -package swagger; - -import com.google.inject.Inject; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; - -public class ApiCall extends Action { - - @Inject - private ApiCall() {} - - public CompletionStage call(Http.Context ctx) { - try { - //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); - } catch (Throwable t) { - //TODO: log the error in your metric - - //We rethrow this error so it will be caught in the ErrorHandler - throw t; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java deleted file mode 100644 index d4900e02167..00000000000 --- a/samples/server/petstore/java-play-framework-no-exception-handling/app/swagger/SwaggerUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package swagger; - -import play.mvc.With; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.text.SimpleDateFormat; -import java.util.*; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -public class SwaggerUtils { - - @With(ApiCall.class) - @Target({ ElementType.TYPE, ElementType.METHOD }) - @Retention(RetentionPolicy.RUNTIME) - public @interface ApiAction { - } - - public static void validate(T obj) { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(obj); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } - - public static List parametersToList(String collectionFormat, String[] values){ - List params = new ArrayList<>(); - - if (values == null) { - return params; - } - - if (values.length >= 1 && collectionFormat.equals("multi")) { - params.addAll(Arrays.asList(values)); - } else { - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv - - String delimiter = ","; - - switch(collectionFormat) { - case "csv": { - delimiter = ","; - break; - } - case "ssv": { - delimiter = " "; - break; - } - case "tsv": { - delimiter = "\t"; - break; - } - case "pipes": { - delimiter = "|"; - break; - } - } - - params = Arrays.asList(values[0].split(delimiter)); - } - - return params; - } - - public static String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date) { - return formatDatetime((Date) param); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection)param) { - if (b.length() > 0) { - b.append(","); - } - b.append(String.valueOf(o)); - } - - return b.toString(); - } else { - return String.valueOf(param); - } - } - - public static String formatDatetime(Date date) { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf b/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf index 1c6854a0cb4..a0e7bf1a478 100644 --- a/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-exception-handling/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/public/openapi.json b/samples/server/petstore/java-play-framework-no-exception-handling/public/openapi.json new file mode 100644 index 00000000000..085c36fa397 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-exception-handling/public/openapi.json @@ -0,0 +1,1048 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "Swagger Petstore", + "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache-2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "name" : "pet", + "description" : "Everything about your Pets", + "externalDocs" : { + "description" : "Find out more", + "url" : "http://swagger.io" + } + }, { + "name" : "store", + "description" : "Access to Petstore orders" + }, { + "name" : "user", + "description" : "Operations about user", + "externalDocs" : { + "description" : "Find out more about our store", + "url" : "http://swagger.io" + } + } ], + "paths" : { + "/pet" : { + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "operationId" : "updatePet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + }, + "405" : { + "description" : "Validation exception", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "operationId" : "addPet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string", + "default" : "available", + "enum" : [ "available", "pending", "sold" ] + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid status value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid tag value", + "content" : { } + } + }, + "deprecated" : true, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to return", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "properties" : { + "name" : { + "type" : "string", + "description" : "Updated name of the pet" + }, + "status" : { + "type" : "string", + "description" : "Updated status of the pet" + } + } + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/x-www-form-urlencoded", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "operationId" : "deletePet", + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "schema" : { + "type" : "string" + } + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "operationId" : "uploadFile", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "properties" : { + "additionalMetadata" : { + "type" : "string", + "description" : "Additional data to pass to server" + }, + "file" : { + "type" : "string", + "description" : "file to upload", + "format" : "binary" + } + } + } + } + } + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "multipart/form-data", + "x-accepts" : "application/json" + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "operationId" : "placeOrder", + "requestBody" : { + "description" : "order placed for purchasing the pet", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid Order", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "schema" : { + "maximum" : 5, + "minimum" : 1, + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "description" : "Created user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "operationId" : "loginUser", + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, + "X-Expires-After" : { + "description" : "date in UTC when toekn expires", + "schema" : { + "type" : "string", + "format" : "date-time" + } + } + }, + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + } + }, + "400" : { + "description" : "Invalid username/password supplied", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "operationId" : "getUserByName", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing.", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "description" : "Updated user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + } + }, + "components" : { + "schemas" : { + "Order" : { + "title" : "Pet Order", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean", + "default" : false + } + }, + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "title" : "Pet category", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "xml" : { + "name" : "Category" + } + }, + "User" : { + "title" : "a User", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "description" : "User Status", + "format" : "int32" + } + }, + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "title" : "Pet Tag", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "title" : "a Pet", + "required" : [ "name", "photoUrls" ], + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + }, + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + }, + "items" : { + "$ref" : "#/components/schemas/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "title" : "An uploaded response", + "type" : "object", + "properties" : { + "code" : { + "type" : "integer", + "format" : "int32" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } + } + }, + "securitySchemes" : { + "petstore_auth" : { + "type" : "oauth2", + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + } + }, + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-exception-handling/public/swagger.json b/samples/server/petstore/java-play-framework-no-exception-handling/public/swagger.json deleted file mode 100644 index 01499dcfd25..00000000000 --- a/samples/server/petstore/java-play-framework-no-exception-handling/public/swagger.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "openapi" : "3.0.1", - "info" : { - "title" : "Swagger Petstore", - "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", - "termsOfService" : "http://swagger.io/terms/", - "contact" : { - "email" : "apiteam@swagger.io" - }, - "license" : { - "name" : "Apache-2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "name" : "pet", - "description" : "Everything about your Pets", - "externalDocs" : { - "description" : "Find out more", - "url" : "http://swagger.io" - } - }, { - "name" : "store", - "description" : "Access to Petstore orders" - }, { - "name" : "user", - "description" : "Operations about user", - "externalDocs" : { - "description" : "Find out more about our store", - "url" : "http://swagger.io" - } - } ], - "paths" : { - "/pet" : { - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "operationId" : "updatePet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - }, - "405" : { - "description" : "Validation exception", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "operationId" : "addPet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - } - }, - "/pet/findByStatus" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "name" : "status", - "in" : "query", - "description" : "Status values that need to be considered for filter", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string", - "default" : "available", - "enum" : [ "available", "pending", "sold" ] - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid status value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/findByTags" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "name" : "tags", - "in" : "query", - "description" : "Tags to filter by", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid tag value", - "content" : { } - } - }, - "deprecated" : true, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to return", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be updated", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "properties" : { - "name" : { - "type" : "string", - "description" : "Updated name of the pet" - }, - "status" : { - "type" : "string", - "description" : "Updated status of the pet" - } - } - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/x-www-form-urlencoded", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "operationId" : "deletePet", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "schema" : { - "type" : "string" - } - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", - "operationId" : "uploadFile", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to update", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "properties" : { - "additionalMetadata" : { - "type" : "string", - "description" : "Additional data to pass to server" - }, - "file" : { - "type" : "string", - "description" : "file to upload", - "format" : "binary" - } - } - } - } - } - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "multipart/form-data", - "x-accepts" : "application/json" - } - }, - "/store/inventory" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "type" : "object", - "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } - } - } - } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - } - }, - "/store/order" : { - "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", - "operationId" : "placeOrder", - "requestBody" : { - "description" : "order placed for purchasing the pet", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "required" : true - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid Order", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/store/order/{orderId}" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "schema" : { - "maximum" : 5, - "minimum" : 1, - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "description" : "Created user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "operationId" : "loginUser", - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when toekn expires", - "schema" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - } - }, - "400" : { - "description" : "Invalid username/password supplied", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "operationId" : "getUserByName", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing.", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Updated user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - } - }, - "components" : { - "schemas" : { - "Order" : { - "title" : "Pet Order", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "petId" : { - "type" : "integer", - "format" : "int64" - }, - "quantity" : { - "type" : "integer", - "format" : "int32" - }, - "shipDate" : { - "type" : "string", - "format" : "date-time" - }, - "status" : { - "type" : "string", - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] - }, - "complete" : { - "type" : "boolean", - "default" : false - } - }, - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "title" : "Pet category", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "xml" : { - "name" : "Category" - } - }, - "User" : { - "title" : "a User", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "description" : "User Status", - "format" : "int32" - } - }, - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "title" : "Pet Tag", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "title" : "a Pet", - "required" : [ "name", "photoUrls" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "type" : "string", - "example" : "doggie" - }, - "photoUrls" : { - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - }, - "items" : { - "type" : "string" - } - }, - "tags" : { - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" - } - }, - "status" : { - "type" : "string", - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] - } - }, - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "title" : "An uploaded response", - "type" : "object", - "properties" : { - "code" : { - "type" : "integer", - "format" : "int32" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "description" : "Describes the result of uploading an image resource" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "type" : "oauth2", - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - } - }, - "api_key" : { - "type" : "apiKey", - "name" : "api_key", - "in" : "header" - } - } - } -} \ 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 592b7e49986..74dc88d8ad6 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -44,7 +44,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -72,7 +72,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -83,7 +83,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -96,7 +96,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -107,7 +107,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -118,7 +118,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -131,7 +131,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -172,7 +172,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + 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 6b0690fa120..e84ba99993d 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -53,7 +53,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -66,14 +66,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + 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 89fdf918b6a..d0e01ef7720 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -43,7 +43,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -60,7 +60,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -78,7 +78,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -98,7 +98,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -138,7 +138,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); 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 new file mode 100644 index 00000000000..7f7d3f78484 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ApiCall.java @@ -0,0 +1,27 @@ +package openapitools; + +import com.google.inject.Inject; +import play.mvc.Action; +import play.mvc.Http; +import play.mvc.Result; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +public class ApiCall extends Action { + + @Inject + private ApiCall() {} + + public CompletionStage call(Http.Context ctx) { + try { + //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) + return delegate.call(ctx); + } catch (Throwable t) { + //TODO: log the error in your metric + + //We rethrow this error so it will be caught in the ErrorHandler + throw t; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ErrorHandler.java new file mode 100644 index 00000000000..cee7a1c4308 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/ErrorHandler.java @@ -0,0 +1,49 @@ +package openapitools; + + +import play.*; +import play.api.OptionalSourceMapper; +import play.api.UsefulException; +import play.api.routing.Router; +import play.http.DefaultHttpErrorHandler; +import play.mvc.Http.*; +import play.mvc.*; + +import javax.inject.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import static play.mvc.Results.*; + +@Singleton +public class ErrorHandler extends DefaultHttpErrorHandler { + + @Inject + public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { + super(configuration, environment, sourceMapper, routes); + } + + @Override + protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected void logServerError(RequestHeader request, UsefulException usefulException) { + //Since the error is already handled, we don't want to print anything on the console + //But if you want to have the error printed in the console, just delete this override + } + + private Result handleExceptions(Throwable t) { + //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) + return ok(); + } +} diff --git a/samples/server/petstore/java-play-framework-no-interface/app/openapitools/OpenAPIUtils.java b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/OpenAPIUtils.java new file mode 100644 index 00000000000..c707ca74ac7 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-interface/app/openapitools/OpenAPIUtils.java @@ -0,0 +1,103 @@ +package openapitools; + +import play.mvc.With; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +public class OpenAPIUtils { + + @With(ApiCall.class) + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + public @interface ApiAction { + } + + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + + public static List parametersToList(String collectionFormat, String[] values){ + List params = new ArrayList<>(); + + if (values == null) { + return params; + } + + if (values.length >= 1 && collectionFormat.equals("multi")) { + params.addAll(Arrays.asList(values)); + } else { + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + String delimiter = ","; + + switch(collectionFormat) { + case "csv": { + delimiter = ","; + break; + } + case "ssv": { + delimiter = " "; + break; + } + case "tsv": { + delimiter = "\t"; + break; + } + case "pipes": { + delimiter = "|"; + break; + } + } + + params = Arrays.asList(values[0].split(delimiter)); + } + + return params; + } + + public static String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDatetime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection)param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + + return b.toString(); + } else { + return String.valueOf(param); + } + } + + public static String formatDatetime(Date date) { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-interface/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-no-interface/app/swagger/ApiCall.java deleted file mode 100644 index 2ca308045b6..00000000000 --- a/samples/server/petstore/java-play-framework-no-interface/app/swagger/ApiCall.java +++ /dev/null @@ -1,27 +0,0 @@ -package swagger; - -import com.google.inject.Inject; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; - -public class ApiCall extends Action { - - @Inject - private ApiCall() {} - - public CompletionStage call(Http.Context ctx) { - try { - //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); - } catch (Throwable t) { - //TODO: log the error in your metric - - //We rethrow this error so it will be caught in the ErrorHandler - throw t; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-interface/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-interface/app/swagger/ErrorHandler.java deleted file mode 100644 index 2c813411a5e..00000000000 --- a/samples/server/petstore/java-play-framework-no-interface/app/swagger/ErrorHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package swagger; - - -import play.*; -import play.api.OptionalSourceMapper; -import play.api.UsefulException; -import play.api.routing.Router; -import play.http.DefaultHttpErrorHandler; -import play.mvc.Http.*; -import play.mvc.*; - -import javax.inject.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import static play.mvc.Results.*; - -@Singleton -public class ErrorHandler extends DefaultHttpErrorHandler { - - @Inject - public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { - super(configuration, environment, sourceMapper, routes); - } - - @Override - protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected void logServerError(RequestHeader request, UsefulException usefulException) { - //Since the error is already handled, we don't want to print anything on the console - //But if you want to have the error printed in the console, just delete this override - } - - private Result handleExceptions(Throwable t) { - //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) - return ok(); - } -} diff --git a/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java deleted file mode 100644 index d4900e02167..00000000000 --- a/samples/server/petstore/java-play-framework-no-interface/app/swagger/SwaggerUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package swagger; - -import play.mvc.With; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.text.SimpleDateFormat; -import java.util.*; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -public class SwaggerUtils { - - @With(ApiCall.class) - @Target({ ElementType.TYPE, ElementType.METHOD }) - @Retention(RetentionPolicy.RUNTIME) - public @interface ApiAction { - } - - public static void validate(T obj) { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(obj); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } - - public static List parametersToList(String collectionFormat, String[] values){ - List params = new ArrayList<>(); - - if (values == null) { - return params; - } - - if (values.length >= 1 && collectionFormat.equals("multi")) { - params.addAll(Arrays.asList(values)); - } else { - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv - - String delimiter = ","; - - switch(collectionFormat) { - case "csv": { - delimiter = ","; - break; - } - case "ssv": { - delimiter = " "; - break; - } - case "tsv": { - delimiter = "\t"; - break; - } - case "pipes": { - delimiter = "|"; - break; - } - } - - params = Arrays.asList(values[0].split(delimiter)); - } - - return params; - } - - public static String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date) { - return formatDatetime((Date) param); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection)param) { - if (b.length() > 0) { - b.append(","); - } - b.append(String.valueOf(o)); - } - - return b.toString(); - } else { - return String.valueOf(param); - } - } - - public static String formatDatetime(Date date) { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-interface/conf/application.conf b/samples/server/petstore/java-play-framework-no-interface/conf/application.conf index a6680d1c487..ffb628cd848 100644 --- a/samples/server/petstore/java-play-framework-no-interface/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-interface/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-no-interface/public/openapi.json b/samples/server/petstore/java-play-framework-no-interface/public/openapi.json new file mode 100644 index 00000000000..085c36fa397 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-interface/public/openapi.json @@ -0,0 +1,1048 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "Swagger Petstore", + "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache-2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "name" : "pet", + "description" : "Everything about your Pets", + "externalDocs" : { + "description" : "Find out more", + "url" : "http://swagger.io" + } + }, { + "name" : "store", + "description" : "Access to Petstore orders" + }, { + "name" : "user", + "description" : "Operations about user", + "externalDocs" : { + "description" : "Find out more about our store", + "url" : "http://swagger.io" + } + } ], + "paths" : { + "/pet" : { + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "operationId" : "updatePet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + }, + "405" : { + "description" : "Validation exception", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "operationId" : "addPet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string", + "default" : "available", + "enum" : [ "available", "pending", "sold" ] + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid status value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid tag value", + "content" : { } + } + }, + "deprecated" : true, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to return", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "properties" : { + "name" : { + "type" : "string", + "description" : "Updated name of the pet" + }, + "status" : { + "type" : "string", + "description" : "Updated status of the pet" + } + } + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/x-www-form-urlencoded", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "operationId" : "deletePet", + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "schema" : { + "type" : "string" + } + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "operationId" : "uploadFile", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "properties" : { + "additionalMetadata" : { + "type" : "string", + "description" : "Additional data to pass to server" + }, + "file" : { + "type" : "string", + "description" : "file to upload", + "format" : "binary" + } + } + } + } + } + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "multipart/form-data", + "x-accepts" : "application/json" + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "operationId" : "placeOrder", + "requestBody" : { + "description" : "order placed for purchasing the pet", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid Order", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "schema" : { + "maximum" : 5, + "minimum" : 1, + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "description" : "Created user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "operationId" : "loginUser", + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, + "X-Expires-After" : { + "description" : "date in UTC when toekn expires", + "schema" : { + "type" : "string", + "format" : "date-time" + } + } + }, + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + } + }, + "400" : { + "description" : "Invalid username/password supplied", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "operationId" : "getUserByName", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing.", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "description" : "Updated user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + } + }, + "components" : { + "schemas" : { + "Order" : { + "title" : "Pet Order", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean", + "default" : false + } + }, + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "title" : "Pet category", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "xml" : { + "name" : "Category" + } + }, + "User" : { + "title" : "a User", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "description" : "User Status", + "format" : "int32" + } + }, + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "title" : "Pet Tag", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "title" : "a Pet", + "required" : [ "name", "photoUrls" ], + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + }, + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + }, + "items" : { + "$ref" : "#/components/schemas/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "title" : "An uploaded response", + "type" : "object", + "properties" : { + "code" : { + "type" : "integer", + "format" : "int32" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } + } + }, + "securitySchemes" : { + "petstore_auth" : { + "type" : "oauth2", + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + } + }, + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-interface/public/swagger.json b/samples/server/petstore/java-play-framework-no-interface/public/swagger.json deleted file mode 100644 index 01499dcfd25..00000000000 --- a/samples/server/petstore/java-play-framework-no-interface/public/swagger.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "openapi" : "3.0.1", - "info" : { - "title" : "Swagger Petstore", - "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", - "termsOfService" : "http://swagger.io/terms/", - "contact" : { - "email" : "apiteam@swagger.io" - }, - "license" : { - "name" : "Apache-2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "name" : "pet", - "description" : "Everything about your Pets", - "externalDocs" : { - "description" : "Find out more", - "url" : "http://swagger.io" - } - }, { - "name" : "store", - "description" : "Access to Petstore orders" - }, { - "name" : "user", - "description" : "Operations about user", - "externalDocs" : { - "description" : "Find out more about our store", - "url" : "http://swagger.io" - } - } ], - "paths" : { - "/pet" : { - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "operationId" : "updatePet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - }, - "405" : { - "description" : "Validation exception", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "operationId" : "addPet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - } - }, - "/pet/findByStatus" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "name" : "status", - "in" : "query", - "description" : "Status values that need to be considered for filter", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string", - "default" : "available", - "enum" : [ "available", "pending", "sold" ] - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid status value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/findByTags" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "name" : "tags", - "in" : "query", - "description" : "Tags to filter by", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid tag value", - "content" : { } - } - }, - "deprecated" : true, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to return", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be updated", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "properties" : { - "name" : { - "type" : "string", - "description" : "Updated name of the pet" - }, - "status" : { - "type" : "string", - "description" : "Updated status of the pet" - } - } - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/x-www-form-urlencoded", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "operationId" : "deletePet", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "schema" : { - "type" : "string" - } - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", - "operationId" : "uploadFile", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to update", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "properties" : { - "additionalMetadata" : { - "type" : "string", - "description" : "Additional data to pass to server" - }, - "file" : { - "type" : "string", - "description" : "file to upload", - "format" : "binary" - } - } - } - } - } - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "multipart/form-data", - "x-accepts" : "application/json" - } - }, - "/store/inventory" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "type" : "object", - "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } - } - } - } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - } - }, - "/store/order" : { - "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", - "operationId" : "placeOrder", - "requestBody" : { - "description" : "order placed for purchasing the pet", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "required" : true - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid Order", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/store/order/{orderId}" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "schema" : { - "maximum" : 5, - "minimum" : 1, - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "description" : "Created user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "operationId" : "loginUser", - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when toekn expires", - "schema" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - } - }, - "400" : { - "description" : "Invalid username/password supplied", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "operationId" : "getUserByName", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing.", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Updated user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - } - }, - "components" : { - "schemas" : { - "Order" : { - "title" : "Pet Order", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "petId" : { - "type" : "integer", - "format" : "int64" - }, - "quantity" : { - "type" : "integer", - "format" : "int32" - }, - "shipDate" : { - "type" : "string", - "format" : "date-time" - }, - "status" : { - "type" : "string", - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] - }, - "complete" : { - "type" : "boolean", - "default" : false - } - }, - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "title" : "Pet category", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "xml" : { - "name" : "Category" - } - }, - "User" : { - "title" : "a User", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "description" : "User Status", - "format" : "int32" - } - }, - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "title" : "Pet Tag", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "title" : "a Pet", - "required" : [ "name", "photoUrls" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "type" : "string", - "example" : "doggie" - }, - "photoUrls" : { - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - }, - "items" : { - "type" : "string" - } - }, - "tags" : { - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" - } - }, - "status" : { - "type" : "string", - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] - } - }, - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "title" : "An uploaded response", - "type" : "object", - "properties" : { - "code" : { - "type" : "integer", - "format" : "int32" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "description" : "Describes the result of uploading an image resource" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "type" : "oauth2", - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - } - }, - "api_key" : { - "type" : "apiKey", - "name" : "api_key", - "in" : "header" - } - } - } -} \ 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 cf849cefa79..8dff1940237 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -44,7 +44,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -72,7 +72,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -83,7 +83,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -96,7 +96,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -107,7 +107,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -118,7 +118,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -131,7 +131,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -172,7 +172,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 991820880b2..03d64c1346c 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -53,7 +53,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -66,14 +66,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 2e6a30b8f17..439fa190f58 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 @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -43,7 +43,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -60,7 +60,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -78,7 +78,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -98,7 +98,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -138,7 +138,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); 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 new file mode 100644 index 00000000000..7f7d3f78484 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ApiCall.java @@ -0,0 +1,27 @@ +package openapitools; + +import com.google.inject.Inject; +import play.mvc.Action; +import play.mvc.Http; +import play.mvc.Result; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +public class ApiCall extends Action { + + @Inject + private ApiCall() {} + + public CompletionStage call(Http.Context ctx) { + try { + //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) + return delegate.call(ctx); + } catch (Throwable t) { + //TODO: log the error in your metric + + //We rethrow this error so it will be caught in the ErrorHandler + throw t; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ErrorHandler.java new file mode 100644 index 00000000000..cee7a1c4308 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/ErrorHandler.java @@ -0,0 +1,49 @@ +package openapitools; + + +import play.*; +import play.api.OptionalSourceMapper; +import play.api.UsefulException; +import play.api.routing.Router; +import play.http.DefaultHttpErrorHandler; +import play.mvc.Http.*; +import play.mvc.*; + +import javax.inject.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import static play.mvc.Results.*; + +@Singleton +public class ErrorHandler extends DefaultHttpErrorHandler { + + @Inject + public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { + super(configuration, environment, sourceMapper, routes); + } + + @Override + protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected void logServerError(RequestHeader request, UsefulException usefulException) { + //Since the error is already handled, we don't want to print anything on the console + //But if you want to have the error printed in the console, just delete this override + } + + private Result handleExceptions(Throwable t) { + //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) + return ok(); + } +} diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/OpenAPIUtils.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/OpenAPIUtils.java new file mode 100644 index 00000000000..c707ca74ac7 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/app/openapitools/OpenAPIUtils.java @@ -0,0 +1,103 @@ +package openapitools; + +import play.mvc.With; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +public class OpenAPIUtils { + + @With(ApiCall.class) + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + public @interface ApiAction { + } + + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + + public static List parametersToList(String collectionFormat, String[] values){ + List params = new ArrayList<>(); + + if (values == null) { + return params; + } + + if (values.length >= 1 && collectionFormat.equals("multi")) { + params.addAll(Arrays.asList(values)); + } else { + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + String delimiter = ","; + + switch(collectionFormat) { + case "csv": { + delimiter = ","; + break; + } + case "ssv": { + delimiter = " "; + break; + } + case "tsv": { + delimiter = "\t"; + break; + } + case "pipes": { + delimiter = "|"; + break; + } + } + + params = Arrays.asList(values[0].split(delimiter)); + } + + return params; + } + + public static String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDatetime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection)param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + + return b.toString(); + } else { + return String.valueOf(param); + } + } + + public static String formatDatetime(Date date) { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/ApiCall.java deleted file mode 100644 index 2ca308045b6..00000000000 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/ApiCall.java +++ /dev/null @@ -1,27 +0,0 @@ -package swagger; - -import com.google.inject.Inject; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; - -public class ApiCall extends Action { - - @Inject - private ApiCall() {} - - public CompletionStage call(Http.Context ctx) { - try { - //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); - } catch (Throwable t) { - //TODO: log the error in your metric - - //We rethrow this error so it will be caught in the ErrorHandler - throw t; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/ErrorHandler.java deleted file mode 100644 index 2c813411a5e..00000000000 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/ErrorHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package swagger; - - -import play.*; -import play.api.OptionalSourceMapper; -import play.api.UsefulException; -import play.api.routing.Router; -import play.http.DefaultHttpErrorHandler; -import play.mvc.Http.*; -import play.mvc.*; - -import javax.inject.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import static play.mvc.Results.*; - -@Singleton -public class ErrorHandler extends DefaultHttpErrorHandler { - - @Inject - public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { - super(configuration, environment, sourceMapper, routes); - } - - @Override - protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected void logServerError(RequestHeader request, UsefulException usefulException) { - //Since the error is already handled, we don't want to print anything on the console - //But if you want to have the error printed in the console, just delete this override - } - - private Result handleExceptions(Throwable t) { - //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) - return ok(); - } -} diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java deleted file mode 100644 index d4900e02167..00000000000 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/app/swagger/SwaggerUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package swagger; - -import play.mvc.With; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.text.SimpleDateFormat; -import java.util.*; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -public class SwaggerUtils { - - @With(ApiCall.class) - @Target({ ElementType.TYPE, ElementType.METHOD }) - @Retention(RetentionPolicy.RUNTIME) - public @interface ApiAction { - } - - public static void validate(T obj) { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(obj); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } - - public static List parametersToList(String collectionFormat, String[] values){ - List params = new ArrayList<>(); - - if (values == null) { - return params; - } - - if (values.length >= 1 && collectionFormat.equals("multi")) { - params.addAll(Arrays.asList(values)); - } else { - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv - - String delimiter = ","; - - switch(collectionFormat) { - case "csv": { - delimiter = ","; - break; - } - case "ssv": { - delimiter = " "; - break; - } - case "tsv": { - delimiter = "\t"; - break; - } - case "pipes": { - delimiter = "|"; - break; - } - } - - params = Arrays.asList(values[0].split(delimiter)); - } - - return params; - } - - public static String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date) { - return formatDatetime((Date) param); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection)param) { - if (b.length() > 0) { - b.append(","); - } - b.append(String.valueOf(o)); - } - - return b.toString(); - } else { - return String.valueOf(param); - } - } - - public static String formatDatetime(Date date) { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf b/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf index bcd07672dc1..fcc5c0499a2 100644 --- a/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-swagger-ui/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration 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 26665acfbf7..9e1c362bfb0 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 @@ -14,7 +14,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; @@ -43,7 +43,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -71,7 +71,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -82,7 +82,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -95,7 +95,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -106,7 +106,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -117,7 +117,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -130,7 +130,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -171,7 +171,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 885634e17c4..5c73582f93d 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 @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; @@ -52,7 +52,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -65,14 +65,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 6490dc6cdfa..9dd1065fa8e 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 @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; @@ -42,7 +42,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -59,7 +59,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -77,7 +77,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -97,7 +97,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -137,7 +137,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/ErrorHandler.java new file mode 100644 index 00000000000..cee7a1c4308 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/ErrorHandler.java @@ -0,0 +1,49 @@ +package openapitools; + + +import play.*; +import play.api.OptionalSourceMapper; +import play.api.UsefulException; +import play.api.routing.Router; +import play.http.DefaultHttpErrorHandler; +import play.mvc.Http.*; +import play.mvc.*; + +import javax.inject.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import static play.mvc.Results.*; + +@Singleton +public class ErrorHandler extends DefaultHttpErrorHandler { + + @Inject + public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { + super(configuration, environment, sourceMapper, routes); + } + + @Override + protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected void logServerError(RequestHeader request, UsefulException usefulException) { + //Since the error is already handled, we don't want to print anything on the console + //But if you want to have the error printed in the console, just delete this override + } + + private Result handleExceptions(Throwable t) { + //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) + return ok(); + } +} diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/OpenAPIUtils.java similarity index 98% rename from samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java rename to samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/OpenAPIUtils.java index 4c5ee51c67f..fca771cfb00 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/SwaggerUtils.java +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/app/openapitools/OpenAPIUtils.java @@ -1,4 +1,4 @@ -package swagger; +package openapitools; import play.mvc.With; @@ -14,7 +14,7 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -public class SwaggerUtils { +public class OpenAPIUtils { public static void validate(T obj) { diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/ErrorHandler.java deleted file mode 100644 index 2c813411a5e..00000000000 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/app/swagger/ErrorHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package swagger; - - -import play.*; -import play.api.OptionalSourceMapper; -import play.api.UsefulException; -import play.api.routing.Router; -import play.http.DefaultHttpErrorHandler; -import play.mvc.Http.*; -import play.mvc.*; - -import javax.inject.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import static play.mvc.Results.*; - -@Singleton -public class ErrorHandler extends DefaultHttpErrorHandler { - - @Inject - public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { - super(configuration, environment, sourceMapper, routes); - } - - @Override - protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected void logServerError(RequestHeader request, UsefulException usefulException) { - //Since the error is already handled, we don't want to print anything on the console - //But if you want to have the error printed in the console, just delete this override - } - - private Result handleExceptions(Throwable t) { - //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) - return ok(); - } -} diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf b/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf index bcd07672dc1..fcc5c0499a2 100644 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/public/openapi.json b/samples/server/petstore/java-play-framework-no-wrap-calls/public/openapi.json new file mode 100644 index 00000000000..085c36fa397 --- /dev/null +++ b/samples/server/petstore/java-play-framework-no-wrap-calls/public/openapi.json @@ -0,0 +1,1048 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "Swagger Petstore", + "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache-2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "name" : "pet", + "description" : "Everything about your Pets", + "externalDocs" : { + "description" : "Find out more", + "url" : "http://swagger.io" + } + }, { + "name" : "store", + "description" : "Access to Petstore orders" + }, { + "name" : "user", + "description" : "Operations about user", + "externalDocs" : { + "description" : "Find out more about our store", + "url" : "http://swagger.io" + } + } ], + "paths" : { + "/pet" : { + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "operationId" : "updatePet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + }, + "405" : { + "description" : "Validation exception", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "operationId" : "addPet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string", + "default" : "available", + "enum" : [ "available", "pending", "sold" ] + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid status value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid tag value", + "content" : { } + } + }, + "deprecated" : true, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to return", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "properties" : { + "name" : { + "type" : "string", + "description" : "Updated name of the pet" + }, + "status" : { + "type" : "string", + "description" : "Updated status of the pet" + } + } + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/x-www-form-urlencoded", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "operationId" : "deletePet", + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "schema" : { + "type" : "string" + } + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "operationId" : "uploadFile", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "properties" : { + "additionalMetadata" : { + "type" : "string", + "description" : "Additional data to pass to server" + }, + "file" : { + "type" : "string", + "description" : "file to upload", + "format" : "binary" + } + } + } + } + } + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "multipart/form-data", + "x-accepts" : "application/json" + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "operationId" : "placeOrder", + "requestBody" : { + "description" : "order placed for purchasing the pet", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid Order", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "schema" : { + "maximum" : 5, + "minimum" : 1, + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "description" : "Created user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "operationId" : "loginUser", + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, + "X-Expires-After" : { + "description" : "date in UTC when toekn expires", + "schema" : { + "type" : "string", + "format" : "date-time" + } + } + }, + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + } + }, + "400" : { + "description" : "Invalid username/password supplied", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "operationId" : "getUserByName", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing.", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "description" : "Updated user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + } + }, + "components" : { + "schemas" : { + "Order" : { + "title" : "Pet Order", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean", + "default" : false + } + }, + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "title" : "Pet category", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "xml" : { + "name" : "Category" + } + }, + "User" : { + "title" : "a User", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "description" : "User Status", + "format" : "int32" + } + }, + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "title" : "Pet Tag", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "title" : "a Pet", + "required" : [ "name", "photoUrls" ], + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + }, + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + }, + "items" : { + "$ref" : "#/components/schemas/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "title" : "An uploaded response", + "type" : "object", + "properties" : { + "code" : { + "type" : "integer", + "format" : "int32" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } + } + }, + "securitySchemes" : { + "petstore_auth" : { + "type" : "oauth2", + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + } + }, + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework-no-wrap-calls/public/swagger.json b/samples/server/petstore/java-play-framework-no-wrap-calls/public/swagger.json deleted file mode 100644 index 01499dcfd25..00000000000 --- a/samples/server/petstore/java-play-framework-no-wrap-calls/public/swagger.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "openapi" : "3.0.1", - "info" : { - "title" : "Swagger Petstore", - "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", - "termsOfService" : "http://swagger.io/terms/", - "contact" : { - "email" : "apiteam@swagger.io" - }, - "license" : { - "name" : "Apache-2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "name" : "pet", - "description" : "Everything about your Pets", - "externalDocs" : { - "description" : "Find out more", - "url" : "http://swagger.io" - } - }, { - "name" : "store", - "description" : "Access to Petstore orders" - }, { - "name" : "user", - "description" : "Operations about user", - "externalDocs" : { - "description" : "Find out more about our store", - "url" : "http://swagger.io" - } - } ], - "paths" : { - "/pet" : { - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "operationId" : "updatePet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - }, - "405" : { - "description" : "Validation exception", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "operationId" : "addPet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - } - }, - "/pet/findByStatus" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "name" : "status", - "in" : "query", - "description" : "Status values that need to be considered for filter", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string", - "default" : "available", - "enum" : [ "available", "pending", "sold" ] - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid status value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/findByTags" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "name" : "tags", - "in" : "query", - "description" : "Tags to filter by", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid tag value", - "content" : { } - } - }, - "deprecated" : true, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to return", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be updated", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "properties" : { - "name" : { - "type" : "string", - "description" : "Updated name of the pet" - }, - "status" : { - "type" : "string", - "description" : "Updated status of the pet" - } - } - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/x-www-form-urlencoded", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "operationId" : "deletePet", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "schema" : { - "type" : "string" - } - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", - "operationId" : "uploadFile", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to update", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "properties" : { - "additionalMetadata" : { - "type" : "string", - "description" : "Additional data to pass to server" - }, - "file" : { - "type" : "string", - "description" : "file to upload", - "format" : "binary" - } - } - } - } - } - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "multipart/form-data", - "x-accepts" : "application/json" - } - }, - "/store/inventory" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "type" : "object", - "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } - } - } - } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - } - }, - "/store/order" : { - "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", - "operationId" : "placeOrder", - "requestBody" : { - "description" : "order placed for purchasing the pet", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "required" : true - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid Order", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/store/order/{orderId}" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "schema" : { - "maximum" : 5, - "minimum" : 1, - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "description" : "Created user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "operationId" : "loginUser", - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when toekn expires", - "schema" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - } - }, - "400" : { - "description" : "Invalid username/password supplied", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "operationId" : "getUserByName", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing.", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Updated user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - } - }, - "components" : { - "schemas" : { - "Order" : { - "title" : "Pet Order", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "petId" : { - "type" : "integer", - "format" : "int64" - }, - "quantity" : { - "type" : "integer", - "format" : "int32" - }, - "shipDate" : { - "type" : "string", - "format" : "date-time" - }, - "status" : { - "type" : "string", - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] - }, - "complete" : { - "type" : "boolean", - "default" : false - } - }, - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "title" : "Pet category", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "xml" : { - "name" : "Category" - } - }, - "User" : { - "title" : "a User", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "description" : "User Status", - "format" : "int32" - } - }, - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "title" : "Pet Tag", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "title" : "a Pet", - "required" : [ "name", "photoUrls" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "type" : "string", - "example" : "doggie" - }, - "photoUrls" : { - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - }, - "items" : { - "type" : "string" - } - }, - "tags" : { - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" - } - }, - "status" : { - "type" : "string", - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] - } - }, - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "title" : "An uploaded response", - "type" : "object", - "properties" : { - "code" : { - "type" : "integer", - "format" : "int32" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "description" : "Describes the result of uploading an image resource" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "type" : "oauth2", - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - } - }, - "api_key" : { - "type" : "apiKey", - "name" : "api_key", - "in" : "header" - } - } - } -} \ 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 cf849cefa79..8dff1940237 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -14,13 +14,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class PetApiController extends Controller { @@ -44,7 +44,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -72,7 +72,7 @@ public class PetApiController extends Controller { if (statusArray == null) { throw new IllegalArgumentException("'status' parameter is required"); } - List statusList = SwaggerUtils.parametersToList("csv", statusArray); + List statusList = OpenAPIUtils.parametersToList("csv", statusArray); List status = new ArrayList(); for (String curParam : statusList) { if (!curParam.isEmpty()) { @@ -83,7 +83,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByStatus(status); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -96,7 +96,7 @@ public class PetApiController extends Controller { if (tagsArray == null) { throw new IllegalArgumentException("'tags' parameter is required"); } - List tagsList = SwaggerUtils.parametersToList("csv", tagsArray); + List tagsList = OpenAPIUtils.parametersToList("csv", tagsArray); List tags = new ArrayList(); for (String curParam : tagsList) { if (!curParam.isEmpty()) { @@ -107,7 +107,7 @@ public class PetApiController extends Controller { List obj = imp.findPetsByTags(tags); if (configuration.getBoolean("useOutputBeanValidation")) { for (Pet curItem : obj) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } JsonNode result = mapper.valueToTree(obj); @@ -118,7 +118,7 @@ public class PetApiController extends Controller { public Result getPetById(Long petId) throws Exception { Pet obj = imp.getPetById(petId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -131,7 +131,7 @@ public class PetApiController extends Controller { if (nodepet != null) { pet = mapper.readValue(nodepet.toString(), Pet.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(pet); + OpenAPIUtils.validate(pet); } } else { throw new IllegalArgumentException("'Pet' parameter is required"); @@ -172,7 +172,7 @@ public class PetApiController extends Controller { Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 991820880b2..03d64c1346c 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/StoreApiController.java @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class StoreApiController extends Controller { @@ -53,7 +53,7 @@ public class StoreApiController extends Controller { public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception { Order obj = imp.getOrderById(orderId); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -66,14 +66,14 @@ public class StoreApiController extends Controller { if (nodeorder != null) { order = mapper.readValue(nodeorder.toString(), Order.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(order); + OpenAPIUtils.validate(order); } } else { throw new IllegalArgumentException("'Order' parameter is required"); } Order obj = imp.placeOrder(order); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); 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 2e6a30b8f17..439fa190f58 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/UserApiController.java @@ -13,13 +13,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; import com.google.inject.Inject; import java.io.File; -import swagger.SwaggerUtils; +import openapitools.OpenAPIUtils; import com.fasterxml.jackson.core.type.TypeReference; import javax.validation.constraints.*; import play.Configuration; -import swagger.SwaggerUtils.ApiAction; +import openapitools.OpenAPIUtils.ApiAction; public class UserApiController extends Controller { @@ -43,7 +43,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); @@ -60,7 +60,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -78,7 +78,7 @@ public class UserApiController extends Controller { user = mapper.readValue(nodeuser.toString(), new TypeReference>(){}); if (configuration.getBoolean("useInputBeanValidation")) { for (User curItem : user) { - SwaggerUtils.validate(curItem); + OpenAPIUtils.validate(curItem); } } } else { @@ -98,7 +98,7 @@ public class UserApiController extends Controller { public Result getUserByName(String username) throws Exception { User obj = imp.getUserByName(username); if (configuration.getBoolean("useOutputBeanValidation")) { - SwaggerUtils.validate(obj); + OpenAPIUtils.validate(obj); } JsonNode result = mapper.valueToTree(obj); return ok(result); @@ -138,7 +138,7 @@ public class UserApiController extends Controller { if (nodeuser != null) { user = mapper.readValue(nodeuser.toString(), User.class); if (configuration.getBoolean("useInputBeanValidation")) { - SwaggerUtils.validate(user); + OpenAPIUtils.validate(user); } } else { throw new IllegalArgumentException("'User' parameter is required"); diff --git a/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java b/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java new file mode 100644 index 00000000000..7f7d3f78484 --- /dev/null +++ b/samples/server/petstore/java-play-framework/app/openapitools/ApiCall.java @@ -0,0 +1,27 @@ +package openapitools; + +import com.google.inject.Inject; +import play.mvc.Action; +import play.mvc.Http; +import play.mvc.Result; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +public class ApiCall extends Action { + + @Inject + private ApiCall() {} + + public CompletionStage call(Http.Context ctx) { + try { + //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) + return delegate.call(ctx); + } catch (Throwable t) { + //TODO: log the error in your metric + + //We rethrow this error so it will be caught in the ErrorHandler + throw t; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/app/openapitools/ErrorHandler.java b/samples/server/petstore/java-play-framework/app/openapitools/ErrorHandler.java new file mode 100644 index 00000000000..cee7a1c4308 --- /dev/null +++ b/samples/server/petstore/java-play-framework/app/openapitools/ErrorHandler.java @@ -0,0 +1,49 @@ +package openapitools; + + +import play.*; +import play.api.OptionalSourceMapper; +import play.api.UsefulException; +import play.api.routing.Router; +import play.http.DefaultHttpErrorHandler; +import play.mvc.Http.*; +import play.mvc.*; + +import javax.inject.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import static play.mvc.Results.*; + +@Singleton +public class ErrorHandler extends DefaultHttpErrorHandler { + + @Inject + public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { + super(configuration, environment, sourceMapper, routes); + } + + @Override + protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { + return CompletableFuture.completedFuture( + handleExceptions(exception) + ); + } + + @Override + protected void logServerError(RequestHeader request, UsefulException usefulException) { + //Since the error is already handled, we don't want to print anything on the console + //But if you want to have the error printed in the console, just delete this override + } + + private Result handleExceptions(Throwable t) { + //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) + return ok(); + } +} diff --git a/samples/server/petstore/java-play-framework/app/openapitools/OpenAPIUtils.java b/samples/server/petstore/java-play-framework/app/openapitools/OpenAPIUtils.java new file mode 100644 index 00000000000..c707ca74ac7 --- /dev/null +++ b/samples/server/petstore/java-play-framework/app/openapitools/OpenAPIUtils.java @@ -0,0 +1,103 @@ +package openapitools; + +import play.mvc.With; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +public class OpenAPIUtils { + + @With(ApiCall.class) + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + public @interface ApiAction { + } + + public static void validate(T obj) { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> constraintViolations = validator.validate(obj); + if (constraintViolations.size() > 0) { + StringBuilder errors = new StringBuilder(); + for (ConstraintViolation contraintes : constraintViolations) { + errors.append(String.format("%s.%s %s\n", + contraintes.getRootBeanClass().getSimpleName(), + contraintes.getPropertyPath(), + contraintes.getMessage())); + } + throw new RuntimeException("Bean validation : " + errors); + } + } + + public static List parametersToList(String collectionFormat, String[] values){ + List params = new ArrayList<>(); + + if (values == null) { + return params; + } + + if (values.length >= 1 && collectionFormat.equals("multi")) { + params.addAll(Arrays.asList(values)); + } else { + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + String delimiter = ","; + + switch(collectionFormat) { + case "csv": { + delimiter = ","; + break; + } + case "ssv": { + delimiter = " "; + break; + } + case "tsv": { + delimiter = "\t"; + break; + } + case "pipes": { + delimiter = "|"; + break; + } + } + + params = Arrays.asList(values[0].split(delimiter)); + } + + return params; + } + + public static String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDatetime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection)param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + + return b.toString(); + } else { + return String.valueOf(param); + } + } + + public static String formatDatetime(Date date) { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/app/swagger/ApiCall.java b/samples/server/petstore/java-play-framework/app/swagger/ApiCall.java deleted file mode 100644 index 2ca308045b6..00000000000 --- a/samples/server/petstore/java-play-framework/app/swagger/ApiCall.java +++ /dev/null @@ -1,27 +0,0 @@ -package swagger; - -import com.google.inject.Inject; -import play.mvc.Action; -import play.mvc.Http; -import play.mvc.Result; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; - -public class ApiCall extends Action { - - @Inject - private ApiCall() {} - - public CompletionStage call(Http.Context ctx) { - try { - //TODO: Do stuff you want to handle with each API call (metrics, logging, etc..) - return delegate.call(ctx); - } catch (Throwable t) { - //TODO: log the error in your metric - - //We rethrow this error so it will be caught in the ErrorHandler - throw t; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/app/swagger/ErrorHandler.java b/samples/server/petstore/java-play-framework/app/swagger/ErrorHandler.java deleted file mode 100644 index 2c813411a5e..00000000000 --- a/samples/server/petstore/java-play-framework/app/swagger/ErrorHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package swagger; - - -import play.*; -import play.api.OptionalSourceMapper; -import play.api.UsefulException; -import play.api.routing.Router; -import play.http.DefaultHttpErrorHandler; -import play.mvc.Http.*; -import play.mvc.*; - -import javax.inject.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import static play.mvc.Results.*; - -@Singleton -public class ErrorHandler extends DefaultHttpErrorHandler { - - @Inject - public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider routes) { - super(configuration, environment, sourceMapper, routes); - } - - @Override - protected CompletionStage onDevServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected CompletionStage onProdServerError(RequestHeader request, UsefulException exception) { - return CompletableFuture.completedFuture( - handleExceptions(exception) - ); - } - - @Override - protected void logServerError(RequestHeader request, UsefulException usefulException) { - //Since the error is already handled, we don't want to print anything on the console - //But if you want to have the error printed in the console, just delete this override - } - - private Result handleExceptions(Throwable t) { - //TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..) - return ok(); - } -} diff --git a/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java b/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java deleted file mode 100644 index d4900e02167..00000000000 --- a/samples/server/petstore/java-play-framework/app/swagger/SwaggerUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package swagger; - -import play.mvc.With; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.text.SimpleDateFormat; -import java.util.*; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -public class SwaggerUtils { - - @With(ApiCall.class) - @Target({ ElementType.TYPE, ElementType.METHOD }) - @Retention(RetentionPolicy.RUNTIME) - public @interface ApiAction { - } - - public static void validate(T obj) { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - Validator validator = factory.getValidator(); - Set> constraintViolations = validator.validate(obj); - if (constraintViolations.size() > 0) { - StringBuilder errors = new StringBuilder(); - for (ConstraintViolation contraintes : constraintViolations) { - errors.append(String.format("%s.%s %s\n", - contraintes.getRootBeanClass().getSimpleName(), - contraintes.getPropertyPath(), - contraintes.getMessage())); - } - throw new RuntimeException("Bean validation : " + errors); - } - } - - public static List parametersToList(String collectionFormat, String[] values){ - List params = new ArrayList<>(); - - if (values == null) { - return params; - } - - if (values.length >= 1 && collectionFormat.equals("multi")) { - params.addAll(Arrays.asList(values)); - } else { - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv - - String delimiter = ","; - - switch(collectionFormat) { - case "csv": { - delimiter = ","; - break; - } - case "ssv": { - delimiter = " "; - break; - } - case "tsv": { - delimiter = "\t"; - break; - } - case "pipes": { - delimiter = "|"; - break; - } - } - - params = Arrays.asList(values[0].split(delimiter)); - } - - return params; - } - - public static String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date) { - return formatDatetime((Date) param); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection)param) { - if (b.length() > 0) { - b.append(","); - } - b.append(String.valueOf(o)); - } - - return b.toString(); - } else { - return String.valueOf(param); - } - } - - public static String formatDatetime(Date date) { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date); - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/conf/application.conf b/samples/server/petstore/java-play-framework/conf/application.conf index bcd07672dc1..fcc5c0499a2 100644 --- a/samples/server/petstore/java-play-framework/conf/application.conf +++ b/samples/server/petstore/java-play-framework/conf/application.conf @@ -17,7 +17,7 @@ play.filters.headers.contentSecurityPolicy=null -# When using bean validation with the swagger api, the validator will check that every constraint is respected +# When using bean validation with the OpenAPI API, the validator will check that every constraint is respected # This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have # shown that the time it takes to validate is exponential. # If this is a concern in your application, or if you don't want to validate the output coming from your API for @@ -26,7 +26,7 @@ play.filters.headers.contentSecurityPolicy=null useInputBeanValidation=true useOutputBeanValidation=true -play.http.errorHandler="swagger.ErrorHandler" +play.http.errorHandler="openapitools.ErrorHandler" ## Akka # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration diff --git a/samples/server/petstore/java-play-framework/public/openapi.json b/samples/server/petstore/java-play-framework/public/openapi.json new file mode 100644 index 00000000000..085c36fa397 --- /dev/null +++ b/samples/server/petstore/java-play-framework/public/openapi.json @@ -0,0 +1,1048 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "Swagger Petstore", + "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache-2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "name" : "pet", + "description" : "Everything about your Pets", + "externalDocs" : { + "description" : "Find out more", + "url" : "http://swagger.io" + } + }, { + "name" : "store", + "description" : "Access to Petstore orders" + }, { + "name" : "user", + "description" : "Operations about user", + "externalDocs" : { + "description" : "Find out more about our store", + "url" : "http://swagger.io" + } + } ], + "paths" : { + "/pet" : { + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "operationId" : "updatePet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + }, + "405" : { + "description" : "Validation exception", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "operationId" : "addPet", + "requestBody" : { + "description" : "Pet object that needs to be added to the store", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "required" : true + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/json", + "x-accepts" : "application/json" + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string", + "default" : "available", + "enum" : [ "available", "pending", "sold" ] + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid status value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : true, + "explode" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + } + }, + "400" : { + "description" : "Invalid tag value", + "content" : { } + } + }, + "deprecated" : true, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to return", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Pet not found", + "content" : { } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "properties" : { + "name" : { + "type" : "string", + "description" : "Updated name of the pet" + }, + "status" : { + "type" : "string", + "description" : "Updated status of the pet" + } + } + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "application/x-www-form-urlencoded", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "operationId" : "deletePet", + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "schema" : { + "type" : "string" + } + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value", + "content" : { } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-accepts" : "application/json" + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "operationId" : "uploadFile", + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "properties" : { + "additionalMetadata" : { + "type" : "string", + "description" : "Additional data to pass to server" + }, + "file" : { + "type" : "string", + "description" : "file to upload", + "format" : "binary" + } + } + } + } + } + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + } + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "x-contentType" : "multipart/form-data", + "x-accepts" : "application/json" + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/json" : { + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "x-accepts" : "application/json" + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "operationId" : "placeOrder", + "requestBody" : { + "description" : "order placed for purchasing the pet", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid Order", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "schema" : { + "maximum" : 5, + "minimum" : 1, + "type" : "integer", + "format" : "int64" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + } + }, + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied", + "content" : { } + }, + "404" : { + "description" : "Order not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "description" : "Created user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "description" : "List of user object", + "content" : { + "*/*" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "operationId" : "loginUser", + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, + "X-Expires-After" : { + "description" : "date in UTC when toekn expires", + "schema" : { + "type" : "string", + "format" : "date-time" + } + } + }, + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + } + }, + "400" : { + "description" : "Invalid username/password supplied", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "operationId" : "getUserByName", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing.", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + } + }, + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "description" : "Updated user object", + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-contentType" : "*/*", + "x-accepts" : "application/json" + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied", + "content" : { } + }, + "404" : { + "description" : "User not found", + "content" : { } + } + }, + "x-accepts" : "application/json" + } + } + }, + "components" : { + "schemas" : { + "Order" : { + "title" : "Pet Order", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean", + "default" : false + } + }, + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "title" : "Pet category", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "xml" : { + "name" : "Category" + } + }, + "User" : { + "title" : "a User", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "description" : "User Status", + "format" : "int32" + } + }, + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "title" : "Pet Tag", + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "title" : "a Pet", + "required" : [ "name", "photoUrls" ], + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + }, + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + }, + "items" : { + "$ref" : "#/components/schemas/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "title" : "An uploaded response", + "type" : "object", + "properties" : { + "code" : { + "type" : "integer", + "format" : "int32" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } + } + }, + "securitySchemes" : { + "petstore_auth" : { + "type" : "oauth2", + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + } + }, + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/public/swagger.json b/samples/server/petstore/java-play-framework/public/swagger.json deleted file mode 100644 index 01499dcfd25..00000000000 --- a/samples/server/petstore/java-play-framework/public/swagger.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "openapi" : "3.0.1", - "info" : { - "title" : "Swagger Petstore", - "description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", - "termsOfService" : "http://swagger.io/terms/", - "contact" : { - "email" : "apiteam@swagger.io" - }, - "license" : { - "name" : "Apache-2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "name" : "pet", - "description" : "Everything about your Pets", - "externalDocs" : { - "description" : "Find out more", - "url" : "http://swagger.io" - } - }, { - "name" : "store", - "description" : "Access to Petstore orders" - }, { - "name" : "user", - "description" : "Operations about user", - "externalDocs" : { - "description" : "Find out more about our store", - "url" : "http://swagger.io" - } - } ], - "paths" : { - "/pet" : { - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "operationId" : "updatePet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - }, - "405" : { - "description" : "Validation exception", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "operationId" : "addPet", - "requestBody" : { - "description" : "Pet object that needs to be added to the store", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "required" : true - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/json", - "x-accepts" : "application/json" - } - }, - "/pet/findByStatus" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "name" : "status", - "in" : "query", - "description" : "Status values that need to be considered for filter", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string", - "default" : "available", - "enum" : [ "available", "pending", "sold" ] - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid status value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/findByTags" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "name" : "tags", - "in" : "query", - "description" : "Tags to filter by", - "required" : true, - "explode" : false, - "schema" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - } - }, - "400" : { - "description" : "Invalid tag value", - "content" : { } - } - }, - "deprecated" : true, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to return", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be updated", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "properties" : { - "name" : { - "type" : "string", - "description" : "Updated name of the pet" - }, - "status" : { - "type" : "string", - "description" : "Updated status of the pet" - } - } - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "application/x-www-form-urlencoded", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "operationId" : "deletePet", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "schema" : { - "type" : "string" - } - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-accepts" : "application/json" - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", - "operationId" : "uploadFile", - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to update", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "properties" : { - "additionalMetadata" : { - "type" : "string", - "description" : "Additional data to pass to server" - }, - "file" : { - "type" : "string", - "description" : "file to upload", - "format" : "binary" - } - } - } - } - } - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "x-contentType" : "multipart/form-data", - "x-accepts" : "application/json" - } - }, - "/store/inventory" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/json" : { - "schema" : { - "type" : "object", - "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } - } - } - } - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "x-accepts" : "application/json" - } - }, - "/store/order" : { - "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", - "operationId" : "placeOrder", - "requestBody" : { - "description" : "order placed for purchasing the pet", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "required" : true - }, - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid Order", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/store/order/{orderId}" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "schema" : { - "maximum" : 5, - "minimum" : 1, - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "description" : "Created user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "description" : "List of user object", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "operationId" : "loginUser", - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when toekn expires", - "schema" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - } - }, - "400" : { - "description" : "Invalid username/password supplied", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "operationId" : "getUserByName", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing.", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Updated user object", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-contentType" : "*/*", - "x-accepts" : "application/json" - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - }, - "x-accepts" : "application/json" - } - } - }, - "components" : { - "schemas" : { - "Order" : { - "title" : "Pet Order", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "petId" : { - "type" : "integer", - "format" : "int64" - }, - "quantity" : { - "type" : "integer", - "format" : "int32" - }, - "shipDate" : { - "type" : "string", - "format" : "date-time" - }, - "status" : { - "type" : "string", - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] - }, - "complete" : { - "type" : "boolean", - "default" : false - } - }, - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "title" : "Pet category", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "xml" : { - "name" : "Category" - } - }, - "User" : { - "title" : "a User", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "description" : "User Status", - "format" : "int32" - } - }, - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "title" : "Pet Tag", - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "title" : "a Pet", - "required" : [ "name", "photoUrls" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "type" : "string", - "example" : "doggie" - }, - "photoUrls" : { - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - }, - "items" : { - "type" : "string" - } - }, - "tags" : { - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" - } - }, - "status" : { - "type" : "string", - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] - } - }, - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "title" : "An uploaded response", - "type" : "object", - "properties" : { - "code" : { - "type" : "integer", - "format" : "int32" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "description" : "Describes the result of uploading an image resource" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "type" : "oauth2", - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - } - }, - "api_key" : { - "type" : "apiKey", - "name" : "api_key", - "in" : "header" - } - } - } -} \ No newline at end of file