diff --git a/bin/configs/spring-boot-delegate.yaml b/bin/configs/spring-boot-delegate.yaml index 26b65d17ba7..162094128db 100644 --- a/bin/configs/spring-boot-delegate.yaml +++ b/bin/configs/spring-boot-delegate.yaml @@ -5,5 +5,5 @@ templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: artifactId: springboot-delegate hideGenerationTimestamp: "true" - java8: "false" + java8: true delegatePattern: "true" diff --git a/bin/configs/spring-mvc.yaml b/bin/configs/spring-mvc.yaml index 2e8c1c718de..8f16468573d 100644 --- a/bin/configs/spring-mvc.yaml +++ b/bin/configs/spring-mvc.yaml @@ -4,7 +4,7 @@ library: spring-mvc inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: - java8: "false" + java8: true booleanGetterPrefix: get artifactId: spring-mvc-server hideGenerationTimestamp: "true" diff --git a/samples/server/petstore/spring-mvc/.openapi-generator/FILES b/samples/server/petstore/spring-mvc/.openapi-generator/FILES index 56bac36e8c9..4b0ad04efe4 100644 --- a/samples/server/petstore/spring-mvc/.openapi-generator/FILES +++ b/samples/server/petstore/spring-mvc/.openapi-generator/FILES @@ -13,7 +13,6 @@ src/main/java/org/openapitools/api/StoreApi.java src/main/java/org/openapitools/api/StoreApiController.java src/main/java/org/openapitools/api/UserApi.java src/main/java/org/openapitools/api/UserApiController.java -src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java src/main/java/org/openapitools/configuration/HomeController.java src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java src/main/java/org/openapitools/configuration/OpenAPIUiConfiguration.java diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 49b9cce014c..722935b3b1a 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -123,9 +123,9 @@ ${springfox-version} - com.github.joschi.jackson - jackson-datatype-threetenbp - ${jackson-threetenbp-version} + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} org.openapitools @@ -152,7 +152,7 @@ - 1.7 + 1.8 ${java.version} ${java.version} 9.2.15.v20160210 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 07b6801beb0..44f3e9bb93f 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 @@ -7,20 +7,28 @@ package org.openapitools.api; import org.openapitools.model.Client; import io.swagger.annotations.*; +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.*; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { + default Optional getRequest() { + return Optional.empty(); + } + /** * PATCH /another-fake/dummy : To test special tags * To test special tags and operation ID starting with number @@ -36,6 +44,18 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" } ) - ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + default ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApiController.java index 731880309bf..7e8132190d6 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -1,25 +1,9 @@ package org.openapitools.api; -import org.openapitools.model.Client; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/}") @@ -32,24 +16,9 @@ public class AnotherFakeApiController implements AnotherFakeApi { this.request = request; } - /** - * PATCH /another-fake/dummy : To test special tags - * To test special tags and operation ID starting with number - * - * @param body client model (required) - * @return successful operation (status code 200) - * @see AnotherFakeApi#call123testSpecialTags - */ - public ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"client\" : \"client\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } 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 f2f112c5750..11a5cf7b551 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 @@ -8,29 +8,37 @@ package org.openapitools.api; import java.math.BigDecimal; import org.openapitools.model.Client; import org.openapitools.model.FileSchemaTestClass; -import org.threeten.bp.LocalDate; +import java.time.LocalDate; import java.util.Map; import org.openapitools.model.ModelApiResponse; -import org.threeten.bp.OffsetDateTime; +import java.time.OffsetDateTime; import org.openapitools.model.OuterComposite; import org.springframework.core.io.Resource; import org.openapitools.model.User; import org.openapitools.model.XmlItem; import io.swagger.annotations.*; +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.*; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Api(value = "fake", description = "the fake API") public interface FakeApi { + default Optional getRequest() { + return Optional.empty(); + } + /** * POST /fake/create_xml_item : creates an XmlItem * this route creates an XmlItem @@ -45,7 +53,10 @@ public interface FakeApi { 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); + default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -62,7 +73,10 @@ public interface FakeApi { value = "/fake/outer/boolean", produces = { "*/*" } ) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -79,7 +93,19 @@ public interface FakeApi { value = "/fake/outer/composite", produces = { "*/*" } ) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + ApiUtil.setExampleResponse(request, "*/*", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -96,7 +122,10 @@ public interface FakeApi { value = "/fake/outer/number", produces = { "*/*" } ) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -113,7 +142,10 @@ public interface FakeApi { value = "/fake/outer/string", produces = { "*/*" } ) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -130,7 +162,10 @@ public interface FakeApi { value = "/fake/body-with-file-schema", consumes = { "application/json" } ) - ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body); + default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -147,7 +182,10 @@ public interface FakeApi { 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); + 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); + + } /** @@ -165,7 +203,19 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" } ) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -199,16 +249,19 @@ public interface FakeApi { 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); + 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); + + } /** * GET /fake : To test enum parameters * To test enum parameters * - * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<String>()) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<>()) * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) - * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<String>()) + * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<>()) * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) * @param enumQueryInteger Query parameter enum test (double) (optional) * @param enumQueryDouble Query parameter enum test (double) (optional) @@ -225,7 +278,10 @@ public interface FakeApi { 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); + 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); + + } /** @@ -246,7 +302,10 @@ public interface FakeApi { @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); + 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); + + } /** @@ -262,7 +321,10 @@ public interface FakeApi { value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param); + default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -279,7 +341,10 @@ public interface FakeApi { 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); + 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); + + } /** @@ -299,7 +364,10 @@ public interface FakeApi { @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); + 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); + + } /** @@ -323,6 +391,18 @@ public interface FakeApi { 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); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java index 68f42954ab3..1ac9ecd804c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,35 +1,9 @@ package org.openapitools.api; -import java.math.BigDecimal; -import org.openapitools.model.Client; -import org.openapitools.model.FileSchemaTestClass; -import org.threeten.bp.LocalDate; -import java.util.Map; -import org.openapitools.model.ModelApiResponse; -import org.threeten.bp.OffsetDateTime; -import org.openapitools.model.OuterComposite; -import org.springframework.core.io.Resource; -import org.openapitools.model.User; -import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/}") @@ -42,251 +16,9 @@ public class FakeApiController implements FakeApi { this.request = request; } - /** - * POST /fake/create_xml_item : creates an XmlItem - * this route creates an XmlItem - * - * @param xmlItem XmlItem Body (required) - * @return successful operation (status code 200) - * @see FakeApi#createXmlItem - */ - public ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /fake/outer/boolean - * Test serialization of outer boolean types - * - * @param body Input boolean as post body (optional) - * @return Output boolean (status code 200) - * @see FakeApi#fakeOuterBooleanSerialize - */ - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /fake/outer/composite - * Test serialization of object with outer number type - * - * @param body Input composite as post body (optional) - * @return Output composite (status code 200) - * @see FakeApi#fakeOuterCompositeSerialize - */ - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { - String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; - ApiUtil.setExampleResponse(request, "*/*", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /fake/outer/number - * Test serialization of outer number types - * - * @param body Input number as post body (optional) - * @return Output number (status code 200) - * @see FakeApi#fakeOuterNumberSerialize - */ - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /fake/outer/string - * Test serialization of outer string types - * - * @param body Input string as post body (optional) - * @return Output string (status code 200) - * @see FakeApi#fakeOuterStringSerialize - */ - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * PUT /fake/body-with-file-schema - * For this test, the body for this request much reference a schema named `File`. - * - * @param body (required) - * @return Success (status code 200) - * @see FakeApi#testBodyWithFileSchema - */ - public ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * PUT /fake/body-with-query-params - * - * @param query (required) - * @param body (required) - * @return Success (status code 200) - * @see FakeApi#testBodyWithQueryParams - */ - public 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); - - } - - /** - * PATCH /fake : To test \"client\" model - * To test \"client\" model - * - * @param body client model (required) - * @return successful operation (status code 200) - * @see FakeApi#testClientModel - */ - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"client\" : \"client\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * - * @param number None (required) - * @param _double None (required) - * @param patternWithoutDelimiter None (required) - * @param _byte None (required) - * @param integer None (optional) - * @param int32 None (optional) - * @param int64 None (optional) - * @param _float None (optional) - * @param string None (optional) - * @param binary None (optional) - * @param date None (optional) - * @param dateTime None (optional) - * @param password None (optional) - * @param paramCallback None (optional) - * @return Invalid username supplied (status code 400) - * or User not found (status code 404) - * @see FakeApi#testEndpointParameters - */ - public 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); - - } - - /** - * GET /fake : To test enum parameters - * To test enum parameters - * - * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<String>()) - * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) - * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<String>()) - * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) - * @param enumQueryInteger Query parameter enum test (double) (optional) - * @param enumQueryDouble Query parameter enum test (double) (optional) - * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) - * @param enumFormString Form parameter enum test (string) (optional, default to -efg) - * @return Invalid request (status code 400) - * or Not found (status code 404) - * @see FakeApi#testEnumParameters - */ - public 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); - - } - - /** - * DELETE /fake : Fake endpoint to test group parameters (optional) - * Fake endpoint to test group parameters (optional) - * - * @param requiredStringGroup Required String in group parameters (required) - * @param requiredBooleanGroup Required Boolean in group parameters (required) - * @param requiredInt64Group Required Integer in group parameters (required) - * @param stringGroup String in group parameters (optional) - * @param booleanGroup Boolean in group parameters (optional) - * @param int64Group Integer in group parameters (optional) - * @return Someting wrong (status code 400) - * @see FakeApi#testGroupParameters - */ - public 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); - - } - - /** - * POST /fake/inline-additionalProperties : test inline additionalProperties - * - * @param param request body (required) - * @return successful operation (status code 200) - * @see FakeApi#testInlineAdditionalProperties - */ - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * GET /fake/jsonFormData : test json serialization of form data - * - * @param param field1 (required) - * @param param2 field2 (required) - * @return successful operation (status code 200) - * @see FakeApi#testJsonFormData - */ - public 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); - - } - - /** - * PUT /fake/test-query-paramters - * To test the collection format in query parameters - * - * @param pipe (required) - * @param ioutil (required) - * @param http (required) - * @param url (required) - * @param context (required) - * @return Success (status code 200) - * @see FakeApi#testQueryParameterCollectionFormat - */ - public 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); - - } - - /** - * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) - * - * @param petId ID of pet to update (required) - * @param requiredFile file to upload (required) - * @param additionalMetadata Additional data to pass to server (optional) - * @return successful operation (status code 200) - * @see FakeApi#uploadFileWithRequiredFile - */ - public 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) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } 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 723fc9f62ac..5742965028b 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 @@ -7,20 +7,28 @@ package org.openapitools.api; import org.openapitools.model.Client; import io.swagger.annotations.*; +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.*; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { + default Optional getRequest() { + return Optional.empty(); + } + /** * PATCH /fake_classname_test : To test class name in snake case * To test class name in snake case @@ -38,6 +46,18 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" } ) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + default ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index 90b1fcb28b5..68f9c4233e8 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -1,25 +1,9 @@ package org.openapitools.api; -import org.openapitools.model.Client; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/}") @@ -32,24 +16,9 @@ public class FakeClassnameTestApiController implements FakeClassnameTestApi { this.request = request; } - /** - * PATCH /fake_classname_test : To test class name in snake case - * To test class name in snake case - * - * @param body client model (required) - * @return successful operation (status code 200) - * @see FakeClassnameTestApi#testClassname - */ - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"client\" : \"client\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } 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 7ab2f6e9d5f..51080bb7d32 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 @@ -10,20 +10,28 @@ import org.openapitools.model.Pet; import org.springframework.core.io.Resource; import java.util.Set; import io.swagger.annotations.*; +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.*; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Api(value = "pet", description = "the pet API") public interface PetApi { + default Optional getRequest() { + return Optional.empty(); + } + /** * POST /pet : Add a new pet to the store * @@ -44,7 +52,10 @@ public interface PetApi { 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); + 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); + + } /** @@ -67,7 +78,10 @@ public interface PetApi { @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); + 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); + + } /** @@ -91,7 +105,24 @@ public interface PetApi { 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); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -116,7 +147,24 @@ public interface PetApi { 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); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -139,7 +187,24 @@ public interface PetApi { value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -166,7 +231,10 @@ public interface PetApi { 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); + 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); + + } /** @@ -189,7 +257,10 @@ public interface PetApi { 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); + 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); + + } /** @@ -213,6 +284,18 @@ public interface PetApi { 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); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java index ac991356a7a..1485b58cb3e 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/PetApiController.java @@ -1,28 +1,9 @@ package org.openapitools.api; -import org.openapitools.model.ModelApiResponse; -import org.openapitools.model.Pet; -import org.springframework.core.io.Resource; -import java.util.Set; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/}") @@ -35,161 +16,9 @@ public class PetApiController implements PetApi { this.request = request; } - /** - * POST /pet : Add a new pet to the store - * - * @param body Pet object that needs to be added to the store (required) - * @return successful operation (status code 200) - * or Invalid input (status code 405) - * @see PetApi#addPet - */ - public 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); - - } - - /** - * DELETE /pet/{petId} : Deletes a pet - * - * @param petId Pet id to delete (required) - * @param apiKey (optional) - * @return successful operation (status code 200) - * or Invalid pet value (status code 400) - * @see PetApi#deletePet - */ - public 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); - - } - - /** - * GET /pet/findByStatus : Finds Pets by status - * Multiple status values can be provided with comma separated strings - * - * @param status Status values that need to be considered for filter (required) - * @return successful operation (status code 200) - * or Invalid status value (status code 400) - * @see PetApi#findPetsByStatus - */ - public 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) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - String exampleString = " 123456789 doggie aeiou aeiou "; - ApiUtil.setExampleResponse(request, "application/xml", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * GET /pet/findByTags : Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * - * @param tags Tags to filter by (required) - * @return successful operation (status code 200) - * or Invalid tag value (status code 400) - * @deprecated - * @see PetApi#findPetsByTags - */ - public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - String exampleString = " 123456789 doggie aeiou aeiou "; - ApiUtil.setExampleResponse(request, "application/xml", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * GET /pet/{petId} : Find pet by ID - * Returns a single pet - * - * @param petId ID of pet to return (required) - * @return successful operation (status code 200) - * or Invalid ID supplied (status code 400) - * or Pet not found (status code 404) - * @see PetApi#getPetById - */ - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - String exampleString = " 123456789 doggie aeiou aeiou "; - ApiUtil.setExampleResponse(request, "application/xml", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * PUT /pet : Update an existing pet - * - * @param body Pet object that needs to be added to the store (required) - * @return successful operation (status code 200) - * or Invalid ID supplied (status code 400) - * or Pet not found (status code 404) - * or Validation exception (status code 405) - * @see PetApi#updatePet - */ - public 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); - - } - - /** - * POST /pet/{petId} : Updates a pet in the store with form data - * - * @param petId ID of pet that needs to be updated (required) - * @param name Updated name of the pet (optional) - * @param status Updated status of the pet (optional) - * @return Invalid input (status code 405) - * @see PetApi#updatePetWithForm - */ - public 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); - - } - - /** - * POST /pet/{petId}/uploadImage : uploads an image - * - * @param petId ID of pet to update (required) - * @param additionalMetadata Additional data to pass to server (optional) - * @param file file to upload (optional) - * @return successful operation (status code 200) - * @see PetApi#uploadFile - */ - public 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) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } 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 0128cb2d54b..831650ae3d6 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 @@ -8,20 +8,28 @@ package org.openapitools.api; import java.util.Map; import org.openapitools.model.Order; import io.swagger.annotations.*; +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.*; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Api(value = "store", description = "the store API") public interface StoreApi { + default Optional getRequest() { + return Optional.empty(); + } + /** * DELETE /store/order/{order_id} : Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -37,7 +45,10 @@ public interface StoreApi { @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); + 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); + + } /** @@ -55,7 +66,10 @@ public interface StoreApi { value = "/store/inventory", produces = { "application/json" } ) - ResponseEntity> getInventory(); + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -76,7 +90,24 @@ public interface StoreApi { 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); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -94,6 +125,23 @@ public interface StoreApi { value = "/store/order", produces = { "application/xml", "application/json" } ) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApiController.java index b03098aa747..3a8489c4176 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApiController.java @@ -1,26 +1,9 @@ package org.openapitools.api; -import java.util.Map; -import org.openapitools.model.Order; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/}") @@ -33,82 +16,9 @@ public class StoreApiController implements StoreApi { this.request = request; } - /** - * DELETE /store/order/{order_id} : Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * - * @param orderId ID of the order that needs to be deleted (required) - * @return Invalid ID supplied (status code 400) - * or Order not found (status code 404) - * @see StoreApi#deleteOrder - */ - public 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); - - } - - /** - * GET /store/inventory : Returns pet inventories by status - * Returns a map of status codes to quantities - * - * @return successful operation (status code 200) - * @see StoreApi#getInventory - */ - public ResponseEntity> getInventory() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * GET /store/order/{order_id} : Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * - * @param orderId ID of pet that needs to be fetched (required) - * @return successful operation (status code 200) - * or Invalid ID supplied (status code 400) - * or Order not found (status code 404) - * @see StoreApi#getOrderById - */ - public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; - ApiUtil.setExampleResponse(request, "application/xml", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /store/order : Place an order for a pet - * - * @param body order placed for purchasing the pet (required) - * @return successful operation (status code 200) - * or Invalid Order (status code 400) - * @see StoreApi#placeOrder - */ - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; - ApiUtil.setExampleResponse(request, "application/xml", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } 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 e1d4245a6b1..f6b591946bc 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 @@ -8,20 +8,28 @@ package org.openapitools.api; import java.util.List; import org.openapitools.model.User; import io.swagger.annotations.*; +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.*; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Validated @Api(value = "user", description = "the user API") public interface UserApi { + default Optional getRequest() { + return Optional.empty(); + } + /** * POST /user : Create user * This can only be done by the logged in user. @@ -35,7 +43,10 @@ public interface UserApi { @PostMapping( value = "/user" ) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); + default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -50,7 +61,10 @@ public interface UserApi { @PostMapping( value = "/user/createWithArray" ) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -65,7 +79,10 @@ public interface UserApi { @PostMapping( value = "/user/createWithList" ) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -83,7 +100,10 @@ public interface UserApi { @DeleteMapping( value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String 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); + + } /** @@ -103,7 +123,24 @@ public interface UserApi { 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); + 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"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -122,7 +159,10 @@ public interface UserApi { 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); + 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); + + } /** @@ -136,7 +176,10 @@ public interface UserApi { @GetMapping( value = "/user/logout" ) - ResponseEntity logoutUser(); + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** @@ -155,6 +198,9 @@ public interface UserApi { @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); + 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/UserApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApiController.java index 24445f78372..85e90691158 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApiController.java @@ -1,26 +1,9 @@ package org.openapitools.api; -import java.util.List; -import org.openapitools.model.User; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/}") @@ -33,121 +16,9 @@ public class UserApiController implements UserApi { this.request = request; } - /** - * POST /user : Create user - * This can only be done by the logged in user. - * - * @param body Created user object (required) - * @return successful operation (status code 200) - * @see UserApi#createUser - */ - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /user/createWithArray : Creates list of users with given input array - * - * @param body List of user object (required) - * @return successful operation (status code 200) - * @see UserApi#createUsersWithArrayInput - */ - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * POST /user/createWithList : Creates list of users with given input array - * - * @param body List of user object (required) - * @return successful operation (status code 200) - * @see UserApi#createUsersWithListInput - */ - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * DELETE /user/{username} : Delete user - * This can only be done by the logged in user. - * - * @param username The name that needs to be deleted (required) - * @return Invalid username supplied (status code 400) - * or User not found (status code 404) - * @see UserApi#deleteUser - */ - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * GET /user/{username} : Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @return successful operation (status code 200) - * or Invalid username supplied (status code 400) - * or User not found (status code 404) - * @see UserApi#getUserByName - */ - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { - for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }"; - ApiUtil.setExampleResponse(request, "application/json", exampleString); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - String exampleString = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; - ApiUtil.setExampleResponse(request, "application/xml", exampleString); - break; - } - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * GET /user/login : Logs user into the system - * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) - * @return successful operation (status code 200) - * or Invalid username/password supplied (status code 400) - * @see UserApi#loginUser - */ - public 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); - - } - - /** - * GET /user/logout : Logs out current logged in user session - * - * @return successful operation (status code 200) - * @see UserApi#logoutUser - */ - public ResponseEntity logoutUser() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * PUT /user/{username} : Updated user - * This can only be done by the logged in user. - * - * @param username name that need to be deleted (required) - * @param body Updated user object (required) - * @return Invalid user supplied (status code 400) - * or User not found (status code 404) - * @see UserApi#updateUser - */ - public 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); - + @Override + public Optional getRequest() { + return Optional.ofNullable(request); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java deleted file mode 100644 index 8f936b31144..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java index 41d0edf1165..3df5ef9f3c3 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -40,8 +40,9 @@ public class OpenAPIDocumentationConfig { .select() .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) .build() - .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class) + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) .apiInfo(apiInfo()); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIUiConfiguration.java index 15f4ddf5ae1..e61611e3b14 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIUiConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/configuration/OpenAPIUiConfiguration.java @@ -2,7 +2,6 @@ package org.openapitools.configuration; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; import org.openapitools.jackson.nullable.JsonNullableModule; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -16,9 +15,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; import java.util.List; @@ -73,14 +69,10 @@ public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter { @Bean public Jackson2ObjectMapperBuilder builder() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); return new Jackson2ObjectMapperBuilder() .indentOutput(true) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .modulesToInstall(module, new JsonNullableModule()) + .modulesToInstall(new JsonNullableModule()) .dateFormat(new RFC3339DateFormat()); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index ce47917ea6e..7b6f5ac16c7 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -68,7 +68,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { if (this.mapString == null) { - this.mapString = new HashMap(); + this.mapString = new HashMap<>(); } this.mapString.put(key, mapStringItem); return this; @@ -96,7 +96,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { if (this.mapNumber == null) { - this.mapNumber = new HashMap(); + this.mapNumber = new HashMap<>(); } this.mapNumber.put(key, mapNumberItem); return this; @@ -125,7 +125,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { if (this.mapInteger == null) { - this.mapInteger = new HashMap(); + this.mapInteger = new HashMap<>(); } this.mapInteger.put(key, mapIntegerItem); return this; @@ -153,7 +153,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { if (this.mapBoolean == null) { - this.mapBoolean = new HashMap(); + this.mapBoolean = new HashMap<>(); } this.mapBoolean.put(key, mapBooleanItem); return this; @@ -181,7 +181,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { if (this.mapArrayInteger == null) { - this.mapArrayInteger = new HashMap>(); + this.mapArrayInteger = new HashMap<>(); } this.mapArrayInteger.put(key, mapArrayIntegerItem); return this; @@ -210,7 +210,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { if (this.mapArrayAnytype == null) { - this.mapArrayAnytype = new HashMap>(); + this.mapArrayAnytype = new HashMap<>(); } this.mapArrayAnytype.put(key, mapArrayAnytypeItem); return this; @@ -239,7 +239,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { if (this.mapMapString == null) { - this.mapMapString = new HashMap>(); + this.mapMapString = new HashMap<>(); } this.mapMapString.put(key, mapMapStringItem); return this; @@ -268,7 +268,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { if (this.mapMapAnytype == null) { - this.mapMapAnytype = new HashMap>(); + this.mapMapAnytype = new HashMap<>(); } this.mapMapAnytype.put(key, mapMapAnytypeItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java index 412feee5230..9fa32d2ea9c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -30,7 +30,7 @@ public class ArrayOfArrayOfNumberOnly { public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { if (this.arrayArrayNumber == null) { - this.arrayArrayNumber = new ArrayList>(); + this.arrayArrayNumber = new ArrayList<>(); } this.arrayArrayNumber.add(arrayArrayNumberItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java index f6f314a4f1b..7910abcc696 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -30,7 +30,7 @@ public class ArrayOfNumberOnly { public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { if (this.arrayNumber == null) { - this.arrayNumber = new ArrayList(); + this.arrayNumber = new ArrayList<>(); } this.arrayNumber.add(arrayNumberItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayTest.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayTest.java index 908810d635a..cb245ac0b60 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayTest.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ArrayTest.java @@ -38,7 +38,7 @@ public class ArrayTest { public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { if (this.arrayOfString == null) { - this.arrayOfString = new ArrayList(); + this.arrayOfString = new ArrayList<>(); } this.arrayOfString.add(arrayOfStringItem); return this; @@ -66,7 +66,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { if (this.arrayArrayOfInteger == null) { - this.arrayArrayOfInteger = new ArrayList>(); + this.arrayArrayOfInteger = new ArrayList<>(); } this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); return this; @@ -95,7 +95,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { if (this.arrayArrayOfModel == null) { - this.arrayArrayOfModel = new ArrayList>(); + this.arrayArrayOfModel = new ArrayList<>(); } this.arrayArrayOfModel.add(arrayArrayOfModelItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/EnumArrays.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/EnumArrays.java index dd1e1b12470..618b78fcbc5 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/EnumArrays.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/EnumArrays.java @@ -123,7 +123,7 @@ public class EnumArrays { public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { if (this.arrayEnum == null) { - this.arrayEnum = new ArrayList(); + this.arrayEnum = new ArrayList<>(); } this.arrayEnum.add(arrayEnumItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FileSchemaTestClass.java index d01c6935fc5..2e1fa754045 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FileSchemaTestClass.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -53,7 +53,7 @@ public class FileSchemaTestClass { public FileSchemaTestClass addFilesItem(java.io.File filesItem) { if (this.files == null) { - this.files = new ArrayList(); + this.files = new ArrayList<>(); } this.files.add(filesItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FormatTest.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FormatTest.java index 8a8c11a3e5e..f75829b436e 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FormatTest.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FormatTest.java @@ -6,10 +6,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; import java.util.UUID; import org.springframework.core.io.Resource; -import org.threeten.bp.LocalDate; -import org.threeten.bp.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; import javax.validation.Valid; import javax.validation.constraints.*; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MapTest.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MapTest.java index e8ed4979406..fbb4966cc6c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MapTest.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MapTest.java @@ -78,7 +78,7 @@ public class MapTest { public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { if (this.mapMapOfString == null) { - this.mapMapOfString = new HashMap>(); + this.mapMapOfString = new HashMap<>(); } this.mapMapOfString.put(key, mapMapOfStringItem); return this; @@ -107,7 +107,7 @@ public class MapTest { public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { if (this.mapOfEnumString == null) { - this.mapOfEnumString = new HashMap(); + this.mapOfEnumString = new HashMap<>(); } this.mapOfEnumString.put(key, mapOfEnumStringItem); return this; @@ -135,7 +135,7 @@ public class MapTest { public MapTest putDirectMapItem(String key, Boolean directMapItem) { if (this.directMap == null) { - this.directMap = new HashMap(); + this.directMap = new HashMap<>(); } this.directMap.put(key, directMapItem); return this; @@ -163,7 +163,7 @@ public class MapTest { public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { if (this.indirectMap == null) { - this.indirectMap = new HashMap(); + this.indirectMap = new HashMap<>(); } this.indirectMap.put(key, indirectMapItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java index 6e2f93546eb..2cab02c3d08 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -5,12 +5,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import org.openapitools.model.Animal; -import org.threeten.bp.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; import javax.validation.Valid; import javax.validation.constraints.*; @@ -82,7 +82,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { if (this.map == null) { - this.map = new HashMap(); + this.map = new HashMap<>(); } this.map.put(key, mapItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Order.java index c7350c2eaa0..c10da34792c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Order.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.threeten.bp.OffsetDateTime; +import java.time.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; import javax.validation.Valid; import javax.validation.constraints.*; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Pet.java index 61cdc3830f1..1c2cd719532 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Pet.java @@ -34,7 +34,7 @@ public class Pet { @JsonProperty("photoUrls") @Valid - private Set photoUrls = new LinkedHashSet(); + private Set photoUrls = new LinkedHashSet<>(); @JsonProperty("tags") @Valid @@ -175,7 +175,7 @@ public class Pet { public Pet addTagsItem(Tag tagsItem) { if (this.tags == null) { - this.tags = new ArrayList(); + this.tags = new ArrayList<>(); } this.tags.add(tagsItem); return this; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderDefault.java index 3b07a1358d8..70f7a789f6b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderDefault.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -33,7 +33,7 @@ public class TypeHolderDefault { @JsonProperty("array_item") @Valid - private List arrayItem = new ArrayList(); + private List arrayItem = new ArrayList<>(); public TypeHolderDefault stringItem(String stringItem) { this.stringItem = stringItem; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderExample.java index aef218572ea..56092259288 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderExample.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -36,7 +36,7 @@ public class TypeHolderExample { @JsonProperty("array_item") @Valid - private List arrayItem = new ArrayList(); + private List arrayItem = new ArrayList<>(); public TypeHolderExample stringItem(String stringItem) { this.stringItem = stringItem; diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/XmlItem.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/XmlItem.java index 820c082d285..75eb7b6f26d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/XmlItem.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/XmlItem.java @@ -203,7 +203,7 @@ public class XmlItem { public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { if (this.wrappedArray == null) { - this.wrappedArray = new ArrayList(); + this.wrappedArray = new ArrayList<>(); } this.wrappedArray.add(wrappedArrayItem); return this; @@ -312,7 +312,7 @@ public class XmlItem { public XmlItem addNameArrayItem(Integer nameArrayItem) { if (this.nameArray == null) { - this.nameArray = new ArrayList(); + this.nameArray = new ArrayList<>(); } this.nameArray.add(nameArrayItem); return this; @@ -340,7 +340,7 @@ public class XmlItem { public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { if (this.nameWrappedArray == null) { - this.nameWrappedArray = new ArrayList(); + this.nameWrappedArray = new ArrayList<>(); } this.nameWrappedArray.add(nameWrappedArrayItem); return this; @@ -449,7 +449,7 @@ public class XmlItem { public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { if (this.prefixArray == null) { - this.prefixArray = new ArrayList(); + this.prefixArray = new ArrayList<>(); } this.prefixArray.add(prefixArrayItem); return this; @@ -477,7 +477,7 @@ public class XmlItem { public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { if (this.prefixWrappedArray == null) { - this.prefixWrappedArray = new ArrayList(); + this.prefixWrappedArray = new ArrayList<>(); } this.prefixWrappedArray.add(prefixWrappedArrayItem); return this; @@ -586,7 +586,7 @@ public class XmlItem { public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { if (this.namespaceArray == null) { - this.namespaceArray = new ArrayList(); + this.namespaceArray = new ArrayList<>(); } this.namespaceArray.add(namespaceArrayItem); return this; @@ -614,7 +614,7 @@ public class XmlItem { public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { if (this.namespaceWrappedArray == null) { - this.namespaceWrappedArray = new ArrayList(); + this.namespaceWrappedArray = new ArrayList<>(); } this.namespaceWrappedArray.add(namespaceWrappedArrayItem); return this; @@ -723,7 +723,7 @@ public class XmlItem { public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { if (this.prefixNsArray == null) { - this.prefixNsArray = new ArrayList(); + this.prefixNsArray = new ArrayList<>(); } this.prefixNsArray.add(prefixNsArrayItem); return this; @@ -751,7 +751,7 @@ public class XmlItem { public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { if (this.prefixNsWrappedArray == null) { - this.prefixNsWrappedArray = new ArrayList(); + this.prefixNsWrappedArray = new ArrayList<>(); } this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); return this; diff --git a/samples/server/petstore/springboot-delegate/.openapi-generator/FILES b/samples/server/petstore/springboot-delegate/.openapi-generator/FILES index 751215bab5e..8c36406da48 100644 --- a/samples/server/petstore/springboot-delegate/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-delegate/.openapi-generator/FILES @@ -21,9 +21,7 @@ src/main/java/org/openapitools/api/StoreApiDelegate.java src/main/java/org/openapitools/api/UserApi.java src/main/java/org/openapitools/api/UserApiController.java src/main/java/org/openapitools/api/UserApiDelegate.java -src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java src/main/java/org/openapitools/configuration/HomeController.java -src/main/java/org/openapitools/configuration/JacksonConfiguration.java src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java src/main/java/org/openapitools/model/AdditionalPropertiesArray.java diff --git a/samples/server/petstore/springboot-delegate/pom.xml b/samples/server/petstore/springboot-delegate/pom.xml index 83b61b77934..01f5ccf7905 100644 --- a/samples/server/petstore/springboot-delegate/pom.xml +++ b/samples/server/petstore/springboot-delegate/pom.xml @@ -6,7 +6,7 @@ springboot-delegate 1.0.0 - 1.7 + 1.8 ${java.version} ${java.version} 2.8.0 @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.12.RELEASE + 2.0.1.RELEASE src/main/java @@ -54,9 +54,8 @@ 2.2.11 - com.github.joschi.jackson - jackson-datatype-threetenbp - 2.8.4 + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 org.openapitools diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java index b7af36b6bbd..7cad28eed8a 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -10,7 +10,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @SpringBootApplication @ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) @@ -39,7 +38,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner { @Bean public WebMvcConfigurer webConfigurer() { - return new WebMvcConfigurerAdapter() { + return new WebMvcConfigurer() { /*@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") 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 07b6801beb0..d0977d683df 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 @@ -21,6 +21,10 @@ import java.util.Map; @Api(value = "another-fake", description = "the another-fake API") public interface AnotherFakeApi { + default AnotherFakeApiDelegate getDelegate() { + return new AnotherFakeApiDelegate() {}; + } + /** * PATCH /another-fake/dummy : To test special tags * To test special tags and operation ID starting with number @@ -36,6 +40,8 @@ public interface AnotherFakeApi { produces = { "application/json" }, consumes = { "application/json" } ) - ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + 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/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java index 659e82778aa..df11134c806 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -1,24 +1,8 @@ package org.openapitools.api; -import org.openapitools.model.Client; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") @@ -27,19 +11,12 @@ public class AnotherFakeApiController implements AnotherFakeApi { private final AnotherFakeApiDelegate delegate; public AnotherFakeApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) AnotherFakeApiDelegate delegate) { - this.delegate = delegate; + this.delegate = Optional.ofNullable(delegate).orElse(new AnotherFakeApiDelegate() {}); } - /** - * PATCH /another-fake/dummy : To test special tags - * To test special tags and operation ID starting with number - * - * @param body client model (required) - * @return successful operation (status code 200) - * @see AnotherFakeApi#call123testSpecialTags - */ - public ResponseEntity call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - return delegate.call123testSpecialTags(body); + @Override + public AnotherFakeApiDelegate getDelegate() { + return delegate; } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index d17e376d976..7e6ac74b30f 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -2,11 +2,15 @@ package org.openapitools.api; import org.openapitools.model.Client; import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; +import java.util.Optional; /** * A delegate to be called by the {@link AnotherFakeApiController}}. @@ -15,6 +19,10 @@ import java.util.Map; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public interface AnotherFakeApiDelegate { + default Optional getRequest() { + return Optional.empty(); + } + /** * PATCH /another-fake/dummy : To test special tags * To test special tags and operation ID starting with number @@ -23,6 +31,18 @@ public interface AnotherFakeApiDelegate { * @return successful operation (status code 200) * @see AnotherFakeApi#call123testSpecialTags */ - ResponseEntity call123testSpecialTags(Client body); + default ResponseEntity call123testSpecialTags(Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } 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 f2f112c5750..2c6f9356ff2 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 @@ -8,10 +8,10 @@ package org.openapitools.api; import java.math.BigDecimal; import org.openapitools.model.Client; import org.openapitools.model.FileSchemaTestClass; -import org.threeten.bp.LocalDate; +import java.time.LocalDate; import java.util.Map; import org.openapitools.model.ModelApiResponse; -import org.threeten.bp.OffsetDateTime; +import java.time.OffsetDateTime; import org.openapitools.model.OuterComposite; import org.springframework.core.io.Resource; import org.openapitools.model.User; @@ -31,6 +31,10 @@ import java.util.Map; @Api(value = "fake", description = "the fake API") public interface FakeApi { + default FakeApiDelegate getDelegate() { + return new FakeApiDelegate() {}; + } + /** * POST /fake/create_xml_item : creates an XmlItem * this route creates an XmlItem @@ -45,7 +49,9 @@ public interface FakeApi { 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); + default ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { + return getDelegate().createXmlItem(xmlItem); + } /** @@ -62,7 +68,9 @@ public interface FakeApi { value = "/fake/outer/boolean", produces = { "*/*" } ) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body); + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { + return getDelegate().fakeOuterBooleanSerialize(body); + } /** @@ -79,7 +87,9 @@ public interface FakeApi { value = "/fake/outer/composite", produces = { "*/*" } ) - ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body); + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { + return getDelegate().fakeOuterCompositeSerialize(body); + } /** @@ -96,7 +106,9 @@ public interface FakeApi { value = "/fake/outer/number", produces = { "*/*" } ) - ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body); + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { + return getDelegate().fakeOuterNumberSerialize(body); + } /** @@ -113,7 +125,9 @@ public interface FakeApi { value = "/fake/outer/string", produces = { "*/*" } ) - ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { + return getDelegate().fakeOuterStringSerialize(body); + } /** @@ -130,7 +144,9 @@ public interface FakeApi { value = "/fake/body-with-file-schema", consumes = { "application/json" } ) - ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body); + default ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { + return getDelegate().testBodyWithFileSchema(body); + } /** @@ -147,7 +163,9 @@ public interface FakeApi { 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); + 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); + } /** @@ -165,7 +183,9 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" } ) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + return getDelegate().testClientModel(body); + } /** @@ -199,16 +219,18 @@ public interface FakeApi { 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); + 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); + } /** * GET /fake : To test enum parameters * To test enum parameters * - * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<String>()) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<>()) * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) - * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<String>()) + * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<>()) * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) * @param enumQueryInteger Query parameter enum test (double) (optional) * @param enumQueryDouble Query parameter enum test (double) (optional) @@ -225,7 +247,9 @@ public interface FakeApi { 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); + 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); + } /** @@ -246,7 +270,9 @@ public interface FakeApi { @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); + 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); + } /** @@ -262,7 +288,9 @@ public interface FakeApi { value = "/fake/inline-additionalProperties", consumes = { "application/json" } ) - ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param); + default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { + return getDelegate().testInlineAdditionalProperties(param); + } /** @@ -279,7 +307,9 @@ public interface FakeApi { 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); + 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); + } /** @@ -299,7 +329,9 @@ public interface FakeApi { @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); + 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); + } /** @@ -323,6 +355,8 @@ public interface FakeApi { 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); + 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/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java index d61d01c66ba..6b22c1aba66 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,34 +1,8 @@ package org.openapitools.api; -import java.math.BigDecimal; -import org.openapitools.model.Client; -import org.openapitools.model.FileSchemaTestClass; -import org.threeten.bp.LocalDate; -import java.util.Map; -import org.openapitools.model.ModelApiResponse; -import org.threeten.bp.OffsetDateTime; -import org.openapitools.model.OuterComposite; -import org.springframework.core.io.Resource; -import org.openapitools.model.User; -import org.openapitools.model.XmlItem; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") @@ -37,218 +11,12 @@ public class FakeApiController implements FakeApi { private final FakeApiDelegate delegate; public FakeApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) FakeApiDelegate delegate) { - this.delegate = delegate; + this.delegate = Optional.ofNullable(delegate).orElse(new FakeApiDelegate() {}); } - /** - * POST /fake/create_xml_item : creates an XmlItem - * this route creates an XmlItem - * - * @param xmlItem XmlItem Body (required) - * @return successful operation (status code 200) - * @see FakeApi#createXmlItem - */ - public ResponseEntity createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true ) @Valid @RequestBody XmlItem xmlItem) { - return delegate.createXmlItem(xmlItem); - } - - /** - * POST /fake/outer/boolean - * Test serialization of outer boolean types - * - * @param body Input boolean as post body (optional) - * @return Output boolean (status code 200) - * @see FakeApi#fakeOuterBooleanSerialize - */ - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { - return delegate.fakeOuterBooleanSerialize(body); - } - - /** - * POST /fake/outer/composite - * Test serialization of object with outer number type - * - * @param body Input composite as post body (optional) - * @return Output composite (status code 200) - * @see FakeApi#fakeOuterCompositeSerialize - */ - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { - return delegate.fakeOuterCompositeSerialize(body); - } - - /** - * POST /fake/outer/number - * Test serialization of outer number types - * - * @param body Input number as post body (optional) - * @return Output number (status code 200) - * @see FakeApi#fakeOuterNumberSerialize - */ - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { - return delegate.fakeOuterNumberSerialize(body); - } - - /** - * POST /fake/outer/string - * Test serialization of outer string types - * - * @param body Input string as post body (optional) - * @return Output string (status code 200) - * @see FakeApi#fakeOuterStringSerialize - */ - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { - return delegate.fakeOuterStringSerialize(body); - } - - /** - * PUT /fake/body-with-file-schema - * For this test, the body for this request much reference a schema named `File`. - * - * @param body (required) - * @return Success (status code 200) - * @see FakeApi#testBodyWithFileSchema - */ - public ResponseEntity testBodyWithFileSchema(@ApiParam(value = "" ,required=true ) @Valid @RequestBody FileSchemaTestClass body) { - return delegate.testBodyWithFileSchema(body); - } - - /** - * PUT /fake/body-with-query-params - * - * @param query (required) - * @param body (required) - * @return Success (status code 200) - * @see FakeApi#testBodyWithQueryParams - */ - public ResponseEntity testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User body) { - return delegate.testBodyWithQueryParams(query, body); - } - - /** - * PATCH /fake : To test \"client\" model - * To test \"client\" model - * - * @param body client model (required) - * @return successful operation (status code 200) - * @see FakeApi#testClientModel - */ - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - return delegate.testClientModel(body); - } - - /** - * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * - * @param number None (required) - * @param _double None (required) - * @param patternWithoutDelimiter None (required) - * @param _byte None (required) - * @param integer None (optional) - * @param int32 None (optional) - * @param int64 None (optional) - * @param _float None (optional) - * @param string None (optional) - * @param binary None (optional) - * @param date None (optional) - * @param dateTime None (optional) - * @param password None (optional) - * @param paramCallback None (optional) - * @return Invalid username supplied (status code 400) - * or User not found (status code 404) - * @see FakeApi#testEndpointParameters - */ - public 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 delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); - } - - /** - * GET /fake : To test enum parameters - * To test enum parameters - * - * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<String>()) - * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) - * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<String>()) - * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) - * @param enumQueryInteger Query parameter enum test (double) (optional) - * @param enumQueryDouble Query parameter enum test (double) (optional) - * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) - * @param enumFormString Form parameter enum test (string) (optional, default to -efg) - * @return Invalid request (status code 400) - * or Not found (status code 404) - * @see FakeApi#testEnumParameters - */ - public 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 delegate.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); - } - - /** - * DELETE /fake : Fake endpoint to test group parameters (optional) - * Fake endpoint to test group parameters (optional) - * - * @param requiredStringGroup Required String in group parameters (required) - * @param requiredBooleanGroup Required Boolean in group parameters (required) - * @param requiredInt64Group Required Integer in group parameters (required) - * @param stringGroup String in group parameters (optional) - * @param booleanGroup Boolean in group parameters (optional) - * @param int64Group Integer in group parameters (optional) - * @return Someting wrong (status code 400) - * @see FakeApi#testGroupParameters - */ - public 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 delegate.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); - } - - /** - * POST /fake/inline-additionalProperties : test inline additionalProperties - * - * @param param request body (required) - * @return successful operation (status code 200) - * @see FakeApi#testInlineAdditionalProperties - */ - public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Map param) { - return delegate.testInlineAdditionalProperties(param); - } - - /** - * GET /fake/jsonFormData : test json serialization of form data - * - * @param param field1 (required) - * @param param2 field2 (required) - * @return successful operation (status code 200) - * @see FakeApi#testJsonFormData - */ - public 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 delegate.testJsonFormData(param, param2); - } - - /** - * PUT /fake/test-query-paramters - * To test the collection format in query parameters - * - * @param pipe (required) - * @param ioutil (required) - * @param http (required) - * @param url (required) - * @param context (required) - * @return Success (status code 200) - * @see FakeApi#testQueryParameterCollectionFormat - */ - public 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 delegate.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context); - } - - /** - * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) - * - * @param petId ID of pet to update (required) - * @param requiredFile file to upload (required) - * @param additionalMetadata Additional data to pass to server (optional) - * @return successful operation (status code 200) - * @see FakeApi#uploadFileWithRequiredFile - */ - public 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 delegate.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); + @Override + public FakeApiDelegate getDelegate() { + return delegate; } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java index c28f5b8e99f..48f9c6a1ae6 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -3,20 +3,24 @@ package org.openapitools.api; import java.math.BigDecimal; import org.openapitools.model.Client; import org.openapitools.model.FileSchemaTestClass; -import org.threeten.bp.LocalDate; +import java.time.LocalDate; import java.util.Map; import org.openapitools.model.ModelApiResponse; -import org.threeten.bp.OffsetDateTime; +import java.time.OffsetDateTime; import org.openapitools.model.OuterComposite; import org.springframework.core.io.Resource; import org.openapitools.model.User; import org.openapitools.model.XmlItem; import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; +import java.util.Optional; /** * A delegate to be called by the {@link FakeApiController}}. @@ -25,6 +29,10 @@ import java.util.Map; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public interface FakeApiDelegate { + default Optional getRequest() { + return Optional.empty(); + } + /** * POST /fake/create_xml_item : creates an XmlItem * this route creates an XmlItem @@ -33,7 +41,10 @@ public interface FakeApiDelegate { * @return successful operation (status code 200) * @see FakeApi#createXmlItem */ - ResponseEntity createXmlItem(XmlItem xmlItem); + default ResponseEntity createXmlItem(XmlItem xmlItem) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake/outer/boolean @@ -43,7 +54,10 @@ public interface FakeApiDelegate { * @return Output boolean (status code 200) * @see FakeApi#fakeOuterBooleanSerialize */ - ResponseEntity fakeOuterBooleanSerialize(Boolean body); + default ResponseEntity fakeOuterBooleanSerialize(Boolean body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake/outer/composite @@ -53,7 +67,19 @@ public interface FakeApiDelegate { * @return Output composite (status code 200) * @see FakeApi#fakeOuterCompositeSerialize */ - ResponseEntity fakeOuterCompositeSerialize(OuterComposite body); + default ResponseEntity fakeOuterCompositeSerialize(OuterComposite body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { + String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }"; + ApiUtil.setExampleResponse(request, "*/*", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake/outer/number @@ -63,7 +89,10 @@ public interface FakeApiDelegate { * @return Output number (status code 200) * @see FakeApi#fakeOuterNumberSerialize */ - ResponseEntity fakeOuterNumberSerialize(BigDecimal body); + default ResponseEntity fakeOuterNumberSerialize(BigDecimal body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake/outer/string @@ -73,7 +102,10 @@ public interface FakeApiDelegate { * @return Output string (status code 200) * @see FakeApi#fakeOuterStringSerialize */ - ResponseEntity fakeOuterStringSerialize(String body); + default ResponseEntity fakeOuterStringSerialize(String body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * PUT /fake/body-with-file-schema @@ -83,7 +115,10 @@ public interface FakeApiDelegate { * @return Success (status code 200) * @see FakeApi#testBodyWithFileSchema */ - ResponseEntity testBodyWithFileSchema(FileSchemaTestClass body); + default ResponseEntity testBodyWithFileSchema(FileSchemaTestClass body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * PUT /fake/body-with-query-params @@ -93,8 +128,11 @@ public interface FakeApiDelegate { * @return Success (status code 200) * @see FakeApi#testBodyWithQueryParams */ - ResponseEntity testBodyWithQueryParams(String query, - User body); + default ResponseEntity testBodyWithQueryParams(String query, + User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * PATCH /fake : To test \"client\" model @@ -104,7 +142,19 @@ public interface FakeApiDelegate { * @return successful operation (status code 200) * @see FakeApi#testClientModel */ - ResponseEntity testClientModel(Client body); + default ResponseEntity testClientModel(Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake : Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -128,7 +178,7 @@ public interface FakeApiDelegate { * or User not found (status code 404) * @see FakeApi#testEndpointParameters */ - ResponseEntity testEndpointParameters(BigDecimal number, + default ResponseEntity testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, @@ -141,15 +191,18 @@ public interface FakeApiDelegate { LocalDate date, OffsetDateTime dateTime, String password, - String paramCallback); + String paramCallback) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /fake : To test enum parameters * To test enum parameters * - * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<String>()) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to new ArrayList<>()) * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) - * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<String>()) + * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to new ArrayList<>()) * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) * @param enumQueryInteger Query parameter enum test (double) (optional) * @param enumQueryDouble Query parameter enum test (double) (optional) @@ -159,14 +212,17 @@ public interface FakeApiDelegate { * or Not found (status code 404) * @see FakeApi#testEnumParameters */ - ResponseEntity testEnumParameters(List enumHeaderStringArray, + default ResponseEntity testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, - String enumFormString); + String enumFormString) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * DELETE /fake : Fake endpoint to test group parameters (optional) @@ -181,12 +237,15 @@ public interface FakeApiDelegate { * @return Someting wrong (status code 400) * @see FakeApi#testGroupParameters */ - ResponseEntity testGroupParameters(Integer requiredStringGroup, + default ResponseEntity testGroupParameters(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, - Long int64Group); + Long int64Group) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake/inline-additionalProperties : test inline additionalProperties @@ -195,7 +254,10 @@ public interface FakeApiDelegate { * @return successful operation (status code 200) * @see FakeApi#testInlineAdditionalProperties */ - ResponseEntity testInlineAdditionalProperties(Map param); + default ResponseEntity testInlineAdditionalProperties(Map param) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /fake/jsonFormData : test json serialization of form data @@ -205,8 +267,11 @@ public interface FakeApiDelegate { * @return successful operation (status code 200) * @see FakeApi#testJsonFormData */ - ResponseEntity testJsonFormData(String param, - String param2); + default ResponseEntity testJsonFormData(String param, + String param2) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * PUT /fake/test-query-paramters @@ -220,11 +285,14 @@ public interface FakeApiDelegate { * @return Success (status code 200) * @see FakeApi#testQueryParameterCollectionFormat */ - ResponseEntity testQueryParameterCollectionFormat(List pipe, + default ResponseEntity testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, - List context); + List context) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) @@ -235,8 +303,20 @@ public interface FakeApiDelegate { * @return successful operation (status code 200) * @see FakeApi#uploadFileWithRequiredFile */ - ResponseEntity uploadFileWithRequiredFile(Long petId, + default ResponseEntity uploadFileWithRequiredFile(Long petId, MultipartFile requiredFile, - String additionalMetadata); + String additionalMetadata) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } 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 723fc9f62ac..6b02c884009 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 @@ -21,6 +21,10 @@ import java.util.Map; @Api(value = "fake_classname_test", description = "the fake_classname_test API") public interface FakeClassnameTestApi { + default FakeClassnameTestApiDelegate getDelegate() { + return new FakeClassnameTestApiDelegate() {}; + } + /** * PATCH /fake_classname_test : To test class name in snake case * To test class name in snake case @@ -38,6 +42,8 @@ public interface FakeClassnameTestApi { produces = { "application/json" }, consumes = { "application/json" } ) - ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + 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/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index 5c14bb5bed3..58497641e4c 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -1,24 +1,8 @@ package org.openapitools.api; -import org.openapitools.model.Client; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") @@ -27,19 +11,12 @@ public class FakeClassnameTestApiController implements FakeClassnameTestApi { private final FakeClassnameTestApiDelegate delegate; public FakeClassnameTestApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) FakeClassnameTestApiDelegate delegate) { - this.delegate = delegate; + this.delegate = Optional.ofNullable(delegate).orElse(new FakeClassnameTestApiDelegate() {}); } - /** - * PATCH /fake_classname_test : To test class name in snake case - * To test class name in snake case - * - * @param body client model (required) - * @return successful operation (status code 200) - * @see FakeClassnameTestApi#testClassname - */ - public ResponseEntity testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - return delegate.testClassname(body); + @Override + public FakeClassnameTestApiDelegate getDelegate() { + return delegate; } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index 20d9b798c62..c71fe13d195 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -2,11 +2,15 @@ package org.openapitools.api; import org.openapitools.model.Client; import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; +import java.util.Optional; /** * A delegate to be called by the {@link FakeClassnameTestApiController}}. @@ -15,6 +19,10 @@ import java.util.Map; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public interface FakeClassnameTestApiDelegate { + default Optional getRequest() { + return Optional.empty(); + } + /** * PATCH /fake_classname_test : To test class name in snake case * To test class name in snake case @@ -23,6 +31,18 @@ public interface FakeClassnameTestApiDelegate { * @return successful operation (status code 200) * @see FakeClassnameTestApi#testClassname */ - ResponseEntity testClassname(Client body); + default ResponseEntity testClassname(Client body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"client\" : \"client\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } 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 7ab2f6e9d5f..ffdbde323f1 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 @@ -24,6 +24,10 @@ import java.util.Map; @Api(value = "pet", description = "the pet API") public interface PetApi { + default PetApiDelegate getDelegate() { + return new PetApiDelegate() {}; + } + /** * POST /pet : Add a new pet to the store * @@ -44,7 +48,9 @@ public interface PetApi { 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); + 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); + } /** @@ -67,7 +73,9 @@ public interface PetApi { @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); + 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); + } /** @@ -91,7 +99,9 @@ public interface PetApi { 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); + 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); + } /** @@ -116,7 +126,9 @@ public interface PetApi { 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); + default ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { + return getDelegate().findPetsByTags(tags); + } /** @@ -139,7 +151,9 @@ public interface PetApi { value = "/pet/{petId}", produces = { "application/xml", "application/json" } ) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); + default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } /** @@ -166,7 +180,9 @@ public interface PetApi { 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); + 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); + } /** @@ -189,7 +205,9 @@ public interface PetApi { 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); + 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); + } /** @@ -213,6 +231,8 @@ public interface PetApi { 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); + 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/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java index 4a8a378932d..5fa088c6f10 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java @@ -1,27 +1,8 @@ package org.openapitools.api; -import org.openapitools.model.ModelApiResponse; -import org.openapitools.model.Pet; -import org.springframework.core.io.Resource; -import java.util.Set; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") @@ -30,113 +11,12 @@ public class PetApiController implements PetApi { private final PetApiDelegate delegate; public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { - this.delegate = delegate; + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() {}); } - /** - * POST /pet : Add a new pet to the store - * - * @param body Pet object that needs to be added to the store (required) - * @return successful operation (status code 200) - * or Invalid input (status code 405) - * @see PetApi#addPet - */ - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { - return delegate.addPet(body); - } - - /** - * DELETE /pet/{petId} : Deletes a pet - * - * @param petId Pet id to delete (required) - * @param apiKey (optional) - * @return successful operation (status code 200) - * or Invalid pet value (status code 400) - * @see PetApi#deletePet - */ - public 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 delegate.deletePet(petId, apiKey); - } - - /** - * GET /pet/findByStatus : Finds Pets by status - * Multiple status values can be provided with comma separated strings - * - * @param status Status values that need to be considered for filter (required) - * @return successful operation (status code 200) - * or Invalid status value (status code 400) - * @see PetApi#findPetsByStatus - */ - public 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 delegate.findPetsByStatus(status); - } - - /** - * GET /pet/findByTags : Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * - * @param tags Tags to filter by (required) - * @return successful operation (status code 200) - * or Invalid tag value (status code 400) - * @deprecated - * @see PetApi#findPetsByTags - */ - public ResponseEntity> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags) { - return delegate.findPetsByTags(tags); - } - - /** - * GET /pet/{petId} : Find pet by ID - * Returns a single pet - * - * @param petId ID of pet to return (required) - * @return successful operation (status code 200) - * or Invalid ID supplied (status code 400) - * or Pet not found (status code 404) - * @see PetApi#getPetById - */ - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) { - return delegate.getPetById(petId); - } - - /** - * PUT /pet : Update an existing pet - * - * @param body Pet object that needs to be added to the store (required) - * @return successful operation (status code 200) - * or Invalid ID supplied (status code 400) - * or Pet not found (status code 404) - * or Validation exception (status code 405) - * @see PetApi#updatePet - */ - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { - return delegate.updatePet(body); - } - - /** - * POST /pet/{petId} : Updates a pet in the store with form data - * - * @param petId ID of pet that needs to be updated (required) - * @param name Updated name of the pet (optional) - * @param status Updated status of the pet (optional) - * @return Invalid input (status code 405) - * @see PetApi#updatePetWithForm - */ - public 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 delegate.updatePetWithForm(petId, name, status); - } - - /** - * POST /pet/{petId}/uploadImage : uploads an image - * - * @param petId ID of pet to update (required) - * @param additionalMetadata Additional data to pass to server (optional) - * @param file file to upload (optional) - * @return successful operation (status code 200) - * @see PetApi#uploadFile - */ - public 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 delegate.uploadFile(petId, additionalMetadata, file); + @Override + public PetApiDelegate getDelegate() { + return delegate; } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java index 426aeb26948..5a70de5ef3e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -5,11 +5,15 @@ import org.openapitools.model.Pet; import org.springframework.core.io.Resource; import java.util.Set; import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; +import java.util.Optional; /** * A delegate to be called by the {@link PetApiController}}. @@ -18,6 +22,10 @@ import java.util.Map; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public interface PetApiDelegate { + default Optional getRequest() { + return Optional.empty(); + } + /** * POST /pet : Add a new pet to the store * @@ -26,7 +34,10 @@ public interface PetApiDelegate { * or Invalid input (status code 405) * @see PetApi#addPet */ - ResponseEntity addPet(Pet body); + default ResponseEntity addPet(Pet body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * DELETE /pet/{petId} : Deletes a pet @@ -37,8 +48,11 @@ public interface PetApiDelegate { * or Invalid pet value (status code 400) * @see PetApi#deletePet */ - ResponseEntity deletePet(Long petId, - String apiKey); + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /pet/findByStatus : Finds Pets by status @@ -49,7 +63,24 @@ public interface PetApiDelegate { * or Invalid status value (status code 400) * @see PetApi#findPetsByStatus */ - ResponseEntity> findPetsByStatus(List status); + default ResponseEntity> findPetsByStatus(List status) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /pet/findByTags : Finds Pets by tags @@ -61,7 +92,24 @@ public interface PetApiDelegate { * @deprecated * @see PetApi#findPetsByTags */ - ResponseEntity> findPetsByTags(Set tags); + default ResponseEntity> findPetsByTags(Set tags) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /pet/{petId} : Find pet by ID @@ -73,7 +121,24 @@ public interface PetApiDelegate { * or Pet not found (status code 404) * @see PetApi#getPetById */ - ResponseEntity getPetById(Long petId); + default ResponseEntity getPetById(Long petId) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 doggie aeiou aeiou "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * PUT /pet : Update an existing pet @@ -85,7 +150,10 @@ public interface PetApiDelegate { * or Validation exception (status code 405) * @see PetApi#updatePet */ - ResponseEntity updatePet(Pet body); + default ResponseEntity updatePet(Pet body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /pet/{petId} : Updates a pet in the store with form data @@ -96,9 +164,12 @@ public interface PetApiDelegate { * @return Invalid input (status code 405) * @see PetApi#updatePetWithForm */ - ResponseEntity updatePetWithForm(Long petId, + default ResponseEntity updatePetWithForm(Long petId, String name, - String status); + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /pet/{petId}/uploadImage : uploads an image @@ -109,8 +180,20 @@ public interface PetApiDelegate { * @return successful operation (status code 200) * @see PetApi#uploadFile */ - ResponseEntity uploadFile(Long petId, + default ResponseEntity uploadFile(Long petId, String additionalMetadata, - MultipartFile file); + MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } 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 0128cb2d54b..96c812bb697 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 @@ -22,6 +22,10 @@ import java.util.Map; @Api(value = "store", description = "the store API") public interface StoreApi { + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() {}; + } + /** * DELETE /store/order/{order_id} : Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -37,7 +41,9 @@ public interface StoreApi { @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); + 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); + } /** @@ -55,7 +61,9 @@ public interface StoreApi { value = "/store/inventory", produces = { "application/json" } ) - ResponseEntity> getInventory(); + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } /** @@ -76,7 +84,9 @@ public interface StoreApi { 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); + 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); + } /** @@ -94,6 +104,8 @@ public interface StoreApi { value = "/store/order", produces = { "application/xml", "application/json" } ) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + 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/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiController.java index ad6c539471b..9e08c646ae9 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiController.java @@ -1,25 +1,8 @@ package org.openapitools.api; -import java.util.Map; -import org.openapitools.model.Order; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") @@ -28,57 +11,12 @@ public class StoreApiController implements StoreApi { private final StoreApiDelegate delegate; public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { - this.delegate = delegate; + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() {}); } - /** - * DELETE /store/order/{order_id} : Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * - * @param orderId ID of the order that needs to be deleted (required) - * @return Invalid ID supplied (status code 400) - * or Order not found (status code 404) - * @see StoreApi#deleteOrder - */ - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) { - return delegate.deleteOrder(orderId); - } - - /** - * GET /store/inventory : Returns pet inventories by status - * Returns a map of status codes to quantities - * - * @return successful operation (status code 200) - * @see StoreApi#getInventory - */ - public ResponseEntity> getInventory() { - return delegate.getInventory(); - } - - /** - * GET /store/order/{order_id} : Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * - * @param orderId ID of pet that needs to be fetched (required) - * @return successful operation (status code 200) - * or Invalid ID supplied (status code 400) - * or Order not found (status code 404) - * @see StoreApi#getOrderById - */ - public ResponseEntity getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) { - return delegate.getOrderById(orderId); - } - - /** - * POST /store/order : Place an order for a pet - * - * @param body order placed for purchasing the pet (required) - * @return successful operation (status code 200) - * or Invalid Order (status code 400) - * @see StoreApi#placeOrder - */ - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { - return delegate.placeOrder(body); + @Override + public StoreApiDelegate getDelegate() { + return delegate; } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java index a7bfc60e128..5091e7e1f2c 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -3,11 +3,15 @@ package org.openapitools.api; import java.util.Map; import org.openapitools.model.Order; import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; +import java.util.Optional; /** * A delegate to be called by the {@link StoreApiController}}. @@ -16,6 +20,10 @@ import java.util.Map; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public interface StoreApiDelegate { + default Optional getRequest() { + return Optional.empty(); + } + /** * DELETE /store/order/{order_id} : Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -25,7 +33,10 @@ public interface StoreApiDelegate { * or Order not found (status code 404) * @see StoreApi#deleteOrder */ - ResponseEntity deleteOrder(String orderId); + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /store/inventory : Returns pet inventories by status @@ -34,7 +45,10 @@ public interface StoreApiDelegate { * @return successful operation (status code 200) * @see StoreApi#getInventory */ - ResponseEntity> getInventory(); + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /store/order/{order_id} : Find purchase order by ID @@ -46,7 +60,24 @@ public interface StoreApiDelegate { * or Order not found (status code 404) * @see StoreApi#getOrderById */ - ResponseEntity getOrderById(Long orderId); + default ResponseEntity getOrderById(Long orderId) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /store/order : Place an order for a pet @@ -56,6 +87,23 @@ public interface StoreApiDelegate { * or Invalid Order (status code 400) * @see StoreApi#placeOrder */ - ResponseEntity placeOrder(Order body); + default ResponseEntity placeOrder(Order body) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } 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 e1d4245a6b1..f572889cda6 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 @@ -22,6 +22,10 @@ import java.util.Map; @Api(value = "user", description = "the user API") public interface UserApi { + default UserApiDelegate getDelegate() { + return new UserApiDelegate() {}; + } + /** * POST /user : Create user * This can only be done by the logged in user. @@ -35,7 +39,9 @@ public interface UserApi { @PostMapping( value = "/user" ) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); + default ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + return getDelegate().createUser(body); + } /** @@ -50,7 +56,9 @@ public interface UserApi { @PostMapping( value = "/user/createWithArray" ) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + default ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + return getDelegate().createUsersWithArrayInput(body); + } /** @@ -65,7 +73,9 @@ public interface UserApi { @PostMapping( value = "/user/createWithList" ) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + default ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + return getDelegate().createUsersWithListInput(body); + } /** @@ -83,7 +93,9 @@ public interface UserApi { @DeleteMapping( value = "/user/{username}" ) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); + default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } /** @@ -103,7 +115,9 @@ public interface UserApi { 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); + 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); + } /** @@ -122,7 +136,9 @@ public interface UserApi { 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); + 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); + } /** @@ -136,7 +152,9 @@ public interface UserApi { @GetMapping( value = "/user/logout" ) - ResponseEntity logoutUser(); + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } /** @@ -155,6 +173,8 @@ public interface UserApi { @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); + 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/UserApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiController.java index 4ee524e3a04..bc2d33598fd 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiController.java @@ -1,25 +1,8 @@ package org.openapitools.api; -import java.util.List; -import org.openapitools.model.User; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -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.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; +import java.util.Optional; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") @Controller @RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") @@ -28,104 +11,12 @@ public class UserApiController implements UserApi { private final UserApiDelegate delegate; public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { - this.delegate = delegate; + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() {}); } - /** - * POST /user : Create user - * This can only be done by the logged in user. - * - * @param body Created user object (required) - * @return successful operation (status code 200) - * @see UserApi#createUser - */ - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { - return delegate.createUser(body); - } - - /** - * POST /user/createWithArray : Creates list of users with given input array - * - * @param body List of user object (required) - * @return successful operation (status code 200) - * @see UserApi#createUsersWithArrayInput - */ - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { - return delegate.createUsersWithArrayInput(body); - } - - /** - * POST /user/createWithList : Creates list of users with given input array - * - * @param body List of user object (required) - * @return successful operation (status code 200) - * @see UserApi#createUsersWithListInput - */ - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { - return delegate.createUsersWithListInput(body); - } - - /** - * DELETE /user/{username} : Delete user - * This can only be done by the logged in user. - * - * @param username The name that needs to be deleted (required) - * @return Invalid username supplied (status code 400) - * or User not found (status code 404) - * @see UserApi#deleteUser - */ - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) { - return delegate.deleteUser(username); - } - - /** - * GET /user/{username} : Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @return successful operation (status code 200) - * or Invalid username supplied (status code 400) - * or User not found (status code 404) - * @see UserApi#getUserByName - */ - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) { - return delegate.getUserByName(username); - } - - /** - * GET /user/login : Logs user into the system - * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) - * @return successful operation (status code 200) - * or Invalid username/password supplied (status code 400) - * @see UserApi#loginUser - */ - public 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 delegate.loginUser(username, password); - } - - /** - * GET /user/logout : Logs out current logged in user session - * - * @return successful operation (status code 200) - * @see UserApi#logoutUser - */ - public ResponseEntity logoutUser() { - return delegate.logoutUser(); - } - - /** - * PUT /user/{username} : Updated user - * This can only be done by the logged in user. - * - * @param username name that need to be deleted (required) - * @param body Updated user object (required) - * @return Invalid user supplied (status code 400) - * or User not found (status code 404) - * @see UserApi#updateUser - */ - public 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 delegate.updateUser(username, body); + @Override + public UserApiDelegate getDelegate() { + return delegate; } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java index 81c3ecc2588..78da7c8510b 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -3,11 +3,15 @@ package org.openapitools.api; import java.util.List; import org.openapitools.model.User; import io.swagger.annotations.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; +import java.util.Optional; /** * A delegate to be called by the {@link UserApiController}}. @@ -16,6 +20,10 @@ import java.util.Map; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public interface UserApiDelegate { + default Optional getRequest() { + return Optional.empty(); + } + /** * POST /user : Create user * This can only be done by the logged in user. @@ -24,7 +32,10 @@ public interface UserApiDelegate { * @return successful operation (status code 200) * @see UserApi#createUser */ - ResponseEntity createUser(User body); + default ResponseEntity createUser(User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /user/createWithArray : Creates list of users with given input array @@ -33,7 +44,10 @@ public interface UserApiDelegate { * @return successful operation (status code 200) * @see UserApi#createUsersWithArrayInput */ - ResponseEntity createUsersWithArrayInput(List body); + default ResponseEntity createUsersWithArrayInput(List body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * POST /user/createWithList : Creates list of users with given input array @@ -42,7 +56,10 @@ public interface UserApiDelegate { * @return successful operation (status code 200) * @see UserApi#createUsersWithListInput */ - ResponseEntity createUsersWithListInput(List body); + default ResponseEntity createUsersWithListInput(List body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * DELETE /user/{username} : Delete user @@ -53,7 +70,10 @@ public interface UserApiDelegate { * or User not found (status code 404) * @see UserApi#deleteUser */ - ResponseEntity deleteUser(String username); + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /user/{username} : Get user by user name @@ -64,7 +84,24 @@ public interface UserApiDelegate { * or User not found (status code 404) * @see UserApi#getUserByName */ - ResponseEntity getUserByName(String username); + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + String exampleString = " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123 "; + ApiUtil.setExampleResponse(request, "application/xml", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /user/login : Logs user into the system @@ -75,8 +112,11 @@ public interface UserApiDelegate { * or Invalid username/password supplied (status code 400) * @see UserApi#loginUser */ - ResponseEntity loginUser(String username, - String password); + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * GET /user/logout : Logs out current logged in user session @@ -84,7 +124,10 @@ public interface UserApiDelegate { * @return successful operation (status code 200) * @see UserApi#logoutUser */ - ResponseEntity logoutUser(); + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } /** * PUT /user/{username} : Updated user @@ -96,7 +139,10 @@ public interface UserApiDelegate { * or User not found (status code 404) * @see UserApi#updateUser */ - ResponseEntity updateUser(String username, - User body); + default ResponseEntity updateUser(String username, + User body) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java deleted file mode 100644 index 8f936b31144..00000000000 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/JacksonConfiguration.java deleted file mode 100644 index b481a87518f..00000000000 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/JacksonConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; - -@Configuration -public class JacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(ThreeTenModule.class) - ThreeTenModule threeTenModule() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - return module; - } -} diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java index 425e530b93b..589dd7dc5e7 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -40,8 +40,9 @@ public class OpenAPIDocumentationConfig { .select() .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) .build() - .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class) + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) .apiInfo(apiInfo()); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index 1e2c8c2726d..76a9f4e4c25 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -66,7 +66,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) { if (this.mapString == null) { - this.mapString = new HashMap(); + this.mapString = new HashMap<>(); } this.mapString.put(key, mapStringItem); return this; @@ -94,7 +94,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) { if (this.mapNumber == null) { - this.mapNumber = new HashMap(); + this.mapNumber = new HashMap<>(); } this.mapNumber.put(key, mapNumberItem); return this; @@ -123,7 +123,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) { if (this.mapInteger == null) { - this.mapInteger = new HashMap(); + this.mapInteger = new HashMap<>(); } this.mapInteger.put(key, mapIntegerItem); return this; @@ -151,7 +151,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) { if (this.mapBoolean == null) { - this.mapBoolean = new HashMap(); + this.mapBoolean = new HashMap<>(); } this.mapBoolean.put(key, mapBooleanItem); return this; @@ -179,7 +179,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List mapArrayIntegerItem) { if (this.mapArrayInteger == null) { - this.mapArrayInteger = new HashMap>(); + this.mapArrayInteger = new HashMap<>(); } this.mapArrayInteger.put(key, mapArrayIntegerItem); return this; @@ -208,7 +208,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List mapArrayAnytypeItem) { if (this.mapArrayAnytype == null) { - this.mapArrayAnytype = new HashMap>(); + this.mapArrayAnytype = new HashMap<>(); } this.mapArrayAnytype.put(key, mapArrayAnytypeItem); return this; @@ -237,7 +237,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapMapStringItem(String key, Map mapMapStringItem) { if (this.mapMapString == null) { - this.mapMapString = new HashMap>(); + this.mapMapString = new HashMap<>(); } this.mapMapString.put(key, mapMapStringItem); return this; @@ -266,7 +266,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map mapMapAnytypeItem) { if (this.mapMapAnytype == null) { - this.mapMapAnytype = new HashMap>(); + this.mapMapAnytype = new HashMap<>(); } this.mapMapAnytype.put(key, mapMapAnytypeItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java index 9c226efbbc4..aec96b23f03 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -28,7 +28,7 @@ public class ArrayOfArrayOfNumberOnly { public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { if (this.arrayArrayNumber == null) { - this.arrayArrayNumber = new ArrayList>(); + this.arrayArrayNumber = new ArrayList<>(); } this.arrayArrayNumber.add(arrayArrayNumberItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java index 51ea58aab38..63a657c8ddd 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -28,7 +28,7 @@ public class ArrayOfNumberOnly { public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { if (this.arrayNumber == null) { - this.arrayNumber = new ArrayList(); + this.arrayNumber = new ArrayList<>(); } this.arrayNumber.add(arrayNumberItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java index 1fea247ab3c..2a36629dfc7 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java @@ -36,7 +36,7 @@ public class ArrayTest { public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { if (this.arrayOfString == null) { - this.arrayOfString = new ArrayList(); + this.arrayOfString = new ArrayList<>(); } this.arrayOfString.add(arrayOfStringItem); return this; @@ -64,7 +64,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { if (this.arrayArrayOfInteger == null) { - this.arrayArrayOfInteger = new ArrayList>(); + this.arrayArrayOfInteger = new ArrayList<>(); } this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); return this; @@ -93,7 +93,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { if (this.arrayArrayOfModel == null) { - this.arrayArrayOfModel = new ArrayList>(); + this.arrayArrayOfModel = new ArrayList<>(); } this.arrayArrayOfModel.add(arrayArrayOfModelItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java index 90d7bf130bb..ec2d4e1ce8b 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/EnumArrays.java @@ -121,7 +121,7 @@ public class EnumArrays { public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { if (this.arrayEnum == null) { - this.arrayEnum = new ArrayList(); + this.arrayEnum = new ArrayList<>(); } this.arrayEnum.add(arrayEnumItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java index a99196c2808..8e4f8d5d5d9 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -51,7 +51,7 @@ public class FileSchemaTestClass { public FileSchemaTestClass addFilesItem(java.io.File filesItem) { if (this.files == null) { - this.files = new ArrayList(); + this.files = new ArrayList<>(); } this.files.add(filesItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java index 533569e421d..55298e86211 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FormatTest.java @@ -6,10 +6,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; import java.util.UUID; import org.springframework.core.io.Resource; -import org.threeten.bp.LocalDate; -import org.threeten.bp.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; import javax.validation.Valid; import javax.validation.constraints.*; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java index b1d48c044ad..7b9a321ecb2 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MapTest.java @@ -76,7 +76,7 @@ public class MapTest { public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { if (this.mapMapOfString == null) { - this.mapMapOfString = new HashMap>(); + this.mapMapOfString = new HashMap<>(); } this.mapMapOfString.put(key, mapMapOfStringItem); return this; @@ -105,7 +105,7 @@ public class MapTest { public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { if (this.mapOfEnumString == null) { - this.mapOfEnumString = new HashMap(); + this.mapOfEnumString = new HashMap<>(); } this.mapOfEnumString.put(key, mapOfEnumStringItem); return this; @@ -133,7 +133,7 @@ public class MapTest { public MapTest putDirectMapItem(String key, Boolean directMapItem) { if (this.directMap == null) { - this.directMap = new HashMap(); + this.directMap = new HashMap<>(); } this.directMap.put(key, directMapItem); return this; @@ -161,7 +161,7 @@ public class MapTest { public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) { if (this.indirectMap == null) { - this.indirectMap = new HashMap(); + this.indirectMap = new HashMap<>(); } this.indirectMap.put(key, indirectMapItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java index 71693227fa7..d80573256c6 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -5,12 +5,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import org.openapitools.model.Animal; -import org.threeten.bp.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; import javax.validation.Valid; import javax.validation.constraints.*; @@ -80,7 +80,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { if (this.map == null) { - this.map = new HashMap(); + this.map = new HashMap<>(); } this.map.put(key, mapItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java index 06a8fdb8935..0c9dddf85da 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Order.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.threeten.bp.OffsetDateTime; +import java.time.OffsetDateTime; import org.openapitools.jackson.nullable.JsonNullable; import javax.validation.Valid; import javax.validation.constraints.*; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java index 5f8b54eb573..5f44cab5669 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Pet.java @@ -32,7 +32,7 @@ public class Pet { @JsonProperty("photoUrls") @Valid - private Set photoUrls = new LinkedHashSet(); + private Set photoUrls = new LinkedHashSet<>(); @JsonProperty("tags") @Valid @@ -173,7 +173,7 @@ public class Pet { public Pet addTagsItem(Tag tagsItem) { if (this.tags == null) { - this.tags = new ArrayList(); + this.tags = new ArrayList<>(); } this.tags.add(tagsItem); return this; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java index bcf00b393fd..80788f31612 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderDefault.java @@ -31,7 +31,7 @@ public class TypeHolderDefault { @JsonProperty("array_item") @Valid - private List arrayItem = new ArrayList(); + private List arrayItem = new ArrayList<>(); public TypeHolderDefault stringItem(String stringItem) { this.stringItem = stringItem; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java index 2151f844f8e..963c3c66b57 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java @@ -34,7 +34,7 @@ public class TypeHolderExample { @JsonProperty("array_item") @Valid - private List arrayItem = new ArrayList(); + private List arrayItem = new ArrayList<>(); public TypeHolderExample stringItem(String stringItem) { this.stringItem = stringItem; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java index 9240d5345a6..465b94b6a88 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/XmlItem.java @@ -201,7 +201,7 @@ public class XmlItem { public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) { if (this.wrappedArray == null) { - this.wrappedArray = new ArrayList(); + this.wrappedArray = new ArrayList<>(); } this.wrappedArray.add(wrappedArrayItem); return this; @@ -310,7 +310,7 @@ public class XmlItem { public XmlItem addNameArrayItem(Integer nameArrayItem) { if (this.nameArray == null) { - this.nameArray = new ArrayList(); + this.nameArray = new ArrayList<>(); } this.nameArray.add(nameArrayItem); return this; @@ -338,7 +338,7 @@ public class XmlItem { public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) { if (this.nameWrappedArray == null) { - this.nameWrappedArray = new ArrayList(); + this.nameWrappedArray = new ArrayList<>(); } this.nameWrappedArray.add(nameWrappedArrayItem); return this; @@ -447,7 +447,7 @@ public class XmlItem { public XmlItem addPrefixArrayItem(Integer prefixArrayItem) { if (this.prefixArray == null) { - this.prefixArray = new ArrayList(); + this.prefixArray = new ArrayList<>(); } this.prefixArray.add(prefixArrayItem); return this; @@ -475,7 +475,7 @@ public class XmlItem { public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) { if (this.prefixWrappedArray == null) { - this.prefixWrappedArray = new ArrayList(); + this.prefixWrappedArray = new ArrayList<>(); } this.prefixWrappedArray.add(prefixWrappedArrayItem); return this; @@ -584,7 +584,7 @@ public class XmlItem { public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) { if (this.namespaceArray == null) { - this.namespaceArray = new ArrayList(); + this.namespaceArray = new ArrayList<>(); } this.namespaceArray.add(namespaceArrayItem); return this; @@ -612,7 +612,7 @@ public class XmlItem { public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) { if (this.namespaceWrappedArray == null) { - this.namespaceWrappedArray = new ArrayList(); + this.namespaceWrappedArray = new ArrayList<>(); } this.namespaceWrappedArray.add(namespaceWrappedArrayItem); return this; @@ -721,7 +721,7 @@ public class XmlItem { public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) { if (this.prefixNsArray == null) { - this.prefixNsArray = new ArrayList(); + this.prefixNsArray = new ArrayList<>(); } this.prefixNsArray.add(prefixNsArrayItem); return this; @@ -749,7 +749,7 @@ public class XmlItem { public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) { if (this.prefixNsWrappedArray == null) { - this.prefixNsWrappedArray = new ArrayList(); + this.prefixNsWrappedArray = new ArrayList<>(); } this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem); return this;