From 8bd2dd4c9dc0d8445f1986d024ce1bd0552b0001 Mon Sep 17 00:00:00 2001 From: Oleh Kurpiak Date: Mon, 24 Aug 2020 12:03:21 +0300 Subject: [PATCH] [Java] [Spring] Spring new mapping annotations (#7189) * Spring new mapping annotations * update other spring mvc templates --- .../main/resources/JavaSpring/api.mustache | 22 ++-- .../main/resources/java-pkmst/api.mustache | 19 ++- .../main/resources/kotlin-spring/api.mustache | 23 ++-- .../kotlin-spring/apiInterface.mustache | 22 ++-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../kotlin/org/openapitools/api/PetApi.kt | 59 ++++----- .../kotlin/org/openapitools/api/StoreApi.kt | 33 ++--- .../kotlin/org/openapitools/api/UserApi.kt | 57 ++++----- .../kotlin/org/openapitools/api/PetApi.kt | 59 ++++----- .../kotlin/org/openapitools/api/StoreApi.kt | 33 ++--- .../kotlin/org/openapitools/api/UserApi.kt | 57 ++++----- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- .../virtualan/api/AnotherFakeApi.java | 18 +-- .../openapitools/virtualan/api/FakeApi.java | 114 ++++++++++-------- .../virtualan/api/FakeClassnameTestApi.java | 18 +-- .../openapitools/virtualan/api/PetApi.java | 65 +++++----- .../openapitools/virtualan/api/StoreApi.java | 35 +++--- .../openapitools/virtualan/api/UserApi.java | 53 ++++---- .../org/openapitools/api/AnotherFakeApi.java | 18 +-- .../java/org/openapitools/api/FakeApi.java | 114 ++++++++++-------- .../api/FakeClassnameTestApi.java | 18 +-- .../java/org/openapitools/api/PetApi.java | 65 +++++----- .../java/org/openapitools/api/StoreApi.java | 35 +++--- .../java/org/openapitools/api/UserApi.java | 53 ++++---- 85 files changed, 2026 insertions(+), 2150 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache index 0f42c448ee..5d66c4998b 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache @@ -20,14 +20,7 @@ import org.springframework.http.ResponseEntity; {{#useBeanValidation}} import org.springframework.validation.annotation.Validated; {{/useBeanValidation}} -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; {{#jdk8-no-delegate}} {{^reactive}} import org.springframework.web.context.request.NativeWebRequest; @@ -124,12 +117,13 @@ public interface {{classname}} { {{/headerParams}} }) {{/implicitHeaders}} - @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}{{#hasProduces}} - produces = "{{{vendorExtensions.x-accepts}}}", {{/hasProduces}}{{#hasConsumes}} - consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} - consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} - method = RequestMethod.{{httpMethod}}) + @{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Mapping( + value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}}, + produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}}, + consumes = "{{{vendorExtensions.x-contentType}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, + produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}}, + consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}} + ) {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#reactive}}, {{/reactive}}{{/hasMore}}{{/allParams}}{{#reactive}}ServerWebExchange exchange{{/reactive}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { {{#delegate-method}} return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}); diff --git a/modules/openapi-generator/src/main/resources/java-pkmst/api.mustache b/modules/openapi-generator/src/main/resources/java-pkmst/api.mustache index bf5b1dc268..b64c95ba04 100644 --- a/modules/openapi-generator/src/main/resources/java-pkmst/api.mustache +++ b/modules/openapi-generator/src/main/resources/java-pkmst/api.mustache @@ -13,13 +13,7 @@ import io.swagger.annotations.*; import org.springframework.http.HttpStatus; {{/jdk8}} import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; {{^useSpringCloudClient}} import java.io.IOException; @@ -62,12 +56,13 @@ public interface {{classname}} { {{#headerParams}}{{>implicitHeader}}{{/headerParams}} }) {{/implicitHeaders}} - @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} + @{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Mapping( + value = "{{{path}}}"{{#singleContentTypes}}, produces = "{{{vendorExtensions.x-accepts}}}", - consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} - consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} - method = RequestMethod.{{httpMethod}}) + consumes = "{{{vendorExtensions.x-contentType}}}"{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, + produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}}, + consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}} + ) {{#useSpringCloudClient}} {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { // do some magic! diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache index 22f9536fae..8e171d4cb2 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache @@ -15,14 +15,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* {{#useBeanValidation}} import org.springframework.validation.annotation.Validated {{/useBeanValidation}} @@ -70,13 +63,13 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v authorizations = [{{#authMethods}}Authorization(value = "{{name}}"{{#isOAuth}}, scopes = [{{#scopes}}AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, {{/hasMore}}{{/scopes}}]{{/isOAuth}}){{#hasMore}}, {{/hasMore}}{{/authMethods}}]{{/hasAuthMethods}}) @ApiResponses( value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}}]){{/swaggerAnnotations}} - @RequestMapping( - value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"],{{#singleContentTypes}}{{#hasProduces}} - produces = "{{{vendorExtensions.x-accepts}}}",{{/hasProduces}}{{#hasConsumes}} - consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = [{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}], {{/hasProduces}}{{#hasConsumes}} - consumes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}],{{/hasConsumes}}{{/singleContentTypes}} - method = [RequestMethod.{{httpMethod}}]) + @{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Mapping( + value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"]{{#singleContentTypes}}{{#hasProduces}}, + produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}}, + consumes = "{{{vendorExtensions.x-contentType}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, + produces = [{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}}, + consumes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}} + ) {{#reactive}}{{^isListContainer}}suspend {{/isListContainer}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> { return {{>returnValue}} } diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache index 4fab920120..a0f3113f20 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache @@ -20,13 +20,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.* {{#useBeanValidation}} import org.springframework.validation.annotation.Validated {{/useBeanValidation}} @@ -77,13 +71,13 @@ interface {{classname}} { authorizations = [{{#authMethods}}Authorization(value = "{{name}}"{{#isOAuth}}, scopes = [{{#scopes}}AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, {{/hasMore}}{{/scopes}}]{{/isOAuth}}){{#hasMore}}, {{/hasMore}}{{/authMethods}}]{{/hasAuthMethods}}) @ApiResponses( value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}}]){{/swaggerAnnotations}} - @RequestMapping( - value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"],{{#singleContentTypes}}{{#hasProduces}} - produces = "{{{vendorExtensions.x-accepts}}}",{{/hasProduces}}{{#hasConsumes}} - consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}], {{/hasProduces}}{{#hasConsumes}} - consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}],{{/hasConsumes}}{{/singleContentTypes}} - method = [RequestMethod.{{httpMethod}}]) + @{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Mapping( + value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"]{{#singleContentTypes}}{{#hasProduces}}, + produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}}, + consumes = "{{{vendorExtensions.x-contentType}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, + produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}}, + consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}} + ) {{#reactive}}{{^isListContainer}}suspend {{/isListContainer}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> { {{^isDelegate}} return {{>returnValue}} diff --git a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java index eaf6262dc6..e176f39afc 100644 --- a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/PetApi.java @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,9 +42,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = "application/json", - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = "application/json" + ) CompletableFuture> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -70,8 +64,9 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @@ -92,9 +87,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = "application/json" + ) CompletableFuture>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @@ -116,9 +112,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = "application/json" + ) CompletableFuture>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @@ -138,9 +135,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = "application/json" + ) CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @@ -162,9 +160,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = "application/json", - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = "application/json" + ) CompletableFuture> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -184,9 +183,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = "application/x-www-form-urlencoded", - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); @@ -206,10 +206,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = "application/json", - consumes = "multipart/form-data", - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file); } diff --git a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java index 2a6251140f..5f1ac1ea33 100644 --- a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -46,8 +39,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{orderId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{orderId}" + ) CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId); @@ -62,9 +56,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = "application/json" + ) CompletableFuture>> getInventory(); @@ -82,9 +77,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{orderId}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{orderId}", + produces = "application/json" + ) CompletableFuture> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId); @@ -99,9 +95,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = "application/json", - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = "application/json" + ) CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java index fd4e234fb8..4ce7658349 100644 --- a/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-cloud-async/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -44,8 +37,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) CompletableFuture> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @@ -58,8 +52,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) CompletableFuture> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -72,8 +67,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) CompletableFuture> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -89,8 +85,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @@ -107,9 +104,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = "application/json" + ) CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username); @@ -125,9 +123,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = "application/json" + ) CompletableFuture> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @@ -139,8 +138,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) CompletableFuture> logoutUser(); @@ -157,8 +157,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java index 7bc16f34a3..4def4ffb3b 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/PetApi.java @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -48,9 +41,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = "application/json", - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = "application/json" + ) com.netflix.hystrix.HystrixCommand> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -69,8 +63,9 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) com.netflix.hystrix.HystrixCommand> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @@ -91,9 +86,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @@ -115,9 +111,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags); @@ -137,9 +134,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @@ -161,9 +159,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = "application/json", - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = "application/json" + ) com.netflix.hystrix.HystrixCommand> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -183,9 +182,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = "application/x-www-form-urlencoded", - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) com.netflix.hystrix.HystrixCommand> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); @@ -205,10 +205,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = "application/json", - consumes = "multipart/form-data", - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) com.netflix.hystrix.HystrixCommand> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file); } diff --git a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java index 75e8d381d7..e9581b31f7 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -45,8 +38,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{orderId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{orderId}" + ) com.netflix.hystrix.HystrixCommand> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId); @@ -61,9 +55,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand>> getInventory(); @@ -81,9 +76,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{orderId}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{orderId}", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId); @@ -98,9 +94,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = "application/json", - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java index 730f106451..77ce955ac3 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -43,8 +36,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) com.netflix.hystrix.HystrixCommand> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @@ -57,8 +51,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) com.netflix.hystrix.HystrixCommand> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -71,8 +66,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) com.netflix.hystrix.HystrixCommand> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -88,8 +84,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) com.netflix.hystrix.HystrixCommand> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @@ -106,9 +103,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username); @@ -124,9 +122,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = "application/json" + ) com.netflix.hystrix.HystrixCommand> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @@ -138,8 +137,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) com.netflix.hystrix.HystrixCommand> logoutUser(); @@ -156,8 +156,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) com.netflix.hystrix.HystrixCommand> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java index 9ebeb1a6fc..e2a3462e1e 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/PetApi.java @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -52,9 +45,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = "application/json", - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = "application/json" + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -76,8 +70,9 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -101,9 +96,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = "application/json" + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -142,9 +138,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = "application/json" + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -181,9 +178,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = "application/json" + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -222,9 +220,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = "application/json", - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = "application/json" + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -247,9 +246,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = "application/x-www-form-urlencoded", - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = "application/x-www-form-urlencoded" + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -272,10 +272,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = "application/json", - consumes = "multipart/form-data", - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = "application/json", + consumes = "multipart/form-data" + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java index e47b3272c4..11de986389 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,8 +42,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{orderId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{orderId}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -68,9 +62,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = "application/json" + ) default ResponseEntity> getInventory() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -91,9 +86,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{orderId}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{orderId}", + produces = "application/json" + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -125,9 +121,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = "application/json", - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = "application/json" + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java index f7fcd5c1fb..e0142043d7 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -47,8 +40,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -64,8 +58,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +76,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -101,8 +97,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -122,9 +119,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = "application/json" + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -157,9 +155,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = "application/json", - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = "application/json" + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -174,8 +173,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -195,8 +195,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApi.kt index 1dca81e1b9..7ac18d95d8 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest import org.springframework.beans.factory.annotation.Autowired @@ -51,10 +44,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 405, message = "Invalid input")]) - @RequestMapping( + @PostMapping( value = ["/pet"], - consumes = ["application/json", "application/xml"], - method = [RequestMethod.POST]) + consumes = ["application/json", "application/xml"] + ) suspend fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet ): ResponseEntity { return ResponseEntity(service.addPet(body), HttpStatus.valueOf(405)) @@ -67,9 +60,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid pet value")]) - @RequestMapping( - value = ["/pet/{petId}"], - method = [RequestMethod.DELETE]) + @DeleteMapping( + value = ["/pet/{petId}"] + ) suspend fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: kotlin.Long ,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: kotlin.String? ): ResponseEntity { @@ -85,10 +78,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid status value")]) - @RequestMapping( + @GetMapping( value = ["/pet/findByStatus"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List ): ResponseEntity> { return ResponseEntity(service.findPetsByStatus(status), HttpStatus.valueOf(200)) @@ -103,10 +96,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid tag value")]) - @RequestMapping( + @GetMapping( value = ["/pet/findByTags"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List ): ResponseEntity> { return ResponseEntity(service.findPetsByTags(tags), HttpStatus.valueOf(200)) @@ -120,10 +113,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "api_key")]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found")]) - @RequestMapping( + @GetMapping( value = ["/pet/{petId}"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) suspend fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: kotlin.Long ): ResponseEntity { return ResponseEntity(service.getPetById(petId), HttpStatus.valueOf(200)) @@ -136,10 +129,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found"),ApiResponse(code = 405, message = "Validation exception")]) - @RequestMapping( + @PutMapping( value = ["/pet"], - consumes = ["application/json", "application/xml"], - method = [RequestMethod.PUT]) + consumes = ["application/json", "application/xml"] + ) suspend fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet ): ResponseEntity { return ResponseEntity(service.updatePet(body), HttpStatus.valueOf(400)) @@ -152,10 +145,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 405, message = "Invalid input")]) - @RequestMapping( + @PostMapping( value = ["/pet/{petId}"], - consumes = ["application/x-www-form-urlencoded"], - method = [RequestMethod.POST]) + consumes = ["application/x-www-form-urlencoded"] + ) suspend fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: kotlin.Long ,@ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) name: kotlin.String? ,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) status: kotlin.String? @@ -171,11 +164,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)]) - @RequestMapping( + @PostMapping( value = ["/pet/{petId}/uploadImage"], - produces = ["application/json"], - consumes = ["multipart/form-data"], - method = [RequestMethod.POST]) + produces = ["application/json"], + consumes = ["multipart/form-data"] + ) suspend fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: kotlin.Long ,@ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: kotlin.String? ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource? diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApi.kt index 35d8d3cbe0..dde98ffba0 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest import org.springframework.beans.factory.annotation.Autowired @@ -49,9 +42,9 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors") @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")]) - @RequestMapping( - value = ["/store/order/{orderId}"], - method = [RequestMethod.DELETE]) + @DeleteMapping( + value = ["/store/order/{orderId}"] + ) suspend fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: kotlin.String ): ResponseEntity { return ResponseEntity(service.deleteOrder(orderId), HttpStatus.valueOf(400)) @@ -66,10 +59,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic authorizations = [Authorization(value = "api_key")]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")]) - @RequestMapping( + @GetMapping( value = ["/store/inventory"], - produces = ["application/json"], - method = [RequestMethod.GET]) + produces = ["application/json"] + ) suspend fun getInventory(): ResponseEntity> { return ResponseEntity(service.getInventory(), HttpStatus.valueOf(200)) } @@ -81,10 +74,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic response = Order::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")]) - @RequestMapping( + @GetMapping( value = ["/store/order/{orderId}"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) suspend fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: kotlin.Long ): ResponseEntity { return ResponseEntity(service.getOrderById(orderId), HttpStatus.valueOf(200)) @@ -97,10 +90,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic response = Order::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid Order")]) - @RequestMapping( + @PostMapping( value = ["/store/order"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.POST]) + produces = ["application/xml", "application/json"] + ) suspend fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order ): ResponseEntity { return ResponseEntity(service.placeOrder(body), HttpStatus.valueOf(200)) diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/UserApi.kt index 7fdaa627b7..d369aefe48 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest import org.springframework.beans.factory.annotation.Autowired @@ -49,9 +42,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "This can only be done by the logged in user.") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user"], - method = [RequestMethod.POST]) + @PostMapping( + value = ["/user"] + ) suspend fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody body: User ): ResponseEntity { return ResponseEntity(service.createUser(body), HttpStatus.valueOf(200)) @@ -63,9 +56,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user/createWithArray"], - method = [RequestMethod.POST]) + @PostMapping( + value = ["/user/createWithArray"] + ) suspend fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: Flow ): ResponseEntity { return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.valueOf(200)) @@ -77,9 +70,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user/createWithList"], - method = [RequestMethod.POST]) + @PostMapping( + value = ["/user/createWithList"] + ) suspend fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: Flow ): ResponseEntity { return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.valueOf(200)) @@ -91,9 +84,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "This can only be done by the logged in user.") @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")]) - @RequestMapping( - value = ["/user/{username}"], - method = [RequestMethod.DELETE]) + @DeleteMapping( + value = ["/user/{username}"] + ) suspend fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: kotlin.String ): ResponseEntity { return ResponseEntity(service.deleteUser(username), HttpStatus.valueOf(400)) @@ -106,10 +99,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) response = User::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = User::class),ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")]) - @RequestMapping( + @GetMapping( value = ["/user/{username}"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) suspend fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: kotlin.String ): ResponseEntity { return ResponseEntity(service.getUserByName(username), HttpStatus.valueOf(200)) @@ -122,10 +115,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) response = kotlin.String::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.String::class),ApiResponse(code = 400, message = "Invalid username/password supplied")]) - @RequestMapping( + @GetMapping( value = ["/user/login"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) suspend fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String ,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String ): ResponseEntity { @@ -138,9 +131,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user/logout"], - method = [RequestMethod.GET]) + @GetMapping( + value = ["/user/logout"] + ) suspend fun logoutUser(): ResponseEntity { return ResponseEntity(service.logoutUser(), HttpStatus.valueOf(200)) } @@ -151,9 +144,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "This can only be done by the logged in user.") @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")]) - @RequestMapping( - value = ["/user/{username}"], - method = [RequestMethod.PUT]) + @PutMapping( + value = ["/user/{username}"] + ) suspend fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: kotlin.String ,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody body: User ): ResponseEntity { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt index 612713d99f..9de503175a 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest import org.springframework.beans.factory.annotation.Autowired @@ -50,10 +43,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 405, message = "Invalid input")]) - @RequestMapping( + @PostMapping( value = ["/pet"], - consumes = ["application/json", "application/xml"], - method = [RequestMethod.POST]) + consumes = ["application/json", "application/xml"] + ) fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet ): ResponseEntity { return ResponseEntity(service.addPet(body), HttpStatus.valueOf(405)) @@ -66,9 +59,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid pet value")]) - @RequestMapping( - value = ["/pet/{petId}"], - method = [RequestMethod.DELETE]) + @DeleteMapping( + value = ["/pet/{petId}"] + ) fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: kotlin.Long ,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: kotlin.String? ): ResponseEntity { @@ -84,10 +77,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid status value")]) - @RequestMapping( + @GetMapping( value = ["/pet/findByStatus"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List ): ResponseEntity> { return ResponseEntity(service.findPetsByStatus(status), HttpStatus.valueOf(200)) @@ -102,10 +95,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid tag value")]) - @RequestMapping( + @GetMapping( value = ["/pet/findByTags"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List ): ResponseEntity> { return ResponseEntity(service.findPetsByTags(tags), HttpStatus.valueOf(200)) @@ -119,10 +112,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "api_key")]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found")]) - @RequestMapping( + @GetMapping( value = ["/pet/{petId}"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: kotlin.Long ): ResponseEntity { return ResponseEntity(service.getPetById(petId), HttpStatus.valueOf(200)) @@ -135,10 +128,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found"),ApiResponse(code = 405, message = "Validation exception")]) - @RequestMapping( + @PutMapping( value = ["/pet"], - consumes = ["application/json", "application/xml"], - method = [RequestMethod.PUT]) + consumes = ["application/json", "application/xml"] + ) fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet ): ResponseEntity { return ResponseEntity(service.updatePet(body), HttpStatus.valueOf(400)) @@ -151,10 +144,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 405, message = "Invalid input")]) - @RequestMapping( + @PostMapping( value = ["/pet/{petId}"], - consumes = ["application/x-www-form-urlencoded"], - method = [RequestMethod.POST]) + consumes = ["application/x-www-form-urlencoded"] + ) fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: kotlin.Long ,@ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) name: kotlin.String? ,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) status: kotlin.String? @@ -170,11 +163,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)]) - @RequestMapping( + @PostMapping( value = ["/pet/{petId}/uploadImage"], - produces = ["application/json"], - consumes = ["multipart/form-data"], - method = [RequestMethod.POST]) + produces = ["application/json"], + consumes = ["multipart/form-data"] + ) fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: kotlin.Long ,@ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: kotlin.String? ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource? diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt index 99dfad74f4..3b82141c4d 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest import org.springframework.beans.factory.annotation.Autowired @@ -48,9 +41,9 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors") @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")]) - @RequestMapping( - value = ["/store/order/{orderId}"], - method = [RequestMethod.DELETE]) + @DeleteMapping( + value = ["/store/order/{orderId}"] + ) fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: kotlin.String ): ResponseEntity { return ResponseEntity(service.deleteOrder(orderId), HttpStatus.valueOf(400)) @@ -65,10 +58,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic authorizations = [Authorization(value = "api_key")]) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")]) - @RequestMapping( + @GetMapping( value = ["/store/inventory"], - produces = ["application/json"], - method = [RequestMethod.GET]) + produces = ["application/json"] + ) fun getInventory(): ResponseEntity> { return ResponseEntity(service.getInventory(), HttpStatus.valueOf(200)) } @@ -80,10 +73,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic response = Order::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")]) - @RequestMapping( + @GetMapping( value = ["/store/order/{orderId}"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: kotlin.Long ): ResponseEntity { return ResponseEntity(service.getOrderById(orderId), HttpStatus.valueOf(200)) @@ -96,10 +89,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic response = Order::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid Order")]) - @RequestMapping( + @PostMapping( value = ["/store/order"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.POST]) + produces = ["application/xml", "application/json"] + ) fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order ): ResponseEntity { return ResponseEntity(service.placeOrder(body), HttpStatus.valueOf(200)) diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt index d10327cd28..7071afde11 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestPart -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest import org.springframework.beans.factory.annotation.Autowired @@ -48,9 +41,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "This can only be done by the logged in user.") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user"], - method = [RequestMethod.POST]) + @PostMapping( + value = ["/user"] + ) fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody body: User ): ResponseEntity { return ResponseEntity(service.createUser(body), HttpStatus.valueOf(200)) @@ -62,9 +55,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user/createWithArray"], - method = [RequestMethod.POST]) + @PostMapping( + value = ["/user/createWithArray"] + ) fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: kotlin.collections.List ): ResponseEntity { return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.valueOf(200)) @@ -76,9 +69,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user/createWithList"], - method = [RequestMethod.POST]) + @PostMapping( + value = ["/user/createWithList"] + ) fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: kotlin.collections.List ): ResponseEntity { return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.valueOf(200)) @@ -90,9 +83,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "This can only be done by the logged in user.") @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")]) - @RequestMapping( - value = ["/user/{username}"], - method = [RequestMethod.DELETE]) + @DeleteMapping( + value = ["/user/{username}"] + ) fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: kotlin.String ): ResponseEntity { return ResponseEntity(service.deleteUser(username), HttpStatus.valueOf(400)) @@ -105,10 +98,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) response = User::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = User::class),ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")]) - @RequestMapping( + @GetMapping( value = ["/user/{username}"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: kotlin.String ): ResponseEntity { return ResponseEntity(service.getUserByName(username), HttpStatus.valueOf(200)) @@ -121,10 +114,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) response = kotlin.String::class) @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.String::class),ApiResponse(code = 400, message = "Invalid username/password supplied")]) - @RequestMapping( + @GetMapping( value = ["/user/login"], - produces = ["application/xml", "application/json"], - method = [RequestMethod.GET]) + produces = ["application/xml", "application/json"] + ) fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String ,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String ): ResponseEntity { @@ -137,9 +130,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "") @ApiResponses( value = [ApiResponse(code = 200, message = "successful operation")]) - @RequestMapping( - value = ["/user/logout"], - method = [RequestMethod.GET]) + @GetMapping( + value = ["/user/logout"] + ) fun logoutUser(): ResponseEntity { return ResponseEntity(service.logoutUser(), HttpStatus.valueOf(200)) } @@ -150,9 +143,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) notes = "This can only be done by the logged in user.") @ApiResponses( value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")]) - @RequestMapping( - value = ["/user/{username}"], - method = [RequestMethod.PUT]) + @PutMapping( + value = ["/user/{username}"] + ) fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: kotlin.String ,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody body: User ): ResponseEntity { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java index 31246e3dc8..d3850915d9 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -47,10 +40,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default CompletableFuture> call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java index 25c244ded2..a7b13bfcd2 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java @@ -21,14 +21,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -57,9 +50,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default CompletableFuture> createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -76,9 +70,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default CompletableFuture> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -95,9 +90,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default CompletableFuture> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -125,9 +121,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default CompletableFuture> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -144,9 +141,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default CompletableFuture> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -163,9 +161,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default CompletableFuture> testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -182,9 +181,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default CompletableFuture> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -201,10 +201,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -249,9 +250,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default CompletableFuture> testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -277,9 +279,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default CompletableFuture> testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -301,8 +304,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default CompletableFuture> testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -318,9 +322,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default CompletableFuture> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -337,9 +342,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default CompletableFuture> testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -360,8 +366,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default CompletableFuture> testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -384,10 +391,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default CompletableFuture> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index ad63ff9527..e343dabc18 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,10 +42,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default CompletableFuture> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java index 6883dcacee..84a23f7d31 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -56,9 +49,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default CompletableFuture> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -82,8 +76,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -107,9 +102,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default CompletableFuture>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -150,9 +146,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default CompletableFuture>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -191,9 +188,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -236,9 +234,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default CompletableFuture> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -261,9 +260,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -286,10 +286,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java index ea131aed27..df25ee2c7f 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -50,8 +43,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -69,9 +63,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default CompletableFuture>> getInventory() { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -92,9 +87,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default CompletableFuture> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -128,9 +124,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java index 4832b81b2a..b22ce9eacc 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -48,8 +41,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default CompletableFuture> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -65,8 +59,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default CompletableFuture> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -82,8 +77,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default CompletableFuture> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -102,8 +98,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -123,9 +120,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { @@ -160,9 +158,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default CompletableFuture> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -177,8 +176,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default CompletableFuture> logoutUser() { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); @@ -198,8 +198,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java index 2052f5808d..44f3e9bb93 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -46,10 +39,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java index 779131b34a..270d71950e 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java @@ -21,14 +21,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -56,9 +49,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -75,9 +69,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -94,9 +89,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -122,9 +118,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -141,9 +138,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -160,9 +158,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -179,9 +178,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -198,10 +198,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -244,9 +245,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) LocalDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -272,9 +274,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -296,8 +299,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -313,9 +317,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -332,9 +337,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -355,8 +361,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -379,10 +386,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 765feb5174..5742965028 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -48,10 +41,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java index 23311c253b..51080bb7d3 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -55,9 +48,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +75,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -106,9 +101,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -147,9 +143,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -186,9 +183,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -229,9 +227,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -254,9 +253,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -279,10 +279,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java index e135ad2702..831650ae3d 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,8 +42,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -68,9 +62,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default ResponseEntity> getInventory() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -91,9 +86,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -125,9 +121,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java index d19c52cdfd..f6b591946b 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -47,8 +40,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -64,8 +58,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +76,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -101,8 +97,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -122,9 +119,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -157,9 +155,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -174,8 +173,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -195,8 +195,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java index fef78e6b90..07b6801beb 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -38,10 +31,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java index 364b70eb9f..f2f112c575 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java @@ -19,14 +19,7 @@ import org.openapitools.model.XmlItem; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -48,9 +41,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem); @@ -64,9 +58,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); @@ -80,9 +75,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); @@ -96,9 +92,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); @@ -112,9 +109,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); @@ -128,9 +126,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body); @@ -144,9 +143,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body); @@ -160,10 +160,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @@ -194,9 +195,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback); @@ -219,9 +221,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString); @@ -240,8 +243,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group); @@ -254,9 +258,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param); @@ -270,9 +275,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2); @@ -290,8 +296,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context); @@ -311,10 +318,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 6a8919d2d1..723fc9f62a 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -40,10 +33,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java index 0c13bf4b97..7ab2f6e9d5 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApi.java @@ -12,14 +12,7 @@ import java.util.Set; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -47,9 +40,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -70,8 +64,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @@ -92,9 +87,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @@ -116,9 +112,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags); @@ -138,9 +135,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @@ -164,9 +162,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -186,9 +185,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status); @@ -208,10 +208,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java index fe89b207bf..0128cb2d54 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.Order; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -41,8 +34,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @@ -57,9 +51,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) ResponseEntity> getInventory(); @@ -77,9 +72,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @@ -94,9 +90,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java index 488b5b7c3a..e1d4245a6b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.User; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -39,8 +32,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @@ -53,8 +47,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -67,8 +62,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -84,8 +80,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @@ -102,9 +99,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username); @@ -120,9 +118,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @@ -134,8 +133,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) ResponseEntity logoutUser(); @@ -152,8 +152,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java index fef78e6b90..07b6801beb 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -38,10 +31,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java index 364b70eb9f..f2f112c575 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java @@ -19,14 +19,7 @@ import org.openapitools.model.XmlItem; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -48,9 +41,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem); @@ -64,9 +58,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); @@ -80,9 +75,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); @@ -96,9 +92,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); @@ -112,9 +109,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); @@ -128,9 +126,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body); @@ -144,9 +143,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body); @@ -160,10 +160,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @@ -194,9 +195,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback); @@ -219,9 +221,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString); @@ -240,8 +243,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group); @@ -254,9 +258,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param); @@ -270,9 +275,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2); @@ -290,8 +296,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context); @@ -311,10 +318,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 6a8919d2d1..723fc9f62a 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -40,10 +33,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java index 0c13bf4b97..7ab2f6e9d5 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/PetApi.java @@ -12,14 +12,7 @@ import java.util.Set; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -47,9 +40,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -70,8 +64,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @@ -92,9 +87,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @@ -116,9 +112,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags); @@ -138,9 +135,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @@ -164,9 +162,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -186,9 +185,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status); @@ -208,10 +208,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java index fe89b207bf..0128cb2d54 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/StoreApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.Order; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -41,8 +34,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @@ -57,9 +51,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) ResponseEntity> getInventory(); @@ -77,9 +72,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @@ -94,9 +90,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java index 488b5b7c3a..e1d4245a6b 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/UserApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.User; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -39,8 +32,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @@ -53,8 +47,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -67,8 +62,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -84,8 +80,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @@ -102,9 +99,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username); @@ -120,9 +118,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @@ -134,8 +133,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) ResponseEntity logoutUser(); @@ -152,8 +152,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java index b1aa060029..d0977d683d 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -42,10 +35,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return getDelegate().call123testSpecialTags(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java index 6be6042871..2c6f9356ff 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -19,14 +19,7 @@ import org.openapitools.model.XmlItem; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -52,9 +45,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return getDelegate().createXmlItem(xmlItem); } @@ -70,9 +64,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return getDelegate().fakeOuterBooleanSerialize(body); } @@ -88,9 +83,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { return getDelegate().fakeOuterCompositeSerialize(body); } @@ -106,9 +102,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return getDelegate().fakeOuterNumberSerialize(body); } @@ -124,9 +121,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return getDelegate().fakeOuterStringSerialize(body); } @@ -142,9 +140,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return getDelegate().testBodyWithFileSchema(body); } @@ -160,9 +159,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return getDelegate().testBodyWithQueryParams(query, body); } @@ -178,10 +178,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return getDelegate().testClientModel(body); } @@ -214,9 +215,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } @@ -241,9 +243,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); } @@ -264,8 +267,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); } @@ -280,9 +284,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return getDelegate().testInlineAdditionalProperties(param); } @@ -298,9 +303,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return getDelegate().testJsonFormData(param, param2); } @@ -320,8 +326,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); } @@ -343,10 +350,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index fe355dfca6..6b02c88400 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -44,10 +37,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { return getDelegate().testClassname(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java index fd05628030..ffdbde323f 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/PetApi.java @@ -12,14 +12,7 @@ import java.util.Set; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -51,9 +44,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return getDelegate().addPet(body); } @@ -76,8 +70,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return getDelegate().deletePet(petId, apiKey); } @@ -100,9 +95,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { return getDelegate().findPetsByStatus(status); } @@ -126,9 +122,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { return getDelegate().findPetsByTags(tags); } @@ -150,9 +147,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { return getDelegate().getPetById(petId); } @@ -178,9 +176,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return getDelegate().updatePet(body); } @@ -202,9 +201,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return getDelegate().updatePetWithForm(petId, name, status); } @@ -226,10 +226,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { return getDelegate().uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java index 17d14a277f..96c812bb69 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/StoreApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.Order; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -45,8 +38,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return getDelegate().deleteOrder(orderId); } @@ -63,9 +57,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default ResponseEntity> getInventory() { return getDelegate().getInventory(); } @@ -85,9 +80,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { return getDelegate().getOrderById(orderId); } @@ -104,9 +100,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { return getDelegate().placeOrder(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java index b63a472aeb..f572889cda 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/UserApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.User; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -43,8 +36,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return getDelegate().createUser(body); } @@ -59,8 +53,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return getDelegate().createUsersWithArrayInput(body); } @@ -75,8 +70,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return getDelegate().createUsersWithListInput(body); } @@ -94,8 +90,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return getDelegate().deleteUser(username); } @@ -114,9 +111,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { return getDelegate().getUserByName(username); } @@ -134,9 +132,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return getDelegate().loginUser(username, password); } @@ -150,8 +149,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return getDelegate().logoutUser(); } @@ -170,8 +170,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return getDelegate().updateUser(username, body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java index fef78e6b90..07b6801beb 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -38,10 +31,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index 364b70eb9f..f2f112c575 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -19,14 +19,7 @@ import org.openapitools.model.XmlItem; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -48,9 +41,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem); @@ -64,9 +58,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); @@ -80,9 +75,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); @@ -96,9 +92,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); @@ -112,9 +109,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); @@ -128,9 +126,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body); @@ -144,9 +143,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body); @@ -160,10 +160,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); @@ -194,9 +195,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback); @@ -219,9 +221,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString); @@ -240,8 +243,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group); @@ -254,9 +258,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param); @@ -270,9 +275,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2); @@ -290,8 +296,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context); @@ -311,10 +318,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 6a8919d2d1..723fc9f62a 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -40,10 +33,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java index 0c13bf4b97..7ab2f6e9d5 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApi.java @@ -12,14 +12,7 @@ import java.util.Set; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -47,9 +40,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -70,8 +64,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @@ -92,9 +87,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status); @@ -116,9 +112,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags); @@ -138,9 +135,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @@ -164,9 +162,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); @@ -186,9 +185,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status); @@ -208,10 +208,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java index fe89b207bf..0128cb2d54 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.Order; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -41,8 +34,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId); @@ -57,9 +51,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) ResponseEntity> getInventory(); @@ -77,9 +72,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); @@ -94,9 +90,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java index 488b5b7c3a..e1d4245a6b 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.User; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; @@ -39,8 +32,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); @@ -53,8 +47,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -67,8 +62,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); @@ -84,8 +80,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @@ -102,9 +99,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username); @@ -120,9 +118,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password); @@ -134,8 +133,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) ResponseEntity logoutUser(); @@ -152,8 +152,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java index c82299203b..f561fb8798 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -48,10 +41,11 @@ public interface AnotherFakeApi { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index b1cd89769a..5b22f17d3e 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -21,14 +21,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -58,9 +51,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -79,9 +73,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -100,9 +95,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -130,9 +126,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -151,9 +148,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -172,9 +170,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Success") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -193,9 +192,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Success") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -214,10 +214,11 @@ public interface FakeApi { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -262,9 +263,10 @@ public interface FakeApi { @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -292,9 +294,10 @@ public interface FakeApi { @ApiImplicitParam(name = "enumHeaderStringArray", value = "Header parameter enum test (string array)", dataType = "List", paramType = "header"), @ApiImplicitParam(name = "enumHeaderString", value = "Header parameter enum test (string)", dataType = "String", paramType = "header") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEnumParameters(@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -318,8 +321,9 @@ public interface FakeApi { @ApiImplicitParam(name = "requiredBooleanGroup", value = "Required Boolean in group parameters", required=true, dataType = "Boolean", paramType = "header"), @ApiImplicitParam(name = "booleanGroup", value = "Boolean in group parameters", dataType = "Boolean", paramType = "header") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -337,9 +341,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -358,9 +363,10 @@ public interface FakeApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -383,8 +389,9 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Success") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -409,10 +416,11 @@ public interface FakeApi { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index e0da9a4803..105f5a41d4 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -50,10 +43,11 @@ public interface FakeClassnameTestApi { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java index 05b6668260..9d616aca2b 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/PetApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -57,9 +50,10 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -85,8 +79,9 @@ public interface PetApi { @ApiImplicitParams({ @ApiImplicitParam(name = "apiKey", value = "", dataType = "String", paramType = "header") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -112,9 +107,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid status value") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -155,9 +151,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid tag value") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -196,9 +193,10 @@ public interface PetApi { @ApiResponse(code = 404, message = "Pet not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -241,9 +239,10 @@ public interface PetApi { @ApiResponse(code = 405, message = "Validation exception") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -268,9 +267,10 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -295,10 +295,11 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @ApiImplicitParams({ }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java index 7ee3a40eb7..2895f2dfd9 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -51,8 +44,9 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -72,9 +66,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default ResponseEntity> getInventory() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -97,9 +92,10 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -133,9 +129,10 @@ public interface StoreApi { @ApiResponse(code = 400, message = "Invalid Order") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java index c4b85c1f2a..35bb030e73 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,8 +42,9 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -68,8 +62,9 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -87,8 +82,9 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -109,8 +105,9 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -132,9 +129,10 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -169,9 +167,10 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username/password supplied") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -188,8 +187,9 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -211,8 +211,9 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java index bd4902862f..544839f39f 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; @@ -46,10 +39,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default Mono> call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().call123testSpecialTags(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java index 2b5c3369e1..479cb87d38 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -19,14 +19,7 @@ import org.openapitools.model.XmlItem; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; @@ -56,9 +49,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default Mono> createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody Mono xmlItem, ServerWebExchange exchange) { return getDelegate().createXmlItem(xmlItem, exchange); } @@ -74,9 +68,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default Mono> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterBooleanSerialize(body, exchange); } @@ -92,9 +87,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default Mono> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterCompositeSerialize(body, exchange); } @@ -110,9 +106,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default Mono> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterNumberSerialize(body, exchange); } @@ -128,9 +125,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default Mono> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterStringSerialize(body, exchange); } @@ -146,9 +144,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default Mono> testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().testBodyWithFileSchema(body, exchange); } @@ -164,9 +163,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default Mono> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().testBodyWithQueryParams(query, body, exchange); } @@ -182,10 +182,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default Mono> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().testClientModel(body, exchange); } @@ -218,9 +219,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default Mono> testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) Flux binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback, ServerWebExchange exchange) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, exchange); } @@ -245,9 +247,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default Mono> testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString, ServerWebExchange exchange) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, exchange); } @@ -268,8 +271,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default Mono> testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group, ServerWebExchange exchange) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, exchange); } @@ -284,9 +288,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default Mono> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Mono param, ServerWebExchange exchange) { return getDelegate().testInlineAdditionalProperties(param, exchange); } @@ -302,9 +307,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default Mono> testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2, ServerWebExchange exchange) { return getDelegate().testJsonFormData(param, param2, exchange); } @@ -324,8 +330,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default Mono> testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context, ServerWebExchange exchange) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, exchange); } @@ -347,10 +354,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default Mono> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) Flux requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, ServerWebExchange exchange) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 20d312afdb..3766a7ed92 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -9,14 +9,7 @@ import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; @@ -48,10 +41,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default Mono> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().testClassname(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java index c9bd79cf35..98f9da3e1b 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java @@ -12,14 +12,7 @@ import java.util.Set; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; @@ -55,9 +48,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default Mono> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().addPet(body, exchange); } @@ -80,8 +74,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default Mono> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, ServerWebExchange exchange) { return getDelegate().deletePet(petId, apiKey, exchange); } @@ -104,9 +99,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default Mono>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, ServerWebExchange exchange) { return getDelegate().findPetsByStatus(status, exchange); } @@ -130,9 +126,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default Mono>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags, ServerWebExchange exchange) { return getDelegate().findPetsByTags(tags, exchange); } @@ -154,9 +151,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default Mono> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, ServerWebExchange exchange) { return getDelegate().getPetById(petId, exchange); } @@ -182,9 +180,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default Mono> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().updatePet(body, exchange); } @@ -206,9 +205,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default Mono> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status, ServerWebExchange exchange) { return getDelegate().updatePetWithForm(petId, name, status, exchange); } @@ -230,10 +230,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default Mono> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) Flux file, ServerWebExchange exchange) { return getDelegate().uploadFile(petId, additionalMetadata, file, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java index 9eadfe25b2..05262bfd1e 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.Order; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; @@ -49,8 +42,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default Mono> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, ServerWebExchange exchange) { return getDelegate().deleteOrder(orderId, exchange); } @@ -67,9 +61,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default Mono>> getInventory(ServerWebExchange exchange) { return getDelegate().getInventory(exchange); } @@ -89,9 +84,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default Mono> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, ServerWebExchange exchange) { return getDelegate().getOrderById(orderId, exchange); } @@ -108,9 +104,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default Mono> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().placeOrder(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java index 3fdc4e8197..0c4ce1f019 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java @@ -10,14 +10,7 @@ import org.openapitools.model.User; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; @@ -47,8 +40,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default Mono> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().createUser(body, exchange); } @@ -63,8 +57,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default Mono> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody Flux body, ServerWebExchange exchange) { return getDelegate().createUsersWithArrayInput(body, exchange); } @@ -79,8 +74,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default Mono> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody Flux body, ServerWebExchange exchange) { return getDelegate().createUsersWithListInput(body, exchange); } @@ -98,8 +94,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default Mono> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, ServerWebExchange exchange) { return getDelegate().deleteUser(username, exchange); } @@ -118,9 +115,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default Mono> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username, ServerWebExchange exchange) { return getDelegate().getUserByName(username, exchange); } @@ -138,9 +136,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default Mono> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, ServerWebExchange exchange) { return getDelegate().loginUser(username, password, exchange); } @@ -154,8 +153,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default Mono> logoutUser(ServerWebExchange exchange) { return getDelegate().logoutUser(exchange); } @@ -174,8 +174,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default Mono> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { return getDelegate().updateUser(username, body, exchange); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java index 2052f5808d..44f3e9bb93 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -46,10 +39,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java index b0855540d1..ae3e51ac6b 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java @@ -21,14 +21,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -56,9 +49,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -75,9 +69,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -94,9 +89,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -122,9 +118,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -141,9 +138,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -160,9 +158,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -179,9 +178,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -198,10 +198,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -244,9 +245,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -272,9 +274,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Optional enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -296,8 +299,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Optional stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Optional booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Optional int64Group) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -313,9 +317,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -332,9 +337,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -355,8 +361,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -379,10 +386,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 765feb5174..5742965028 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -48,10 +41,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java index 53c4221aac..a5c558a5d8 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/PetApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -55,9 +48,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +75,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -106,9 +101,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -147,9 +143,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -186,9 +183,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -229,9 +227,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -254,9 +253,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -279,10 +279,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java index e135ad2702..831650ae3d 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,8 +42,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -68,9 +62,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default ResponseEntity> getInventory() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -91,9 +86,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -125,9 +121,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java index d19c52cdfd..f6b591946b 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -47,8 +40,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -64,8 +58,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +76,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -101,8 +97,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -122,9 +119,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -157,9 +155,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -174,8 +173,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -195,8 +195,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java index 5d6e8ecaf6..1f2e67f154 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/AnotherFakeApi.java @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -50,10 +43,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java index c02b842be9..94b48c373d 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java @@ -23,14 +23,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -60,9 +53,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -80,9 +74,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -100,9 +95,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -129,9 +125,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -149,9 +146,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -169,9 +167,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -189,9 +188,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -209,10 +209,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -256,9 +257,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -285,9 +287,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -310,8 +313,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -328,9 +332,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -348,9 +353,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -372,8 +378,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -397,10 +404,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java index feb616710d..8b7d06ba51 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeClassnameTestApi.java @@ -13,14 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -52,10 +45,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java index fbe4063701..f7bd69ad99 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/PetApi.java @@ -16,14 +16,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -59,9 +52,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -86,8 +80,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -112,9 +107,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -154,9 +150,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -194,9 +191,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -238,9 +236,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -264,9 +263,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -290,10 +290,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java index 0e9b4c38c1..bbff58544f 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/StoreApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -53,8 +46,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -73,9 +67,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default ResponseEntity> getInventory() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -97,9 +92,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -132,9 +128,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java index 4eaafdd0f2..a0f44f23f2 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/UserApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -51,8 +44,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -69,8 +63,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -87,8 +82,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -108,8 +104,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -130,9 +127,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -166,9 +164,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -184,8 +183,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -206,8 +206,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java index 2052f5808d..44f3e9bb93 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -46,10 +39,11 @@ public interface AnotherFakeApi { @ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/another-fake/dummy", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/another-fake/dummy", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java index 637dabcf2d..11a5cf7b55 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java @@ -21,14 +21,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -56,9 +49,10 @@ public interface FakeApi { @ApiOperation(value = "creates an XmlItem", nickname = "createXmlItem", notes = "this route creates an XmlItem", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/create_xml_item", - consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/create_xml_item", + consumes = { "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" } + ) default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -75,9 +69,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) - @RequestMapping(value = "/fake/outer/boolean", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/boolean", + produces = { "*/*" } + ) default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -94,9 +89,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) - @RequestMapping(value = "/fake/outer/composite", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/composite", + produces = { "*/*" } + ) default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -122,9 +118,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) - @RequestMapping(value = "/fake/outer/number", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/number", + produces = { "*/*" } + ) default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -141,9 +138,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) - @RequestMapping(value = "/fake/outer/string", - produces = { "*/*" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/outer/string", + produces = { "*/*" } + ) default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -160,9 +158,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithFileSchema", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-file-schema", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-file-schema", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -179,9 +178,10 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testBodyWithQueryParams", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/body-with-query-params", - consumes = { "application/json" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/body-with-query-params", + consumes = { "application/json" } + ) default ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -198,10 +198,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -244,9 +245,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "number", required = true) BigDecimal number,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "double", required = true) Double _double,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "pattern_without_delimiter", required = true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @Valid @RequestPart(value = "byte", required = true) byte[] _byte,@ApiParam(value = "None") @Valid @RequestPart(value = "integer", required = false) Integer integer,@ApiParam(value = "None") @Valid @RequestPart(value = "int32", required = false) Integer int32,@ApiParam(value = "None") @Valid @RequestPart(value = "int64", required = false) Long int64,@ApiParam(value = "None") @Valid @RequestPart(value = "float", required = false) Float _float,@ApiParam(value = "None") @Valid @RequestPart(value = "string", required = false) String string,@ApiParam(value = "None") @Valid @RequestPart(value = "binary", required = false) MultipartFile binary,@ApiParam(value = "None") @Valid @RequestPart(value = "date", required = false) LocalDate date,@ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) OffsetDateTime dateTime,@ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password,@ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -272,9 +274,10 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) - @RequestMapping(value = "/fake", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testEnumParameters(@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1.1, -1.2") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @Valid @RequestPart(value = "enum_form_string_array", required = false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @Valid @RequestPart(value = "enum_form_string", required = false) String enumFormString) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -296,8 +299,9 @@ public interface FakeApi { @ApiOperation(value = "Fake endpoint to test group parameters (optional)", nickname = "testGroupParameters", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Someting wrong") }) - @RequestMapping(value = "/fake", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/fake" + ) default ResponseEntity testGroupParameters(@NotNull @ApiParam(value = "Required String in group parameters", required = true) @Valid @RequestParam(value = "required_string_group", required = true) Integer requiredStringGroup,@ApiParam(value = "Required Boolean in group parameters" ,required=true) @RequestHeader(value="required_boolean_group", required=true) Boolean requiredBooleanGroup,@NotNull @ApiParam(value = "Required Integer in group parameters", required = true) @Valid @RequestParam(value = "required_int64_group", required = true) Long requiredInt64Group,@ApiParam(value = "String in group parameters") @Valid @RequestParam(value = "string_group", required = false) Integer stringGroup,@ApiParam(value = "Boolean in group parameters" ) @RequestHeader(value="boolean_group", required=false) Boolean booleanGroup,@ApiParam(value = "Integer in group parameters") @Valid @RequestParam(value = "int64_group", required = false) Long int64Group) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -313,9 +317,10 @@ public interface FakeApi { @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/inline-additionalProperties", - consumes = { "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/inline-additionalProperties", + consumes = { "application/json" } + ) default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -332,9 +337,10 @@ public interface FakeApi { @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/fake/jsonFormData", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.GET) + @GetMapping( + value = "/fake/jsonFormData", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -355,8 +361,9 @@ public interface FakeApi { @ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) - @RequestMapping(value = "/fake/test-query-paramters", - method = RequestMethod.PUT) + @PutMapping( + value = "/fake/test-query-paramters" + ) default ResponseEntity testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List context) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -379,10 +386,11 @@ public interface FakeApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/fake/{petId}/uploadImageWithRequiredFile", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 765feb5174..5742965028 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -11,14 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -48,10 +41,11 @@ public interface FakeClassnameTestApi { }, tags={ "fake_classname_tags 123#$%^", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake_classname_test", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) + @PatchMapping( + value = "/fake_classname_test", + produces = { "application/json" }, + consumes = { "application/json" } + ) default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java index 23311c253b..51080bb7d3 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/PetApi.java @@ -14,14 +14,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -55,9 +48,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +75,9 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 400, message = "Invalid pet value") }) - @RequestMapping(value = "/pet/{petId}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/pet/{petId}" + ) default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -106,9 +101,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -147,9 +143,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"), @ApiResponse(code = 400, message = "Invalid tag value") }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -186,9 +183,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -229,9 +227,10 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) - @RequestMapping(value = "/pet", - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) + @PutMapping( + value = "/pet", + consumes = { "application/json", "application/xml" } + ) default ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -254,9 +253,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "/pet/{petId}", - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -279,10 +279,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) + @PostMapping( + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java index e135ad2702..831650ae3d 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/StoreApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -49,8 +42,9 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/store/order/{order_id}" + ) default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -68,9 +62,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/inventory", + produces = { "application/json" } + ) default ResponseEntity> getInventory() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -91,9 +86,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -125,9 +121,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) + @PostMapping( + value = "/store/order", + produces = { "application/xml", "application/json" } + ) default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java index d19c52cdfd..f6b591946b 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/UserApi.java @@ -12,14 +12,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; @@ -47,8 +40,9 @@ public interface UserApi { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user", - method = RequestMethod.POST) + @PostMapping( + value = "/user" + ) default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -64,8 +58,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithArray", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithArray" + ) default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -81,8 +76,9 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/createWithList", - method = RequestMethod.POST) + @PostMapping( + value = "/user/createWithList" + ) default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -101,8 +97,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.DELETE) + @DeleteMapping( + value = "/user/{username}" + ) default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -122,9 +119,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -157,9 +155,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) + @GetMapping( + value = "/user/login", + produces = { "application/xml", "application/json" } + ) default ResponseEntity loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -174,8 +173,9 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) - @RequestMapping(value = "/user/logout", - method = RequestMethod.GET) + @GetMapping( + value = "/user/logout" + ) default ResponseEntity logoutUser() { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); @@ -195,8 +195,9 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) - @RequestMapping(value = "/user/{username}", - method = RequestMethod.PUT) + @PutMapping( + value = "/user/{username}" + ) default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);