From e1c5b220cd0b0659be770a8f406544a691c40a5e Mon Sep 17 00:00:00 2001 From: cachescrubber <5127753+cachescrubber@users.noreply.github.com> Date: Sat, 22 Jan 2022 01:51:17 +0100 Subject: [PATCH] [JAVA] new Feature interface: Documentation Provider and Annotation Library (#11258) * Implement DocumentationProviderFeatures and integrate it in AbstractJavaCodegen * Integrate DocumentationProviderFeatures in SpringCodegen * Run new test config spring-boot-springdoc * Do not use Locale.ROOT * Do not use Locale.ROOT, use NONE instead of empty list * Revert "Do not use Locale.ROOT" This reverts commit a0d6aac92bea2370b4f164d18ada3fd9097f3a30. * Do not use forbidden APIs * Fix spring maven plugin example * Introduce DocumentationProviderFeaturesTest.java * replace AUTO with preferredAnnotationLibrary * remove sout.println from Test * Apply code style. * Update spring sample configuration to use the new property * Update samples after merge * fix atBean import * Generate all samples * Add ParameterObject to test * Allow Subclasses to opt out * Use OpenAPI 2 (fka Swagger RESTful API Documentation Specification) instead of just "Swagger" * export generator docs * Fix typo * Fix typo - update docs. --- ...-boot-beanvalidation-no-nullable-oas3.yaml | 2 +- ...pring-boot-beanvalidation-no-nullable.yaml | 1 + bin/configs/spring-boot-beanvalidation.yaml | 1 + bin/configs/spring-boot-delegate-j8.yaml | 1 + bin/configs/spring-boot-delegate-oas3.yaml | 2 +- bin/configs/spring-boot-delegate.yaml | 1 + .../spring-boot-implicitHeaders-oas3.yaml | 1 + bin/configs/spring-boot-implicitHeaders.yaml | 1 + bin/configs/spring-boot-oas3.yaml | 2 +- bin/configs/spring-boot-reactive-oas3.yaml | 2 +- bin/configs/spring-boot-reactive.yaml | 1 + bin/configs/spring-boot-springdoc.yaml | 10 + bin/configs/spring-boot-useoptional-oas3.yaml | 2 +- bin/configs/spring-boot-useoptional.yaml | 1 + bin/configs/spring-boot-virtualan.yaml | 1 + bin/configs/spring-boot.yaml | 1 + bin/configs/spring-cloud-async-oas3.yaml | 2 +- bin/configs/spring-cloud-async.yaml | 1 + bin/configs/spring-cloud-date-time-oas3.yaml | 4 +- bin/configs/spring-cloud-date-time.yaml | 1 + bin/configs/spring-cloud-oas3-fakeapi.yaml | 2 +- bin/configs/spring-cloud-oas3.yaml | 2 +- ...d-petstore-feign-spring-pageable-oas3.yaml | 2 +- ...-cloud-petstore-feign-spring-pageable.yaml | 1 + bin/configs/spring-cloud.yaml | 1 + bin/configs/spring-mvc-default-values.yaml | 1 + bin/configs/spring-mvc-j8-async.yaml | 1 + bin/configs/spring-mvc-j8-localdatetime.yaml | 1 + bin/configs/spring-mvc-no-nullable.yaml | 1 + ...g-mvc-petstore-server-spring-pageable.yaml | 1 + bin/configs/spring-mvc.yaml | 1 + bin/configs/spring-stubs-oas3.yaml | 2 +- bin/configs/spring-stubs.yaml | 1 + ...g-pageable-delegatePattern-without-j8.yaml | 1 + ...erver-spring-pageable-delegatePattern.yaml | 1 + ...ore-server-spring-pageable-without-j8.yaml | 1 + ...gboot-petstore-server-spring-pageable.yaml | 1 + docs/generators/java-camel.md | 3 +- docs/generators/spring.md | 3 +- .../examples/spring.xml | 1 + .../languages/AbstractJavaCodegen.java | 83 +- .../codegen/languages/SpringCodegen.java | 60 +- .../DocumentationProviderFeatures.java | 173 ++++ .../JavaSpring/allowableValues.mustache | 2 +- .../main/resources/JavaSpring/api.mustache | 38 +- .../JavaSpring/apiController.mustache | 10 +- .../JavaSpring/homeController.mustache | 31 +- .../libraries/spring-boot/README.mustache | 4 +- .../spring-boot/application.mustache | 4 +- .../spring-boot/openapi2SpringBoot.mustache | 12 +- .../libraries/spring-boot/pom.mustache | 60 +- .../libraries/spring-cloud/pom.mustache | 56 +- .../libraries/spring-mvc/README.mustache | 4 +- .../libraries/spring-mvc/application.mustache | 4 +- .../openapiUiConfiguration.mustache | 12 +- .../libraries/spring-mvc/pom.mustache | 8 +- .../main/resources/JavaSpring/model.mustache | 4 +- .../resources/JavaSpring/paramDoc.mustache | 2 +- .../main/resources/JavaSpring/pojo.mustache | 15 +- .../java/spring/SpringCodegenTest.java | 4 + .../DocumentationProviderFeaturesTest.java | 50 + .../petstore/spring-cloud-async/pom.xml | 1 - .../petstore/spring-cloud-date-time/pom.xml | 1 - .../spring-cloud-spring-pageable/pom.xml | 1 - samples/client/petstore/spring-cloud/pom.xml | 1 - .../petstore/spring-cloud-async/pom.xml | 9 +- .../petstore/spring-cloud-date-time/pom.xml | 9 +- .../spring-cloud-oas3-fakeapi/pom.xml | 9 +- .../spring-cloud-spring-pageable/pom.xml | 9 +- .../java/org/openapitools/api/PetApi.java | 5 +- .../client/petstore/spring-cloud/pom.xml | 9 +- .../client/petstore/spring-stubs/pom.xml | 11 +- .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 20 + .../.openapi-generator/VERSION | 1 + .../petstore/spring-boot-springdoc/README.md | 16 + .../petstore/spring-boot-springdoc/pom.xml | 72 ++ .../org/openapitools/OpenAPI2SpringBoot.java | 63 ++ .../org/openapitools/RFC3339DateFormat.java | 38 + .../java/org/openapitools/api/ApiUtil.java | 19 + .../java/org/openapitools/api/PetApi.java | 393 ++++++++ .../openapitools/api/PetApiController.java | 27 + .../java/org/openapitools/api/StoreApi.java | 190 ++++ .../openapitools/api/StoreApiController.java | 27 + .../java/org/openapitools/api/UserApi.java | 304 ++++++ .../openapitools/api/UserApiController.java | 27 + .../configuration/HomeController.java | 53 ++ .../java/org/openapitools/model/Category.java | 108 +++ .../openapitools/model/ModelApiResponse.java | 132 +++ .../java/org/openapitools/model/Order.java | 245 +++++ .../main/java/org/openapitools/model/Pet.java | 261 +++++ .../main/java/org/openapitools/model/Tag.java | 108 +++ .../java/org/openapitools/model/User.java | 252 +++++ .../src/main/resources/application.properties | 3 + .../src/main/resources/openapi.yaml | 893 ++++++++++++++++++ .../pom.xml | 11 +- .../api/AnotherFakeApiController.java | 1 + .../openapitools/api/FakeApiController.java | 1 + .../api/FakeClassnameTestApiController.java | 1 + .../openapitools/api/PetApiController.java | 1 + .../openapitools/api/StoreApiController.java | 1 + .../openapitools/api/UserApiController.java | 1 + .../configuration/HomeController.java | 2 +- .../petstore/springboot-delegate/pom.xml | 11 +- .../configuration/HomeController.java | 2 +- .../springboot-implicitHeaders/pom.xml | 11 +- .../configuration/HomeController.java | 2 +- .../petstore/springboot-reactive/pom.xml | 11 +- .../configuration/HomeController.java | 3 +- .../petstore/springboot-useoptional/pom.xml | 11 +- .../configuration/HomeController.java | 2 +- .../server/petstore/springboot/pom.xml | 11 +- .../configuration/HomeController.java | 2 +- .../api/AnotherFakeApiController.java | 1 - .../openapitools/api/FakeApiController.java | 1 - .../api/FakeClassnameTestApiController.java | 1 - .../openapitools/api/PetApiController.java | 1 - .../openapitools/api/StoreApiController.java | 1 - .../openapitools/api/UserApiController.java | 1 - .../petstore/springboot-reactive/README.md | 2 + .../petstore/springboot-reactive/pom.xml | 9 +- .../org/openapitools/OpenAPI2SpringBoot.java | 6 - .../org/openapitools/api/AnotherFakeApi.java | 3 +- .../api/AnotherFakeApiDelegate.java | 1 + .../java/org/openapitools/api/FakeApi.java | 31 +- .../org/openapitools/api/FakeApiDelegate.java | 1 + .../api/FakeClassnameTestApi.java | 3 +- .../api/FakeClassnameTestApiDelegate.java | 1 + .../java/org/openapitools/api/PetApi.java | 17 +- .../org/openapitools/api/PetApiDelegate.java | 1 + .../java/org/openapitools/api/StoreApi.java | 9 +- .../openapitools/api/StoreApiDelegate.java | 1 + .../java/org/openapitools/api/UserApi.java | 17 +- .../org/openapitools/api/UserApiDelegate.java | 1 + .../configuration/HomeController.java | 37 +- .../src/main/resources/application.properties | 1 + .../api/AnotherFakeApiController.java | 1 - .../openapitools/api/FakeApiController.java | 1 - .../api/FakeClassnameTestApiController.java | 1 - .../openapitools/api/PetApiController.java | 1 - .../openapitools/api/StoreApiController.java | 1 - .../openapitools/api/UserApiController.java | 1 - .../api/AnotherFakeApiController.java | 1 - .../openapitools/api/FakeApiController.java | 1 - .../api/FakeClassnameTestApiController.java | 1 - .../openapitools/api/PetApiController.java | 1 - .../openapitools/api/StoreApiController.java | 1 - .../openapitools/api/UserApiController.java | 1 - 148 files changed, 3971 insertions(+), 315 deletions(-) create mode 100644 bin/configs/spring-boot-springdoc.yaml create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/features/DocumentationProviderFeatures.java create mode 100644 modules/openapi-generator/src/test/java/org/openapitools/codegen/languages/features/DocumentationProviderFeaturesTest.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator-ignore create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/FILES create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/VERSION create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/README.md create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/pom.xml create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/RFC3339DateFormat.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/ApiUtil.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApi.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApiController.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApi.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApiController.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApi.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApiController.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/HomeController.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Category.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/ModelApiResponse.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Order.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Pet.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Tag.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/User.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/application.properties create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/openapi.yaml diff --git a/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml b/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml index 760305ec6cbf..b1e5245ae85b 100644 --- a/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml +++ b/bin/configs/spring-boot-beanvalidation-no-nullable-oas3.yaml @@ -5,7 +5,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 - oas3: "true" + documentationProvider: springdoc java8: "false" useBeanValidation: true artifactId: spring-boot-beanvalidation-no-nullable diff --git a/bin/configs/spring-boot-beanvalidation-no-nullable.yaml b/bin/configs/spring-boot-beanvalidation-no-nullable.yaml index 85c687f4978b..1457469bc725 100644 --- a/bin/configs/spring-boot-beanvalidation-no-nullable.yaml +++ b/bin/configs/spring-boot-beanvalidation-no-nullable.yaml @@ -4,6 +4,7 @@ library: spring-boot 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: + documentationProvider: springfox java8: "false" useBeanValidation: true artifactId: spring-boot-beanvalidation-no-nullable diff --git a/bin/configs/spring-boot-beanvalidation.yaml b/bin/configs/spring-boot-beanvalidation.yaml index 573d8e283b55..dd4ea561c849 100644 --- a/bin/configs/spring-boot-beanvalidation.yaml +++ b/bin/configs/spring-boot-beanvalidation.yaml @@ -4,6 +4,7 @@ library: spring-boot 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: + documentationProvider: springfox java8: true useBeanValidation: true artifactId: spring-boot-beanvalidation diff --git a/bin/configs/spring-boot-delegate-j8.yaml b/bin/configs/spring-boot-delegate-j8.yaml index a90e8b3ce1d4..e1fae5805cd2 100644 --- a/bin/configs/spring-boot-delegate-j8.yaml +++ b/bin/configs/spring-boot-delegate-j8.yaml @@ -3,6 +3,7 @@ outputDir: samples/server/petstore/springboot-delegate-j8 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: + documentationProvider: springfox artifactId: springboot-delegate-j8 hideGenerationTimestamp: "true" delegatePattern: "true" diff --git a/bin/configs/spring-boot-delegate-oas3.yaml b/bin/configs/spring-boot-delegate-oas3.yaml index 7d8631523d8a..8b604d558a9e 100644 --- a/bin/configs/spring-boot-delegate-oas3.yaml +++ b/bin/configs/spring-boot-delegate-oas3.yaml @@ -4,7 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 - oas3: "true" + documentationProvider: springdoc artifactId: springboot-delegate hideGenerationTimestamp: "true" java8: true diff --git a/bin/configs/spring-boot-delegate.yaml b/bin/configs/spring-boot-delegate.yaml index 162094128db3..228b14d823e2 100644 --- a/bin/configs/spring-boot-delegate.yaml +++ b/bin/configs/spring-boot-delegate.yaml @@ -3,6 +3,7 @@ outputDir: samples/server/petstore/springboot-delegate 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: + documentationProvider: springfox artifactId: springboot-delegate hideGenerationTimestamp: "true" java8: true diff --git a/bin/configs/spring-boot-implicitHeaders-oas3.yaml b/bin/configs/spring-boot-implicitHeaders-oas3.yaml index 973561fad57e..3d9423cd3264 100644 --- a/bin/configs/spring-boot-implicitHeaders-oas3.yaml +++ b/bin/configs/spring-boot-implicitHeaders-oas3.yaml @@ -4,6 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 + documentationProvider: springdoc oas3: "true" artifactId: springboot-implicitHeaders hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-implicitHeaders.yaml b/bin/configs/spring-boot-implicitHeaders.yaml index cb84abe664da..5457e89b8315 100644 --- a/bin/configs/spring-boot-implicitHeaders.yaml +++ b/bin/configs/spring-boot-implicitHeaders.yaml @@ -4,5 +4,6 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: artifactId: springboot-implicitHeaders + documentationProvider: springfox hideGenerationTimestamp: "true" implicitHeaders: true diff --git a/bin/configs/spring-boot-oas3.yaml b/bin/configs/spring-boot-oas3.yaml index 9a0f864b2713..21994a14ad48 100644 --- a/bin/configs/spring-boot-oas3.yaml +++ b/bin/configs/spring-boot-oas3.yaml @@ -4,7 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 + documentationProvider: springdoc artifactId: springboot snapshotVersion: "true" - oas3: "true" hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-reactive-oas3.yaml b/bin/configs/spring-boot-reactive-oas3.yaml index b3fc8278491a..3e3fb91657bc 100644 --- a/bin/configs/spring-boot-reactive-oas3.yaml +++ b/bin/configs/spring-boot-reactive-oas3.yaml @@ -4,7 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 - oas3: "true" + documentationProvider: springdoc artifactId: springboot-reactive reactive: "true" hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-reactive.yaml b/bin/configs/spring-boot-reactive.yaml index 3d0c92edbeea..b3edff7de11c 100644 --- a/bin/configs/spring-boot-reactive.yaml +++ b/bin/configs/spring-boot-reactive.yaml @@ -4,6 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: artifactId: springboot-reactive + documentationProvider: springfox reactive: "true" hideGenerationTimestamp: "true" delegatePattern: "true" diff --git a/bin/configs/spring-boot-springdoc.yaml b/bin/configs/spring-boot-springdoc.yaml new file mode 100644 index 000000000000..47b1c195c36f --- /dev/null +++ b/bin/configs/spring-boot-springdoc.yaml @@ -0,0 +1,10 @@ +generatorName: spring +outputDir: samples/openapi3/server/petstore/spring-boot-springdoc +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaSpring +additionalProperties: + groupId: org.openapitools.openapi3 + documentationProvider: springdoc + artifactId: spring-boot-springdoc + snapshotVersion: "true" + hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-useoptional-oas3.yaml b/bin/configs/spring-boot-useoptional-oas3.yaml index 6fd5755ca31c..ac66d1df1480 100644 --- a/bin/configs/spring-boot-useoptional-oas3.yaml +++ b/bin/configs/spring-boot-useoptional-oas3.yaml @@ -4,7 +4,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 - oas3: "true" + documentationProvider: springdoc useOptional: true artifactId: spring-boot-useoptional hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-useoptional.yaml b/bin/configs/spring-boot-useoptional.yaml index 93a7924dcba5..1e028977898c 100644 --- a/bin/configs/spring-boot-useoptional.yaml +++ b/bin/configs/spring-boot-useoptional.yaml @@ -3,6 +3,7 @@ outputDir: samples/server/petstore/springboot-useoptional 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: + documentationProvider: springfox useOptional: true artifactId: spring-boot-useoptional hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-boot-virtualan.yaml b/bin/configs/spring-boot-virtualan.yaml index 3d580d05c8a2..c67ecf980ed6 100644 --- a/bin/configs/spring-boot-virtualan.yaml +++ b/bin/configs/spring-boot-virtualan.yaml @@ -4,6 +4,7 @@ library: spring-boot 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: + documentationProvider: springfox apiPackage: org.openapitools.virtualan.api modelPackage: org.openapitools.virtualan.model virtualService: true diff --git a/bin/configs/spring-boot.yaml b/bin/configs/spring-boot.yaml index f752bc817e4f..fe2345e7126c 100644 --- a/bin/configs/spring-boot.yaml +++ b/bin/configs/spring-boot.yaml @@ -3,6 +3,7 @@ outputDir: samples/server/petstore/springboot 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: + documentationProvider: springfox artifactId: springboot snapshotVersion: "true" hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-cloud-async-oas3.yaml b/bin/configs/spring-cloud-async-oas3.yaml index 637e9b4d1626..59c9d22e695e 100644 --- a/bin/configs/spring-cloud-async-oas3.yaml +++ b/bin/configs/spring-cloud-async-oas3.yaml @@ -5,7 +5,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 - oas3: "true" + documentationProvider: springdoc async: "true" java8: "true" artifactId: petstore-spring-cloud diff --git a/bin/configs/spring-cloud-async.yaml b/bin/configs/spring-cloud-async.yaml index 7f087b9e0bc9..b14f654366f6 100644 --- a/bin/configs/spring-cloud-async.yaml +++ b/bin/configs/spring-cloud-async.yaml @@ -4,6 +4,7 @@ library: spring-cloud inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox async: "true" java8: "true" artifactId: petstore-spring-cloud diff --git a/bin/configs/spring-cloud-date-time-oas3.yaml b/bin/configs/spring-cloud-date-time-oas3.yaml index 27cd8723133e..9e5724d2ac9d 100644 --- a/bin/configs/spring-cloud-date-time-oas3.yaml +++ b/bin/configs/spring-cloud-date-time-oas3.yaml @@ -5,8 +5,8 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/date-time-par templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 + documentationProvider: springdoc artifactId: spring-cloud-date-time-oas3 interfaceOnly: "true" singleContentTypes: "true" - hideGenerationTimestamp: "true" - oas3: "true" \ No newline at end of file + hideGenerationTimestamp: "true" \ No newline at end of file diff --git a/bin/configs/spring-cloud-date-time.yaml b/bin/configs/spring-cloud-date-time.yaml index 16686c8b9ac7..ff06030aab30 100644 --- a/bin/configs/spring-cloud-date-time.yaml +++ b/bin/configs/spring-cloud-date-time.yaml @@ -4,6 +4,7 @@ outputDir: samples/client/petstore/spring-cloud-date-time inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/date-time-parameter-types-for-testing.yml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox artifactId: spring-cloud-date-time interfaceOnly: "true" singleContentTypes: "true" diff --git a/bin/configs/spring-cloud-oas3-fakeapi.yaml b/bin/configs/spring-cloud-oas3-fakeapi.yaml index f12e8b601991..3f4e3c8ba3a3 100644 --- a/bin/configs/spring-cloud-oas3-fakeapi.yaml +++ b/bin/configs/spring-cloud-oas3-fakeapi.yaml @@ -5,8 +5,8 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 + documentationProvider: springdoc artifactId: spring-cloud-oas3 interfaceOnly: "true" singleContentTypes: "true" hideGenerationTimestamp: "true" - oas3: "true" diff --git a/bin/configs/spring-cloud-oas3.yaml b/bin/configs/spring-cloud-oas3.yaml index 3d627dcca254..c43b53303af2 100644 --- a/bin/configs/spring-cloud-oas3.yaml +++ b/bin/configs/spring-cloud-oas3.yaml @@ -5,8 +5,8 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 + documentationProvider: springdoc artifactId: spring-cloud-oas3 interfaceOnly: "true" singleContentTypes: "true" hideGenerationTimestamp: "true" - oas3: "true" diff --git a/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml b/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml index 64f048226e83..02c96627b645 100644 --- a/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml +++ b/bin/configs/spring-cloud-petstore-feign-spring-pageable-oas3.yaml @@ -5,6 +5,6 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-spring templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 - oas3: "true" + documentationProvider: springdoc artifactId: spring-cloud-spring-pageable hideGenerationTimestamp: 'true' diff --git a/bin/configs/spring-cloud-petstore-feign-spring-pageable.yaml b/bin/configs/spring-cloud-petstore-feign-spring-pageable.yaml index 366a1978822d..506a1c53be6b 100644 --- a/bin/configs/spring-cloud-petstore-feign-spring-pageable.yaml +++ b/bin/configs/spring-cloud-petstore-feign-spring-pageable.yaml @@ -4,5 +4,6 @@ library: spring-cloud inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox artifactId: spring-cloud-spring-pageable hideGenerationTimestamp: 'true' diff --git a/bin/configs/spring-cloud.yaml b/bin/configs/spring-cloud.yaml index df13fabbf035..cd207cd64cd6 100644 --- a/bin/configs/spring-cloud.yaml +++ b/bin/configs/spring-cloud.yaml @@ -4,5 +4,6 @@ library: spring-cloud inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox artifactId: petstore-spring-cloud hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-mvc-default-values.yaml b/bin/configs/spring-mvc-default-values.yaml index b1ae7fbd0484..e25aa41b503d 100644 --- a/bin/configs/spring-mvc-default-values.yaml +++ b/bin/configs/spring-mvc-default-values.yaml @@ -3,5 +3,6 @@ outputDir: samples/server/petstore/spring-mvc-default-value inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_8535.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox hideGenerationTimestamp: "true" artifactId: spring-mvc-default-value \ No newline at end of file diff --git a/bin/configs/spring-mvc-j8-async.yaml b/bin/configs/spring-mvc-j8-async.yaml index cd03b0e427dc..287d05993ee4 100644 --- a/bin/configs/spring-mvc-j8-async.yaml +++ b/bin/configs/spring-mvc-j8-async.yaml @@ -4,6 +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: + documentationProvider: springfox async: "true" java8: true artifactId: spring-mvc-server-j8-async diff --git a/bin/configs/spring-mvc-j8-localdatetime.yaml b/bin/configs/spring-mvc-j8-localdatetime.yaml index f8d6126c9f3c..c1e66bf80a63 100644 --- a/bin/configs/spring-mvc-j8-localdatetime.yaml +++ b/bin/configs/spring-mvc-j8-localdatetime.yaml @@ -4,6 +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: + documentationProvider: springfox booleanGetterPrefix: get artifactId: spring-mvc-j8-localdatetime hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-mvc-no-nullable.yaml b/bin/configs/spring-mvc-no-nullable.yaml index f1d6585071c5..76cefce348f2 100644 --- a/bin/configs/spring-mvc-no-nullable.yaml +++ b/bin/configs/spring-mvc-no-nullable.yaml @@ -4,6 +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: + documentationProvider: springfox artifactId: spring-mvc-server-no-nullable openApiNullable: "false" serverPort: "8002" diff --git a/bin/configs/spring-mvc-petstore-server-spring-pageable.yaml b/bin/configs/spring-mvc-petstore-server-spring-pageable.yaml index bcb362e65db9..027a98cbff47 100644 --- a/bin/configs/spring-mvc-petstore-server-spring-pageable.yaml +++ b/bin/configs/spring-mvc-petstore-server-spring-pageable.yaml @@ -4,5 +4,6 @@ library: spring-mvc inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox artifactId: spring-mvc-spring-pageable hideGenerationTimestamp: 'true' diff --git a/bin/configs/spring-mvc.yaml b/bin/configs/spring-mvc.yaml index 8eca9e650a2b..9093bb518c8f 100644 --- a/bin/configs/spring-mvc.yaml +++ b/bin/configs/spring-mvc.yaml @@ -4,6 +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: + documentationProvider: springfox java8: true booleanGetterPrefix: get artifactId: spring-mvc-server diff --git a/bin/configs/spring-stubs-oas3.yaml b/bin/configs/spring-stubs-oas3.yaml index 1c725e53b33d..d5149f28adca 100644 --- a/bin/configs/spring-stubs-oas3.yaml +++ b/bin/configs/spring-stubs-oas3.yaml @@ -4,8 +4,8 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: groupId: org.openapitools.openapi3 + documentationProvider: springdoc artifactId: spring-stubs - oas3: "true" interfaceOnly: "true" singleContentTypes: "true" hideGenerationTimestamp: "true" diff --git a/bin/configs/spring-stubs.yaml b/bin/configs/spring-stubs.yaml index 8c58e6838ea6..bdbefb1e58f5 100644 --- a/bin/configs/spring-stubs.yaml +++ b/bin/configs/spring-stubs.yaml @@ -3,6 +3,7 @@ outputDir: samples/client/petstore/spring-stubs inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox artifactId: spring-stubs interfaceOnly: "true" singleContentTypes: "true" diff --git a/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern-without-j8.yaml b/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern-without-j8.yaml index 7e0c9882db50..7d16b4a1e762 100644 --- a/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern-without-j8.yaml +++ b/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern-without-j8.yaml @@ -6,5 +6,6 @@ templateDir: modules/openapi-generator/src/main/resources/JavaSpring delegatePattern: true java8: false additionalProperties: + documentationProvider: springfox artifactId: springboot-spring-pageable-delegatePattern-without-j8 hideGenerationTimestamp: 'true' diff --git a/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern.yaml b/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern.yaml index 9c96151f04fc..c4d1eb5b6874 100644 --- a/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern.yaml +++ b/bin/configs/springboot-petstore-server-spring-pageable-delegatePattern.yaml @@ -5,5 +5,6 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring delegatePattern: true additionalProperties: + documentationProvider: springfox artifactId: springboot-spring-pageable-delegatePattern hideGenerationTimestamp: 'true' diff --git a/bin/configs/springboot-petstore-server-spring-pageable-without-j8.yaml b/bin/configs/springboot-petstore-server-spring-pageable-without-j8.yaml index c87a6776a5f4..87c63968490e 100644 --- a/bin/configs/springboot-petstore-server-spring-pageable-without-j8.yaml +++ b/bin/configs/springboot-petstore-server-spring-pageable-without-j8.yaml @@ -5,5 +5,6 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e templateDir: modules/openapi-generator/src/main/resources/JavaSpring java8: false additionalProperties: + documentationProvider: springfox artifactId: springboot-spring-pageable-withoutj8 hideGenerationTimestamp: 'true' diff --git a/bin/configs/springboot-petstore-server-spring-pageable.yaml b/bin/configs/springboot-petstore-server-spring-pageable.yaml index ddeaaa6cb728..db518c226044 100644 --- a/bin/configs/springboot-petstore-server-spring-pageable.yaml +++ b/bin/configs/springboot-petstore-server-spring-pageable.yaml @@ -4,5 +4,6 @@ library: spring-boot inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml templateDir: modules/openapi-generator/src/main/resources/JavaSpring additionalProperties: + documentationProvider: springfox artifactId: springboot-spring-pageable hideGenerationTimestamp: 'true' diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md index a55d98db57a4..c0ebb548e2e8 100644 --- a/docs/generators/java-camel.md +++ b/docs/generators/java-camel.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|annotationLibrary|Select the complementary documentation annotation library.|
**none**
Do not annotate Model and Api with complementary annotations.
**swagger1**
Annotate Model and Api using the Swagger Annotations 1.x library.
**swagger2**
Annotate Model and Api using the Swagger Annotations 2.x library.
|swagger2| |apiFirst|Generate the API from the OAI spec at server compile time (API first approach)| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| @@ -47,6 +48,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| +|documentationProvider|Select the OpenAPI documentation provider.|
**none**
Do not publish an OpenAPI specification.
**source**
Publish the original input OpenAPI specification.
**springfox**
Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x.
**springdoc**
Generate an OpenAPI 3 specification using SpringDoc.
|springdoc| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false| @@ -63,7 +65,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |licenseName|The name of the license| |Unlicense| |licenseUrl|The URL of the license| |http://unlicense.org| |modelPackage|package for generated models| |org.openapitools.model| -|oas3|Use OAS 3 Swagger annotations instead of OAS 2 annotations| |false| |openApiNullable|Enable OpenAPI Jackson Nullable library| |true| |parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null| |parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null| diff --git a/docs/generators/spring.md b/docs/generators/spring.md index 94e1639fa0e2..c06ac0fa7072 100644 --- a/docs/generators/spring.md +++ b/docs/generators/spring.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|annotationLibrary|Select the complementary documentation annotation library.|
**none**
Do not annotate Model and Api with complementary annotations.
**swagger1**
Annotate Model and Api using the Swagger Annotations 1.x library.
**swagger2**
Annotate Model and Api using the Swagger Annotations 2.x library.
|swagger2| |apiFirst|Generate the API from the OAI spec at server compile time (API first approach)| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| @@ -40,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| +|documentationProvider|Select the OpenAPI documentation provider.|
**none**
Do not publish an OpenAPI specification.
**source**
Publish the original input OpenAPI specification.
**springfox**
Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x.
**springdoc**
Generate an OpenAPI 3 specification using SpringDoc.
|springdoc| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false| @@ -56,7 +58,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |licenseName|The name of the license| |Unlicense| |licenseUrl|The URL of the license| |http://unlicense.org| |modelPackage|package for generated models| |org.openapitools.model| -|oas3|Use OAS 3 Swagger annotations instead of OAS 2 annotations| |false| |openApiNullable|Enable OpenAPI Jackson Nullable library| |true| |parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null| |parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null| diff --git a/modules/openapi-generator-maven-plugin/examples/spring.xml b/modules/openapi-generator-maven-plugin/examples/spring.xml index e1802203383a..e5ea3463f94b 100644 --- a/modules/openapi-generator-maven-plugin/examples/spring.xml +++ b/modules/openapi-generator-maven-plugin/examples/spring.xml @@ -40,6 +40,7 @@ + springfox true true diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 603de4781b96..05cb3233ebf4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -32,6 +32,7 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; +import org.openapitools.codegen.languages.features.DocumentationProviderFeatures; import org.openapitools.codegen.meta.features.*; import org.openapitools.codegen.utils.ModelUtils; import org.slf4j.Logger; @@ -48,7 +49,8 @@ import java.util.stream.Stream; import static org.openapitools.codegen.utils.StringUtils.*; -public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig { +public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig, + DocumentationProviderFeatures { private final Logger LOGGER = LoggerFactory.getLogger(AbstractJavaCodegen.class); private static final String ARTIFACT_VERSION_DEFAULT_VALUE = "1.0.0"; @@ -111,6 +113,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code protected List additionalModelTypeAnnotations = new LinkedList<>(); protected List additionalEnumTypeAnnotations = new LinkedList<>(); protected boolean openApiNullable = true; + protected DocumentationProvider documentationProvider; + protected AnnotationLibrary annotationLibrary; public AbstractJavaCodegen() { super(); @@ -259,12 +263,68 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code snapShotVersion.setEnum(snapShotVersionOptions); cliOptions.add(snapShotVersion); + if (null != defaultDocumentationProvider()) { + CliOption documentationProviderCliOption = new CliOption(DOCUMENTATION_PROVIDER, + "Select the OpenAPI documentation provider.") + .defaultValue(defaultDocumentationProvider().toCliOptValue()); + supportedDocumentationProvider().forEach(dp -> + documentationProviderCliOption.addEnum(dp.toCliOptValue(), dp.getDescription())); + cliOptions.add(documentationProviderCliOption); + + CliOption annotationLibraryCliOption = new CliOption(ANNOTATION_LIBRARY, + "Select the complementary documentation annotation library.") + .defaultValue(defaultDocumentationProvider().getPreferredAnnotationLibrary().toCliOptValue()); + supportedAnnotationLibraries().forEach(al -> + annotationLibraryCliOption.addEnum(al.toCliOptValue(), al.getDescription())); + cliOptions.add(annotationLibraryCliOption); + } } @Override public void processOpts() { super.processOpts(); + if (null != defaultDocumentationProvider()) { + documentationProvider = DocumentationProvider.ofCliOption( + (String)additionalProperties.getOrDefault(DOCUMENTATION_PROVIDER, + defaultDocumentationProvider().toCliOptValue()) + ); + + if (! supportedDocumentationProvider().contains(documentationProvider)) { + String msg = String.format(Locale.ROOT, + "The [%s] Documentation Provider is not supported by this generator", + documentationProvider.toCliOptValue()); + throw new IllegalArgumentException(msg); + } + + annotationLibrary = AnnotationLibrary.ofCliOption( + (String) additionalProperties.getOrDefault(ANNOTATION_LIBRARY, + documentationProvider.getPreferredAnnotationLibrary().toCliOptValue()) + ); + + if (! supportedAnnotationLibraries().contains(annotationLibrary)) { + String msg = String.format(Locale.ROOT, "The Annotation Library [%s] is not supported by this generator", + annotationLibrary.toCliOptValue()); + throw new IllegalArgumentException(msg); + } + + if (! documentationProvider.supportedAnnotationLibraries().contains(annotationLibrary)) { + String msg = String.format(Locale.ROOT, + "The [%s] documentation provider does not support [%s] as complementary annotation library", + documentationProvider.toCliOptValue(), annotationLibrary.toCliOptValue()); + throw new IllegalArgumentException(msg); + } + + additionalProperties.put(DOCUMENTATION_PROVIDER, documentationProvider.toCliOptValue()); + additionalProperties.put(documentationProvider.getPropertyName(), true); + additionalProperties.put(ANNOTATION_LIBRARY, annotationLibrary.toCliOptValue()); + additionalProperties.put(annotationLibrary.getPropertyName(), true); + } else { + additionalProperties.put(DOCUMENTATION_PROVIDER, DocumentationProvider.NONE); + additionalProperties.put(ANNOTATION_LIBRARY, AnnotationLibrary.NONE); + } + + if (StringUtils.isEmpty(System.getenv("JAVA_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)"); LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); @@ -1753,6 +1813,26 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code this.openApiNullable = openApiNullable; } + @Override + public DocumentationProvider getDocumentationProvider() { + return documentationProvider; + } + + @Override + public void setDocumentationProvider(DocumentationProvider documentationProvider) { + this.documentationProvider = documentationProvider; + } + + @Override + public AnnotationLibrary getAnnotationLibrary() { + return annotationLibrary; + } + + @Override + public void setAnnotationLibrary(AnnotationLibrary annotationLibrary) { + this.annotationLibrary = annotationLibrary; + } + @Override public String escapeQuotationMark(String input) { // remove " to avoid code injection @@ -1933,4 +2013,5 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code addImport(codegenModel, codegenModel.additionalPropertiesType); } } + } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index c6eeb212bee0..ec8853e4a969 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -89,7 +89,6 @@ public class SpringCodegen extends AbstractJavaCodegen public static final String IMPLICIT_HEADERS = "implicitHeaders"; public static final String OPENAPI_DOCKET_CONFIG = "swaggerDocketConfig"; public static final String API_FIRST = "apiFirst"; - public static final String OAS3 = "oas3"; public static final String SPRING_CONTROLLER = "useSpringController"; public static final String HATEOAS = "hateoas"; public static final String RETURN_SUCCESS_CODE = "returnSuccessCode"; @@ -122,7 +121,6 @@ public class SpringCodegen extends AbstractJavaCodegen protected boolean returnSuccessCode = false; protected boolean unhandledException = false; protected boolean useSpringController = false; - protected boolean oas3 = false; public SpringCodegen() { super(); @@ -198,7 +196,6 @@ public class SpringCodegen extends AbstractJavaCodegen CliOption.newBoolean(HATEOAS, "Use Spring HATEOAS library to allow adding HATEOAS links", hateoas)); cliOptions .add(CliOption.newBoolean(RETURN_SUCCESS_CODE, "Generated server returns 2xx code", returnSuccessCode)); - cliOptions.add(CliOption.newBoolean(OAS3, "Use OAS 3 Swagger annotations instead of OAS 2 annotations", oas3)); cliOptions.add(CliOption.newBoolean(SPRING_CONTROLLER, "Annotate the generated API as a Spring Controller", useSpringController)); cliOptions.add(CliOption.newBoolean(UNHANDLED_EXCEPTION_HANDLING, "Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).", @@ -239,6 +236,29 @@ public class SpringCodegen extends AbstractJavaCodegen return "Generates a Java SpringBoot Server application using the SpringFox integration."; } + @Override + public DocumentationProvider defaultDocumentationProvider() { + return DocumentationProvider.SPRINGDOC; + } + + public List supportedDocumentationProvider() { + List supportedProviders = new ArrayList<>(); + supportedProviders.add(DocumentationProvider.NONE); + supportedProviders.add(DocumentationProvider.SOURCE); + supportedProviders.add(DocumentationProvider.SPRINGFOX); + supportedProviders.add(DocumentationProvider.SPRINGDOC); + return supportedProviders; + } + + @Override + public List supportedAnnotationLibraries() { + List supportedLibraries = new ArrayList<>(); + supportedLibraries.add(AnnotationLibrary.NONE); + supportedLibraries.add(AnnotationLibrary.SWAGGER1); + supportedLibraries.add(AnnotationLibrary.SWAGGER2); + return supportedLibraries; + } + @Override public void processOpts() { final List> configOptions = additionalProperties.entrySet().stream() @@ -374,11 +394,6 @@ public class SpringCodegen extends AbstractJavaCodegen } writePropertyBack(SPRING_CONTROLLER, useSpringController); - if (additionalProperties.containsKey(OAS3)) { - this.setOas3(convertPropertyToBoolean(OAS3)); - } - writePropertyBack(OAS3, oas3); - if (additionalProperties.containsKey(RETURN_SUCCESS_CODE)) { this.setReturnSuccessCode(Boolean.parseBoolean(additionalProperties.get(RETURN_SUCCESS_CODE).toString())); } @@ -394,6 +409,7 @@ public class SpringCodegen extends AbstractJavaCodegen importMapping.put("Pageable", "org.springframework.data.domain.Pageable"); importMapping.put("DateTimeFormat", "org.springframework.format.annotation.DateTimeFormat"); importMapping.put("ApiIgnore", "springfox.documentation.annotations.ApiIgnore"); + importMapping.put("ParameterObject", "org.springdoc.api.annotations.ParameterObject"); if (useOptional) { writePropertyBack(USE_OPTIONAL, useOptional); @@ -518,15 +534,6 @@ public class SpringCodegen extends AbstractJavaCodegen additionalProperties.put(RESPONSE_WRAPPER, "Callable"); } - // Springfox cannot be used with oas3 or apiFirst or reactive. So, write the property back after determining - // whether it should be enabled or not. - boolean useSpringFox = false; - if (!apiFirst && !reactive && !oas3) { - useSpringFox = true; - additionalProperties.put("useSpringfox", true); - } - writePropertyBack("useSpringfox", useSpringFox); - // Some well-known Spring or Spring-Cloud response wrappers if (isNotEmpty(responseWrapper)) { additionalProperties.put("jdk8", false); @@ -885,10 +892,6 @@ public class SpringCodegen extends AbstractJavaCodegen this.useSpringController = useSpringController; } - public void setOas3(boolean oas3) { - this.oas3 = oas3; - } - public void setReturnSuccessCode(boolean returnSuccessCode) { this.returnSuccessCode = returnSuccessCode; } @@ -937,8 +940,8 @@ public class SpringCodegen extends AbstractJavaCodegen @Override public CodegenModel fromModel(String name, Schema model) { CodegenModel codegenModel = super.fromModel(name, model); - if (oas3) { - // remove swagger2 imports + if (getAnnotationLibrary() != AnnotationLibrary.SWAGGER1) { + // remove swagger imports codegenModel.imports.remove("ApiModelProperty"); codegenModel.imports.remove("ApiModel"); } @@ -961,7 +964,16 @@ public class SpringCodegen extends AbstractJavaCodegen // add org.springframework.data.domain.Pageable import when needed if (codegenOperation.vendorExtensions.containsKey("x-spring-paginated")) { codegenOperation.imports.add("Pageable"); - if (Boolean.TRUE.equals(additionalProperties.get("useSpringfox"))) { + if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) { + codegenOperation.imports.add("ApiIgnore"); + } + if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())) { + codegenOperation.imports.add("ParameterObject"); + } + } + + if (reactive) { + if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) { codegenOperation.imports.add("ApiIgnore"); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/features/DocumentationProviderFeatures.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/features/DocumentationProviderFeatures.java new file mode 100644 index 000000000000..b658ea0e4d9e --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/features/DocumentationProviderFeatures.java @@ -0,0 +1,173 @@ +package org.openapitools.codegen.languages.features; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Objects; + +/** + * The DocumentationProvider Features support to additional properties to select the + * documentation provider and the annotation library to use during code generation. + * + * @author cachescrubber, 2022-01-08 + * @since 5.4.0 + */ +public interface DocumentationProviderFeatures { + + String DOCUMENTATION_PROVIDER = "documentationProvider"; + + String ANNOTATION_LIBRARY = "annotationLibrary"; + + /** + * Define the default documentation Provider for CliOpts processing. + * A NULL return value will disable the documentation provider support. + * Override in subclasses to customize. + * @return the default documentation provider + */ + default DocumentationProvider defaultDocumentationProvider() { + return null; + } + + /** + * Define the List of supported documentation Provider for CliOpts processing. + * Override in subclasses to customize. + * @return the list of supported documentation provider + */ + default List supportedDocumentationProvider() { + List supportedProviders = new ArrayList<>(); + supportedProviders.add(DocumentationProvider.NONE); + return supportedProviders; + } + + /** + * Define the list of supported annotation libraries for CliOpts processing. + * Override in subclasses to customize. + * @return the list of supported annotation libraries + */ + default List supportedAnnotationLibraries() { + List supportedLibraries = new ArrayList<>(); + supportedLibraries.add(AnnotationLibrary.NONE); + return supportedLibraries; + } + + DocumentationProvider getDocumentationProvider(); + + void setDocumentationProvider(DocumentationProvider documentationProvider); + + AnnotationLibrary getAnnotationLibrary(); + + void setAnnotationLibrary(AnnotationLibrary annotationLibrary); + + enum DocumentationProvider { + NONE("withoutDocumentationProvider", "Do not publish an OpenAPI specification.", + AnnotationLibrary.NONE, AnnotationLibrary.values()), + + SOURCE("sourceDocumentationProvider", "Publish the original input OpenAPI specification.", + AnnotationLibrary.NONE, AnnotationLibrary.values()), + + SWAGGER1("swagger1DocumentationProvider", "Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using Swagger-Core 1.x.", + AnnotationLibrary.SWAGGER1, AnnotationLibrary.SWAGGER1), + + SWAGGER2("swagger2DocumentationProvider", "Generate an OpenAPI 3 specification using Swagger-Core 2.x.", + AnnotationLibrary.SWAGGER2, AnnotationLibrary.SWAGGER2), + + SPRINGFOX("springFoxDocumentationProvider", "Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x.", + AnnotationLibrary.SWAGGER1, AnnotationLibrary.SWAGGER1), + + SPRINGDOC("springDocDocumentationProvider", "Generate an OpenAPI 3 specification using SpringDoc.", + AnnotationLibrary.SWAGGER2, AnnotationLibrary.SWAGGER2); + + private final String propertyName; + + private final String description; + + private final AnnotationLibrary preferredAnnotationLibrary; + + private final AnnotationLibrary[] supportedAnnotationLibraries; + + DocumentationProvider(String propertyName, String description, + AnnotationLibrary preferredAnnotationLibrary, + AnnotationLibrary... supportedAnnotationLibraries) { + this.propertyName = propertyName; + this.description = description; + this.preferredAnnotationLibrary = preferredAnnotationLibrary; + this.supportedAnnotationLibraries = supportedAnnotationLibraries; + } + + public static DocumentationProvider ofCliOption(String optVal) { + optVal = Objects.requireNonNull(optVal).toUpperCase(Locale.ROOT); + return valueOf(optVal); + } + + /** + * The property name should be used in the codegen model as a boolean property. + * + * @return the property name for this documentation provider + */ + public String getPropertyName() { + return propertyName; + } + + public String getDescription() { + return description; + } + + public AnnotationLibrary getPreferredAnnotationLibrary() { + return preferredAnnotationLibrary; + } + + public AnnotationLibrary[] getSupportedAnnotationLibraries() { + return supportedAnnotationLibraries; + } + + public List supportedAnnotationLibraries() { + return Arrays.asList(getSupportedAnnotationLibraries()); + } + + public String toCliOptValue() { + return name().toLowerCase(Locale.ROOT); + } + } + + enum AnnotationLibrary { + NONE("withoutAnnotationLibrary", "Do not annotate Model and Api with complementary annotations."), + + SWAGGER1("swagger1AnnotationLibrary", "Annotate Model and Api using the Swagger Annotations 1.x library."), + + SWAGGER2("swagger2AnnotationLibrary", "Annotate Model and Api using the Swagger Annotations 2.x library."), + + MICROPROFILE("microprofileAnnotationLibrary", "Annotate Model and Api using the Microprofile annotations."); + + private final String propertyName; + + private final String description; + + public static AnnotationLibrary ofCliOption(String optVal) { + optVal = Objects.requireNonNull(optVal).toUpperCase(Locale.ROOT); + return valueOf(optVal); + } + + /** + * The property name is used in the codegen model as a boolean property. + * + * @return the property name for this annotation library + */ + public String getPropertyName() { + return propertyName; + } + + public String getDescription() { + return description; + } + + AnnotationLibrary(String propertyName, String description) { + this.propertyName = propertyName; + this.description = description; + } + + public String toCliOptValue() { + return name().toLowerCase(Locale.ROOT); + } + } +} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache index 1cba2038d870..6aa973a6a65a 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/allowableValues.mustache @@ -1 +1 @@ -{{#allowableValues}}allowableValues ={{#oas3}} { {{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}} }{{/oas3}}{{^oas3}} "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/oas3}}{{/allowableValues}} \ No newline at end of file +{{#allowableValues}}allowableValues ={{#swagger2AnnotationLibrary}} { {{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}} }{{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}} "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/swagger1AnnotationLibrary}}{{/allowableValues}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache index affa1fb385be..da913ae679a0 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/api.mustache @@ -7,7 +7,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -{{#oas3}} +{{#swagger2AnnotationLibrary}} import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -16,10 +16,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -{{/oas3}} -{{^oas3}} +{{/swagger2AnnotationLibrary}} +{{#swagger1AnnotationLibrary}} import io.swagger.annotations.*; -{{/oas3}} +{{/swagger1AnnotationLibrary}} {{#jdk8-no-delegate}} {{#virtualService}} import io.virtualan.annotation.ApiVirtual; @@ -75,12 +75,12 @@ import javax.annotation.Generated; {{#useSpringController}} @Controller {{/useSpringController}} -{{#oas3}} +{{#swagger2AnnotationLibrary}} @Tag(name = "{{{baseName}}}", description = "the {{{baseName}}} API") -{{/oas3}} -{{^oas3}} +{{/swagger2AnnotationLibrary}} +{{#swagger1AnnotationLibrary}} @Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") -{{/oas3}} +{{/swagger1AnnotationLibrary}} {{#operations}} {{#virtualService}} @VirtualService @@ -126,7 +126,7 @@ public interface {{classname}} { {{#virtualService}} @ApiVirtual {{/virtualService}} - {{#oas3}} + {{#swagger2AnnotationLibrary}} @Operation( operationId = "{{{operationId}}}", {{#summary}} @@ -146,8 +146,8 @@ public interface {{classname}} { {{/authMethods}} }{{/hasAuthMethods}} ) - {{/oas3}} - {{^oas3}} + {{/swagger2AnnotationLibrary}} + {{#swagger1AnnotationLibrary}} @ApiOperation( tags = { {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} }, value = "{{{summary}}}", @@ -174,20 +174,20 @@ public interface {{classname}} { @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}} {{/responses}} }) - {{/oas3}} + {{/swagger1AnnotationLibrary}} {{#implicitHeaders}} - {{#oas3}} + {{#swagger2AnnotationLibrary}} @Parameters({ {{#headerParams}} {{>paramDoc}}{{^-last}},{{/-last}} {{/headerParams}} - {{/oas3}} - {{^oas3}} + {{/swagger2AnnotationLibrary}} + {{#swagger1AnnotationLibrary}} @ApiImplicitParams({ {{#headerParams}} {{>implicitHeader}}{{^-last}},{{/-last}} {{/headerParams}} - {{/oas3}} + {{/swagger1AnnotationLibrary}} }) {{/implicitHeaders}} @RequestMapping( @@ -201,15 +201,15 @@ public interface {{classname}} { {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}( {{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, - {{/hasParams}}{{#oas3}}@Parameter(hidden = true){{/oas3}}{{#useSpringfox}}@ApiIgnore{{/useSpringfox}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}}, - {{/hasParams}}{{#useSpringfox}}@ApiIgnore {{/useSpringfox}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}} + {{/hasParams}}{{#swagger2AnnotationLibrary}}@Parameter(hidden = true){{/swagger2AnnotationLibrary}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}}, + {{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore {{/springFoxDocumentationProvider}}{{#springDocDocumentationProvider}}@ParameterObject {{/springDocDocumentationProvider}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}} ){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { {{#delegate-method}} return {{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); } // Override this method - {{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#useSpringfox}}@ApiIgnore{{/useSpringfox}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#useSpringfox}}@ApiIgnore{{/useSpringfox}} final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { + {{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, {{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { {{/delegate-method}} {{^isDelegate}} {{>methodBody}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache index ca8076c56a47..374fe9eaa8c9 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache @@ -3,7 +3,7 @@ package {{package}}; {{^jdk8}} {{#imports}}import {{import}}; {{/imports}} -{{#oas3}} +{{#swagger2AnnotationLibrary}} import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; @@ -11,10 +11,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -{{/oas3}} -{{^oas3}} +{{/swagger2AnnotationLibrary}} +{{^swagger1AnnotationLibrary}} import io.swagger.annotations.*; -{{/oas3}} +{{/swagger1AnnotationLibrary}} import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -132,7 +132,7 @@ public class {{classname}}Controller implements {{classname}} { public {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}( {{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}}, {{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}}, - {{/hasParams}}{{#useSpringfox}}@ApiIgnore {{/useSpringfox}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}} + {{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore {{/springFoxDocumentationProvider}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}} ) { {{^isDelegate}} {{^async}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/homeController.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/homeController.mustache index f909a15b37df..189eccefbc83 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/homeController.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/homeController.mustache @@ -1,35 +1,36 @@ package {{configPackage}}; -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} import org.springframework.stereotype.Controller; -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} import org.springframework.util.StreamUtils; import org.springframework.web.bind.annotation.GetMapping; -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} import org.springframework.web.bind.annotation.RequestMapping; -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} import org.springframework.web.bind.annotation.ResponseBody; -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} {{#reactive}} +import org.springframework.context.annotation.Bean; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.ServerResponse; {{/reactive}} -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} import java.io.IOException; import java.io.InputStream; -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} {{#reactive}} import java.net.URI; {{/reactive}} -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} import java.nio.charset.Charset; -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} {{#reactive}} import static org.springframework.web.reactive.function.server.RequestPredicates.GET; @@ -42,7 +43,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r @Controller public class HomeController { -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} private static YAMLMapper yamlMapper = new YAMLMapper(); @Value("classpath:/openapi.yaml") @@ -67,20 +68,20 @@ public class HomeController { return yamlMapper.readValue(openapiContent(), Object.class); } -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} {{#reactive}} @Bean RouterFunction index() { return route( GET("/"), - req -> ServerResponse.temporaryRedirect(URI.create("{{#useSpringfox}}swagger-ui.html{{/useSpringfox}}{{^useSpringfox}}swagger-ui/index.html?url=../openapi.json{{/useSpringfox}}")).build() + req -> ServerResponse.temporaryRedirect(URI.create("{{#springFoxDocumentationProvider}}swagger-ui.html{{/springFoxDocumentationProvider}}{{^springFoxDocumentationProvider}}swagger-ui/index.html?url=../openapi.json{{/springFoxDocumentationProvider}}")).build() ); } {{/reactive}} {{^reactive}} @RequestMapping("/") public String index() { - return "redirect:{{#useSpringfox}}swagger-ui.html{{/useSpringfox}}{{^useSpringfox}}swagger-ui/index.html?url=../openapi.json{{/useSpringfox}}"; + return "redirect:{{#springFoxDocumentationProvider}}swagger-ui.html{{/springFoxDocumentationProvider}}{{^springFoxDocumentationProvider}}swagger-ui/index.html?url=../openapi.json{{/springFoxDocumentationProvider}}"; } {{/reactive}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/README.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/README.mustache index 196292339da4..b304cb8866d8 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/README.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/README.mustache @@ -8,10 +8,10 @@ This server was generated by the [OpenAPI Generator](https://openapi-generator.t By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. -{{#useSpringfox}} +{{#springFoxDocumentationProvider}} The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} Start your server as a simple java application {{^reactive}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/application.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/application.mustache index 6eb4ae242983..06f041051b96 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/application.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/application.mustache @@ -1,6 +1,6 @@ -{{#useSpringfox}} +{{#springFoxDocumentationProvider}} springfox.documentation.swagger.v2.path=/api-docs -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} server.port={{serverPort}} spring.jackson.date-format={{basePackage}}.RFC3339DateFormat spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/openapi2SpringBoot.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/openapi2SpringBoot.mustache index 8180f6c50a01..a171e3cff16b 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/openapi2SpringBoot.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/openapi2SpringBoot.mustache @@ -12,9 +12,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; {{^reactive}} import org.springframework.web.servlet.config.annotation.CorsRegistry; - {{^useSpringfox}} + {{^springFoxDocumentationProvider}} import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; - {{/useSpringfox}} + {{/springFoxDocumentationProvider}} import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; {{^java8}} import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -22,9 +22,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter {{/reactive}} {{#reactive}} import org.springframework.web.reactive.config.CorsRegistry; - {{^useSpringfox}} + {{^springFoxDocumentationProvider}} import org.springframework.web.reactive.config.ResourceHandlerRegistry; - {{/useSpringfox}} + {{/springFoxDocumentationProvider}} import org.springframework.web.reactive.config.WebFluxConfigurer; {{/reactive}} @@ -63,13 +63,13 @@ public class OpenAPI2SpringBoot implements CommandLineRunner { .allowedMethods("*") .allowedHeaders("Content-Type"); }*/ -{{^useSpringfox}} +{{^springFoxDocumentationProvider}} @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); } -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} }; } diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache index 05447fe9563d..c929876ffc44 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache @@ -9,12 +9,22 @@ {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} ${java.version} ${java.version} - {{#useSpringfox}} + {{#springFoxDocumentationProvider}} 2.9.2 - {{/useSpringfox}} - {{^useSpringfox}} - {{#oas3}}2.1.11{{/oas3}}{{^oas3}}1.6.3{{/oas3}} - {{/useSpringfox}} + {{/springFoxDocumentationProvider}} + {{#springDocDocumentationProvider}} + 1.6.4 + {{/springDocDocumentationProvider}} + {{^springFoxDocumentationProvider}} + {{^springDocDocumentationProvider}} + {{#swagger1AnnotationLibrary}} + 1.6.4 + {{/swagger1AnnotationLibrary}} + {{#swagger2AnnotationLibrary}} + }2.1.12 + {{/swagger2AnnotationLibrary}} + {{/springDocDocumentationProvider}} + {{/springFoxDocumentationProvider}} {{#parentOverridden}} @@ -27,7 +37,7 @@ org.springframework.boot spring-boot-starter-parent - 2.5.8 + {{#springFoxDocumentationProvider}}2.5.8{{/springFoxDocumentationProvider}}{{^springFoxDocumentationProvider}}2.6.2{{/springFoxDocumentationProvider}} {{/parentOverridden}} @@ -82,30 +92,40 @@ org.springframework.data spring-data-commons - {{#useSpringfox}} + {{#springDocDocumentationProvider}} + + + org.springdoc + springdoc-openapi-ui + ${springdoc.version} + + {{/springDocDocumentationProvider}} + {{#springFoxDocumentationProvider}} io.springfox springfox-swagger2 ${springfox.version} - {{/useSpringfox}} - {{^useSpringfox}} - {{#oas3}} - - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} - - {{/oas3}} - {{^oas3}} + {{/springFoxDocumentationProvider}} + {{^springFoxDocumentationProvider}} + {{^springDocDocumentationProvider}} + {{#swagger1AnnotationLibrary}} io.swagger swagger-annotations - ${swagger-core-version} + ${swagger-annotations.version} - {{/oas3}} - {{/useSpringfox}} + {{/swagger1AnnotationLibrary}} + {{#swagger2AnnotationLibrary}} + + io.swagger.core.v3 + swagger-annotations + ${swagger-annotations.version} + + {{/swagger2AnnotationLibrary}} + {{/springDocDocumentationProvider}} + {{/springFoxDocumentationProvider}} com.google.code.findbugs diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache index f9228dd345e2..64a0b7189bae 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache @@ -9,10 +9,22 @@ {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} ${java.version} ${java.version} - {{#oas3}}2.1.11{{/oas3}}{{^oas3}}1.6.3{{/oas3}} - {{#useSpringfox}} + {{#springFoxDocumentationProvider}} 2.9.2 - {{/useSpringfox}} + {{/springFoxDocumentationProvider}} + {{#springDocDocumentationProvider}} + 1.6.4 + {{/springDocDocumentationProvider}} + {{^springFoxDocumentationProvider}} + {{^springDocDocumentationProvider}} + {{#swagger1AnnotationLibrary}} + 1.6.4 + {{/swagger1AnnotationLibrary}} + {{#swagger2AnnotationLibrary}} + }2.1.12 + {{/swagger2AnnotationLibrary}} + {{/springDocDocumentationProvider}} + {{/springFoxDocumentationProvider}} {{#parentOverridden}} @@ -47,30 +59,40 @@ {{/parentOverridden}} - {{#useSpringfox}} + {{#springDocDocumentationProvider}} + + + org.springdoc + springdoc-openapi-ui + ${springdoc.version} + + {{/springDocDocumentationProvider}} + {{#springFoxDocumentationProvider}} io.springfox springfox-swagger2 ${springfox.version} - {{/useSpringfox}} - {{^useSpringfox}} - {{#oas3}} - - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} - - {{/oas3}} - {{^oas3}} + {{/springFoxDocumentationProvider}} + {{^springFoxDocumentationProvider}} + {{^springDocDocumentationProvider}} + {{#swagger1AnnotationLibrary}} io.swagger swagger-annotations - ${swagger-core-version} + ${swagger-annotations.version} - {{/oas3}} - {{/useSpringfox}} + {{/swagger1AnnotationLibrary}} + {{#swagger2AnnotationLibrary}} + + io.swagger.core.v3 + swagger-annotations + ${swagger-annotations.version} + + {{/swagger2AnnotationLibrary}} + {{/springDocDocumentationProvider}} + {{/springFoxDocumentationProvider}} com.google.code.findbugs diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/README.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/README.mustache index efc3e8921a6c..bdd21d95a70d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/README.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/README.mustache @@ -6,9 +6,9 @@ Spring MVC Server ## Overview This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the Spring MVC framework. -{{#useSpringfox}} +{{#springFoxDocumentationProvider}} The underlying library integrating OpenAPI to Spring-MVC is [springfox](https://github.com/springfox/springfox) -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} You can view the server in swagger-ui by pointing to http://localhost:{{serverPort}}{{contextPath}}{{^contextPath}}/{{/contextPath}}/ \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/application.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/application.mustache index 67214287ed3d..655c870be613 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/application.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/application.mustache @@ -1,3 +1,3 @@ -{{#useSpringfox}} +{{#springFoxDocumentationProvider}} springfox.documentation.swagger.v2.path=/api-docs -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/openapiUiConfiguration.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/openapiUiConfiguration.mustache index 8709512d54a9..a9b5410403d2 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/openapiUiConfiguration.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/openapiUiConfiguration.mustache @@ -11,9 +11,9 @@ import org.openapitools.jackson.nullable.JsonNullableModule; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -{{#useSpringfox}} +{{#springFoxDocumentationProvider}} import org.springframework.context.annotation.Import; -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} import org.springframework.context.annotation.Bean; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; @@ -39,9 +39,9 @@ import javax.annotation.Generated; @ComponentScan(basePackages = {"{{apiPackage}}", "{{configPackage}}"}) @EnableWebMvc @PropertySource("classpath:application.properties") -{{#useSpringfox}} +{{#springFoxDocumentationProvider}} @Import(OpenAPIDocumentationConfig.class) -{{/useSpringfox}} +{{/springFoxDocumentationProvider}} public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; @@ -81,11 +81,11 @@ public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter { if (!registry.hasMappingForPattern("/**")) { registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); } - {{^useSpringfox}} + {{^springFoxDocumentationProvider}} if (!registry.hasMappingForPattern("/swagger-ui/**")) { registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); } - {{/useSpringfox}} + {{/springFoxDocumentationProvider}} } /*@Override diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache index f0f17f6b2088..3610261ac22a 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache @@ -147,7 +147,7 @@ jakarta.xml.bind-api ${jakarta.xml.bind-version} - {{#useSpringfox}} + {{#springFoxDocumentationProvider}} io.springfox @@ -165,8 +165,8 @@ springfox-swagger-ui ${springfox-version} - {{/useSpringfox}} - {{^useSpringfox}} + {{/springFoxDocumentationProvider}} + {{^springFoxDocumentationProvider}} io.springfox springfox-swagger2 @@ -208,7 +208,7 @@ jackson-dataformat-yaml ${jackson-version} - {{/useSpringfox}} + {{/springFoxDocumentationProvider}} {{#withXml}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache index 18f1ca620719..9261660fe365 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache @@ -26,9 +26,9 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; {{/withXml}} {{/jackson}} -{{#oas3}} +{{#swagger2AnnotationLibrary}} import io.swagger.v3.oas.annotations.media.Schema; -{{/oas3}} +{{/swagger2AnnotationLibrary}} {{#withXml}} import javax.xml.bind.annotation.*; diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache index 7f3eb71e0b01..304e097c219f 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/paramDoc.mustache @@ -1 +1 @@ -{{#oas3}}@Parameter(name = "{{{baseName}}}", description = "{{{description}}}"{{#required}}, required = true{{/required}}, schema = @Schema(description = ""{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}})){{/oas3}}{{^oas3}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}){{/oas3}} \ No newline at end of file +{{#swagger2AnnotationLibrary}}@Parameter(name = "{{{baseName}}}", description = "{{{description}}}"{{#required}}, required = true{{/required}}, schema = @Schema(description = ""{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}})){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}{{/isContainer}}){{/swagger1AnnotationLibrary}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache index dd1ac7f2b98a..c33f9ac03b4c 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache @@ -3,7 +3,12 @@ */ {{>additionalModelTypeAnnotations}} {{#description}} -{{#oas3}}@Schema({{#name}}name = "{{name}}", {{/name}}{{/oas3}}{{^oas3}}@ApiModel({{/oas3}}description = "{{{.}}}") +{{#swagger1AnnotationLibrary}} +@ApiModel(description = "{{{description}}}") +{{/swagger1AnnotationLibrary}} +{{#swagger2AnnotationLibrary}} +@Schema({{#name}}name = "{{name}}", {{/name}}description = "{{{description}}}") +{{/swagger2AnnotationLibrary}} {{/description}} {{#discriminator}} {{>typeInfoAnnotation}} @@ -130,12 +135,12 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{^parent}}{{#ha {{#useBeanValidation}} {{>beanValidation}} {{/useBeanValidation}} - {{#oas3}} + {{#swagger2AnnotationLibrary}} @Schema(name = "{{{baseName}}}", {{#isReadOnly}}accessMode = Schema.AccessMode.READ_ONLY, {{/isReadOnly}}{{#example}}example = "{{{.}}}", {{/example}}{{#description}}description = "{{{.}}}", {{/description}}required = {{{required}}}) - {{/oas3}} - {{^oas3}} + {{/swagger2AnnotationLibrary}} + {{#swagger1AnnotationLibrary}} @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") - {{/oas3}} + {{/swagger1AnnotationLibrary}} public {{>nullableDataType}} {{getter}}() { return {{name}}; } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index a5b43b0e3b7d..456dea2f4001 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -43,6 +43,7 @@ import static java.util.stream.Collectors.groupingBy; import static org.openapitools.codegen.TestUtils.assertFileContains; import static org.openapitools.codegen.TestUtils.assertFileNotContains; import static org.openapitools.codegen.languages.SpringCodegen.RESPONSE_WRAPPER; +import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -486,6 +487,7 @@ public class SpringCodegenTest { final SpringCodegen codegen = new SpringCodegen(); codegen.setLibrary("spring-boot"); codegen.setDelegatePattern(true); + codegen.additionalProperties().put(DOCUMENTATION_PROVIDER, "springfox"); final Map files = generateFiles(codegen, "src/test/resources/3_0/form-multipart-binary-array.yaml"); @@ -687,6 +689,7 @@ public class SpringCodegenTest { SpringCodegen codegen = new SpringCodegen(); codegen.setOutputDir(output.getAbsolutePath()); codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + codegen.additionalProperties().put(DOCUMENTATION_PROVIDER, "springfox"); ClientOptInput input = new ClientOptInput(); input.openAPI(openAPI); @@ -800,6 +803,7 @@ public class SpringCodegenTest { Assert.assertEquals(codegen.importMapping().get("Pageable"), "org.springframework.data.domain.Pageable"); Assert.assertEquals(codegen.importMapping().get("DateTimeFormat"), "org.springframework.format.annotation.DateTimeFormat"); Assert.assertEquals(codegen.importMapping().get("ApiIgnore"), "springfox.documentation.annotations.ApiIgnore"); + Assert.assertEquals(codegen.importMapping().get("ParameterObject"), "org.springdoc.api.annotations.ParameterObject"); } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/languages/features/DocumentationProviderFeaturesTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/languages/features/DocumentationProviderFeaturesTest.java new file mode 100644 index 000000000000..0954e79fb3a9 --- /dev/null +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/languages/features/DocumentationProviderFeaturesTest.java @@ -0,0 +1,50 @@ +package org.openapitools.codegen.languages.features; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; +import org.openapitools.codegen.languages.features.DocumentationProviderFeatures.AnnotationLibrary; +import org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DocumentationProvider; +import org.testng.Assert; +import org.testng.annotations.Test; + +// Tests are not final, methods currently just generate documentation as MD tables. +public class DocumentationProviderFeaturesTest { + + @Test(priority = 0) + void generateDocumentationProviderTable() { + List providers = Arrays.asList(DocumentationProvider.values()); + StringBuilder sb = new StringBuilder(); + sb.append("### DocumentationProvider\n"); + sb.append("|Cli Option|Description|Property Name|Preferred Annotation Library|Supported Annotation Libraries|\n"); + sb.append("|----------|-----------|-------------|----------------------------|------------------------------|\n"); + providers.forEach(dp -> sb.append(String.format(Locale.ROOT, "|**%s**|%s|`%s`|%s|%s|\n", + dp.toCliOptValue(), + dp.getDescription(), + dp.getPropertyName(), + dp.getPreferredAnnotationLibrary().toCliOptValue(), + dp.supportedAnnotationLibraries().stream() + .map(AnnotationLibrary::toCliOptValue) + .collect(Collectors.joining(", ")) + ))); + sb.append("\n"); + Assert.assertTrue(sb.toString().contains("none")); + } + + @Test(priority = 1) + void generateAnnotationLibraryTable() { + List libraries = Arrays.asList(AnnotationLibrary.values()); + StringBuilder sb = new StringBuilder(); + sb.append("### AnnotationLibrary\n"); + sb.append("|Cli Option|Description|Property Name|\n"); + sb.append("|----------|-----------|-----------|\n"); + libraries.forEach(dp -> sb.append(String.format(Locale.ROOT, "|**%s**|%s|`%s`|\n", + dp.toCliOptValue(), + dp.getDescription(), + dp.getPropertyName() + ))); + Assert.assertTrue(sb.toString().contains("none")); + sb.append("\n"); + } +} \ No newline at end of file diff --git a/samples/client/petstore/spring-cloud-async/pom.xml b/samples/client/petstore/spring-cloud-async/pom.xml index 6b400a3539fe..d542d02ebc73 100644 --- a/samples/client/petstore/spring-cloud-async/pom.xml +++ b/samples/client/petstore/spring-cloud-async/pom.xml @@ -9,7 +9,6 @@ 1.8 ${java.version} ${java.version} - 1.6.3 2.9.2 diff --git a/samples/client/petstore/spring-cloud-date-time/pom.xml b/samples/client/petstore/spring-cloud-date-time/pom.xml index c01b2969fb37..36fac629b8d1 100644 --- a/samples/client/petstore/spring-cloud-date-time/pom.xml +++ b/samples/client/petstore/spring-cloud-date-time/pom.xml @@ -9,7 +9,6 @@ 1.8 ${java.version} ${java.version} - 1.6.3 2.9.2 diff --git a/samples/client/petstore/spring-cloud-spring-pageable/pom.xml b/samples/client/petstore/spring-cloud-spring-pageable/pom.xml index 622e4334036f..d6f807b454e5 100644 --- a/samples/client/petstore/spring-cloud-spring-pageable/pom.xml +++ b/samples/client/petstore/spring-cloud-spring-pageable/pom.xml @@ -9,7 +9,6 @@ 1.8 ${java.version} ${java.version} - 1.6.3 2.9.2 diff --git a/samples/client/petstore/spring-cloud/pom.xml b/samples/client/petstore/spring-cloud/pom.xml index 6b400a3539fe..d542d02ebc73 100644 --- a/samples/client/petstore/spring-cloud/pom.xml +++ b/samples/client/petstore/spring-cloud/pom.xml @@ -9,7 +9,6 @@ 1.8 ${java.version} ${java.version} - 1.6.3 2.9.2 diff --git a/samples/openapi3/client/petstore/spring-cloud-async/pom.xml b/samples/openapi3/client/petstore/spring-cloud-async/pom.xml index 950b9bbe3531..d236e4527106 100644 --- a/samples/openapi3/client/petstore/spring-cloud-async/pom.xml +++ b/samples/openapi3/client/petstore/spring-cloud-async/pom.xml @@ -9,7 +9,7 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot @@ -33,10 +33,11 @@ + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml b/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml index 9f8de9c14cdf..cd2a2017c6cf 100644 --- a/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml +++ b/samples/openapi3/client/petstore/spring-cloud-date-time/pom.xml @@ -9,7 +9,7 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot @@ -33,10 +33,11 @@ + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml index 6cf023f501f2..899cb60d2d7c 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/pom.xml @@ -9,7 +9,7 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot @@ -33,10 +33,11 @@ + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml index 648e8d7f9950..933cfb2a5ff7 100644 --- a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/pom.xml @@ -9,7 +9,7 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot @@ -33,10 +33,11 @@ + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index 4ae25d24dfb3..1a58d97ea6ca 100644 --- a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -7,6 +7,7 @@ package org.openapitools.api; import org.openapitools.model.ModelApiResponse; import org.springframework.data.domain.Pageable; +import org.springdoc.api.annotations.ParameterObject; import org.openapitools.model.Pet; import org.springframework.core.io.Resource; import io.swagger.v3.oas.annotations.Operation; @@ -119,7 +120,7 @@ public interface PetApi { ) ResponseEntity> findPetsByStatus( @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", allowableValues = { "available", "pending", "sold" })) @Valid @RequestParam(value = "status", required = true) List status, - final Pageable pageable + @ParameterObject final Pageable pageable ); @@ -151,7 +152,7 @@ public interface PetApi { ) ResponseEntity> findPetsByTags( @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) List tags, - final Pageable pageable + @ParameterObject final Pageable pageable ); diff --git a/samples/openapi3/client/petstore/spring-cloud/pom.xml b/samples/openapi3/client/petstore/spring-cloud/pom.xml index 6cf023f501f2..899cb60d2d7c 100644 --- a/samples/openapi3/client/petstore/spring-cloud/pom.xml +++ b/samples/openapi3/client/petstore/spring-cloud/pom.xml @@ -9,7 +9,7 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot @@ -33,10 +33,11 @@ + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/client/petstore/spring-stubs/pom.xml b/samples/openapi3/client/petstore/spring-stubs/pom.xml index 5e1f049caf43..b2890ab9d519 100644 --- a/samples/openapi3/client/petstore/spring-stubs/pom.xml +++ b/samples/openapi3/client/petstore/spring-stubs/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -28,10 +28,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator-ignore b/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/FILES b/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/FILES new file mode 100644 index 000000000000..7de4a0d86c09 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/FILES @@ -0,0 +1,20 @@ +README.md +pom.xml +src/main/java/org/openapitools/OpenAPI2SpringBoot.java +src/main/java/org/openapitools/RFC3339DateFormat.java +src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/PetApi.java +src/main/java/org/openapitools/api/PetApiController.java +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/HomeController.java +src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ModelApiResponse.java +src/main/java/org/openapitools/model/Order.java +src/main/java/org/openapitools/model/Pet.java +src/main/java/org/openapitools/model/Tag.java +src/main/java/org/openapitools/model/User.java +src/main/resources/application.properties +src/main/resources/openapi.yaml diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/VERSION b/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/VERSION new file mode 100644 index 000000000000..0984c4c1ad21 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/README.md b/samples/openapi3/server/petstore/spring-boot-springdoc/README.md new file mode 100644 index 000000000000..5bbe4a495d99 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/README.md @@ -0,0 +1,16 @@ +# OpenAPI generated server + +Spring Boot Server + + +## Overview +This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. +This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. + +Start your server as a simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:8080/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/pom.xml b/samples/openapi3/server/petstore/spring-boot-springdoc/pom.xml new file mode 100644 index 000000000000..8cc169fadddd --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/pom.xml @@ -0,0 +1,72 @@ + + 4.0.0 + org.openapitools.openapi3 + spring-boot-springdoc + jar + spring-boot-springdoc + 1.0.0-SNAPSHOT + + 1.8 + ${java.version} + ${java.version} + 1.6.4 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-commons + + + + org.springdoc + springdoc-openapi-ui + ${springdoc.version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + 0.2.2 + + + + org.springframework.boot + spring-boot-starter-validation + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..cb088f451935 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,63 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +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.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenAPI2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPI2SpringBoot.class).run(args); + } + + static class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + + @Bean + public WebMvcConfigurer webConfigurer() { + return new WebMvcConfigurer() { + /*@Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("Content-Type"); + }*/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); + } + }; + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/RFC3339DateFormat.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/RFC3339DateFormat.java new file mode 100644 index 000000000000..bcd3936d8b34 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/RFC3339DateFormat.java @@ -0,0 +1,38 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return this; + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/ApiUtil.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/ApiUtil.java new file mode 100644 index 000000000000..1245b1dd0ccf --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/ApiUtil.java @@ -0,0 +1,19 @@ +package org.openapitools.api; + +import org.springframework.web.context.request.NativeWebRequest; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class ApiUtil { + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class); + res.setCharacterEncoding("UTF-8"); + res.addHeader("Content-Type", contentType); + res.getWriter().print(example); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApi.java new file mode 100644 index 000000000000..f27571c387be --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApi.java @@ -0,0 +1,393 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; +import org.springframework.core.io.Resource; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +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; +import javax.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * POST /pet : Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store (required) + * @return successful operation (status code 200) + * or Invalid input (status code 405) + */ + @Operation( + operationId = "addPet", + summary = "Add a new pet to the store", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity addPet( + @Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet pet + ) { + 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\" : \"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); + + } + + + /** + * DELETE /pet/{petId} : Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return Invalid pet value (status code 400) + */ + @Operation( + operationId = "deletePet", + summary = "Deletes a pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid pet value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/pet/{petId}" + ) + default ResponseEntity deletePet( + @Parameter(name = "petId", description = "Pet id to delete", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "api_key", description = "", schema = @Schema(description = "")) @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) + */ + @Operation( + operationId = "findPetsByStatus", + summary = "Finds Pets by status", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid status value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByStatus", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(name = "status", description = "Status values that need to be considered for filter", required = true, schema = @Schema(description = "", 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\" : \"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 + */ + @Operation( + operationId = "findPetsByTags", + summary = "Finds Pets by tags", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/findByTags", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "tags", required = true) List 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\" : \"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) + */ + @Operation( + operationId = "getPetById", + summary = "Find pet by ID", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/pet/{petId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getPetById( + @Parameter(name = "petId", description = "ID of pet to return", required = true, schema = @Schema(description = "")) @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\" : \"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 pet 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) + */ + @Operation( + operationId = "updatePet", + summary = "Update an existing pet", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" } + ) + default ResponseEntity updatePet( + @Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true, schema = @Schema(description = "")) @Valid @RequestBody Pet pet + ) { + 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\" : \"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); + + } + + + /** + * 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) + */ + @Operation( + operationId = "updatePetWithForm", + summary = "Updates a pet in the store with form data", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "405", description = "Invalid input") + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" } + ) + default ResponseEntity updatePetWithForm( + @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "name", description = "Updated name of the pet", schema = @Schema(description = "")) @Valid @RequestPart(value = "name", required = false) String name, + @Parameter(name = "status", description = "Updated status of the pet", schema = @Schema(description = "")) @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) + */ + @Operation( + operationId = "uploadFile", + summary = "uploads an image", + tags = { "pet" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) + }, + security = { + @SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" } + ) + default ResponseEntity uploadFile( + @Parameter(name = "petId", description = "ID of pet to update", required = true, schema = @Schema(description = "")) @PathVariable("petId") Long petId, + @Parameter(name = "additionalMetadata", description = "Additional data to pass to server", schema = @Schema(description = "")) @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(name = "file", description = "file to upload", schema = @Schema(description = "")) @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/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApiController.java new file mode 100644 index 000000000000..4ad9ef06158b --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/PetApiController.java @@ -0,0 +1,27 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +import javax.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class PetApiController implements PetApi { + + private final NativeWebRequest request; + + @Autowired + public PetApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApi.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApi.java new file mode 100644 index 000000000000..04b786a8ba48 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,190 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.util.Map; +import org.openapitools.model.Order; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +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; +import javax.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * DELETE /store/order/{orderId} : 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) + */ + @Operation( + operationId = "deleteOrder", + summary = "Delete purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/store/order/{orderId}" + ) + default ResponseEntity deleteOrder( + @Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("orderId") 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) + */ + @Operation( + operationId = "getInventory", + summary = "Returns pet inventories by status", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))) + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/inventory", + produces = { "application/json" } + ) + default ResponseEntity> getInventory( + + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * GET /store/order/{orderId} : 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) + */ + @Operation( + operationId = "getOrderById", + summary = "Find purchase order by ID", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/store/order/{orderId}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, schema = @Schema(description = "")) @PathVariable("orderId") 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 + * + * @param order order placed for purchasing the pet (required) + * @return successful operation (status code 200) + * or Invalid Order (status code 400) + */ + @Operation( + operationId = "placeOrder", + summary = "Place an order for a pet", + tags = { "store" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/store/order", + produces = { "application/xml", "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity placeOrder( + @Parameter(name = "Order", description = "order placed for purchasing the pet", required = true, schema = @Schema(description = "")) @Valid @RequestBody Order order + ) { + 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/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApiController.java new file mode 100644 index 000000000000..293d3035f805 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/StoreApiController.java @@ -0,0 +1,27 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +import javax.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class StoreApiController implements StoreApi { + + private final NativeWebRequest request; + + @Autowired + public StoreApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApi.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApi.java new file mode 100644 index 000000000000..3268f2475c06 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApi.java @@ -0,0 +1,304 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import java.util.List; +import java.time.OffsetDateTime; +import org.openapitools.model.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +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; +import javax.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Validated +@Tag(name = "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. + * + * @param user Created user object (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "createUser", + summary = "Create user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user", + consumes = { "application/json" } + ) + default ResponseEntity createUser( + @Parameter(name = "User", description = "Created user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User user + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /user/createWithArray : Creates list of users with given input array + * + * @param user List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "createUsersWithArrayInput", + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithArray", + consumes = { "application/json" } + ) + default ResponseEntity createUsersWithArrayInput( + @Parameter(name = "User", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List user + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * POST /user/createWithList : Creates list of users with given input array + * + * @param user List of user object (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "createUsersWithListInput", + summary = "Creates list of users with given input array", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/user/createWithList", + consumes = { "application/json" } + ) + default ResponseEntity createUsersWithListInput( + @Parameter(name = "User", description = "List of user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody List user + ) { + 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) + */ + @Operation( + operationId = "deleteUser", + summary = "Delete user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.DELETE, + value = "/user/{username}" + ) + default ResponseEntity deleteUser( + @Parameter(name = "username", description = "The name that needs to be deleted", required = true, schema = @Schema(description = "")) @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) + */ + @Operation( + operationId = "getUserByName", + summary = "Get user by user name", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/{username}", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity getUserByName( + @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, schema = @Schema(description = "")) @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); + + } + + + /** + * 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) + */ + @Operation( + operationId = "loginUser", + summary = "Logs user into the system", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/login", + produces = { "application/xml", "application/json" } + ) + default ResponseEntity loginUser( + @NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Parameter(name = "username", description = "The user name for login", required = true, schema = @Schema(description = "")) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, schema = @Schema(description = "")) @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) + */ + @Operation( + operationId = "logoutUser", + summary = "Logs out current logged in user session", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.GET, + value = "/user/logout" + ) + default 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 user Updated user object (required) + * @return Invalid user supplied (status code 400) + * or User not found (status code 404) + */ + @Operation( + operationId = "updateUser", + summary = "Updated user", + tags = { "user" }, + responses = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") + }, + security = { + @SecurityRequirement(name = "api_key") + } + ) + @RequestMapping( + method = RequestMethod.PUT, + value = "/user/{username}", + consumes = { "application/json" } + ) + default ResponseEntity updateUser( + @Parameter(name = "username", description = "name that need to be deleted", required = true, schema = @Schema(description = "")) @PathVariable("username") String username, + @Parameter(name = "User", description = "Updated user object", required = true, schema = @Schema(description = "")) @Valid @RequestBody User user + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApiController.java new file mode 100644 index 000000000000..aab4767a50d0 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/api/UserApiController.java @@ -0,0 +1,27 @@ +package org.openapitools.api; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.context.request.NativeWebRequest; +import java.util.Optional; +import javax.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}") +public class UserApiController implements UserApi { + + private final NativeWebRequest request; + + @Autowired + public UserApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/HomeController.java new file mode 100644 index 000000000000..61d4ebb31830 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/HomeController.java @@ -0,0 +1,53 @@ +package org.openapitools.configuration; + +import org.springframework.context.annotation.Bean; +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + +/** + * Home redirection to OpenAPI api documentation + */ +@Controller +public class HomeController { + + private static YAMLMapper yamlMapper = new YAMLMapper(); + + @Value("classpath:/openapi.yaml") + private Resource openapi; + + @Bean + public String openapiContent() throws IOException { + try(InputStream is = openapi.getInputStream()) { + return StreamUtils.copyToString(is, Charset.defaultCharset()); + } + } + + @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") + @ResponseBody + public String openapiYaml() throws IOException { + return openapiContent(); + } + + @GetMapping(value = "/openapi.json", produces = "application/json") + @ResponseBody + public Object openapiJson() throws IOException { + return yamlMapper.readValue(openapiContent(), Object.class); + } + + @RequestMapping("/") + public String index() { + return "redirect:swagger-ui/index.html?url=../openapi.json"; + } + + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Category.java new file mode 100644 index 000000000000..823adb2ae4d8 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Category.java @@ -0,0 +1,108 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * A category for a pet + */ + +@Schema(name = "Category", description = "A category for a pet") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Category { + + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + + @Schema(name = "id", required = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @Schema(name = "name", required = false) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 000000000000..ea4f1e402648 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,132 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * Describes the result of uploading an image resource + */ + +@Schema(name = "ApiResponse", description = "Describes the result of uploading an image resource") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ModelApiResponse { + + @JsonProperty("code") + private Integer code; + + @JsonProperty("type") + private String type; + + @JsonProperty("message") + private String message; + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + + @Schema(name = "code", required = false) + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", required = false) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + + @Schema(name = "message", required = false) + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Order.java new file mode 100644 index 000000000000..e624a0d7c1fe --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Order.java @@ -0,0 +1,245 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import org.springframework.format.annotation.DateTimeFormat; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * An order for a pets from the pet store + */ + +@Schema(name = "Order", description = "An order for a pets from the pet store") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Order { + + @JsonProperty("id") + private Long id; + + @JsonProperty("petId") + private Long petId; + + @JsonProperty("quantity") + private Integer quantity; + + @JsonProperty("shipDate") + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + private OffsetDateTime shipDate; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("status") + private StatusEnum status; + + @JsonProperty("complete") + private Boolean complete = false; + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + + @Schema(name = "id", required = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + */ + + @Schema(name = "petId", required = false) + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + */ + + @Schema(name = "quantity", required = false) + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order shipDate(OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + */ + @Valid + @Schema(name = "shipDate", required = false) + public OffsetDateTime getShipDate() { + return shipDate; + } + + public void setShipDate(OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + */ + + @Schema(name = "status", description = "Order Status", required = false) + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + */ + + @Schema(name = "complete", required = false) + public Boolean getComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Pet.java new file mode 100644 index 000000000000..ddff66759bac --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Pet.java @@ -0,0 +1,261 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.model.Category; +import org.openapitools.model.Tag; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * A pet for sale in the pet store + */ + +@Schema(name = "Pet", description = "A pet for sale in the pet store") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Pet { + + @JsonProperty("id") + private Long id; + + @JsonProperty("category") + private Category category; + + @JsonProperty("name") + private String name; + + @JsonProperty("photoUrls") + @Valid + private List photoUrls = new ArrayList<>(); + + @JsonProperty("tags") + @Valid + private List tags = null; + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("status") + private StatusEnum status; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + + @Schema(name = "id", required = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + */ + @Valid + @Schema(name = "category", required = false) + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @NotNull + @Schema(name = "name", example = "doggie", required = true) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + */ + @NotNull + @Schema(name = "photoUrls", required = true) + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + */ + @Valid + @Schema(name = "tags", required = false) + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + */ + + @Schema(name = "status", description = "pet status in the store", required = false) + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Tag.java new file mode 100644 index 000000000000..5c3ac82ba6e8 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/Tag.java @@ -0,0 +1,108 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * A tag for a pet + */ + +@Schema(name = "Tag", description = "A tag for a pet") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class Tag { + + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name; + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + + @Schema(name = "id", required = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + + @Schema(name = "name", required = false) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/User.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/User.java new file mode 100644 index 000000000000..328569672eb4 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/model/User.java @@ -0,0 +1,252 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * A User who is purchasing from the pet store + */ + +@Schema(name = "User", description = "A User who is purchasing from the pet store") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class User { + + @JsonProperty("id") + private Long id; + + @JsonProperty("username") + private String username; + + @JsonProperty("firstName") + private String firstName; + + @JsonProperty("lastName") + private String lastName; + + @JsonProperty("email") + private String email; + + @JsonProperty("password") + private String password; + + @JsonProperty("phone") + private String phone; + + @JsonProperty("userStatus") + private Integer userStatus; + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + + @Schema(name = "id", required = false) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + */ + + @Schema(name = "username", required = false) + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + */ + + @Schema(name = "firstName", required = false) + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + */ + + @Schema(name = "lastName", required = false) + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + */ + + @Schema(name = "email", required = false) + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + */ + + @Schema(name = "password", required = false) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + */ + + @Schema(name = "phone", required = false) + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + */ + + @Schema(name = "userStatus", description = "User Status", required = false) + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/application.properties b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/application.properties new file mode 100644 index 000000000000..7e90813e59b2 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=8080 +spring.jackson.date-format=org.openapitools.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/openapi.yaml new file mode 100644 index 000000000000..56703dfefb56 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/resources/openapi.yaml @@ -0,0 +1,893 @@ +openapi: 3.0.0 +info: + description: This is a sample server Petstore server. For this sample, you can use + the api key `special-key` to test the authorization filters. + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io/v2 +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /pet: + post: + operationId: addPet + requestBody: + $ref: '#/components/requestBodies/Pet' + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store + tags: + - pet + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + put: + operationId: updatePet + requestBody: + $ref: '#/components/requestBodies/Pet' + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: pet + /pet/findByStatus: + get: + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - deprecated: true + description: Status values that need to be considered for filter + explode: false + in: query + name: status + required: true + schema: + items: + default: available + enum: + - available + - pending + - sold + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + description: successful operation + "400": + description: Invalid status value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by status + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/findByTags: + get: + deprecated: true + description: Multiple tags can be provided with comma separated strings. Use + tag1, tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - description: Tags to filter by + explode: false + in: query + name: tags + required: true + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: + application/xml: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + application/json: + schema: + items: + $ref: '#/components/schemas/Pet' + type: array + description: successful operation + "400": + description: Invalid tag value + security: + - petstore_auth: + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - explode: false + in: header + name: api_key + required: false + schema: + type: string + style: simple + - description: Pet id to delete + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "400": + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + get: + description: Returns a single pet + operationId: getPetById + parameters: + - description: ID of pet to return + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Pet not found + security: + - api_key: [] + summary: Find pet by ID + tags: + - pet + x-accepts: application/json + x-tags: + - tag: pet + post: + operationId: updatePetWithForm + parameters: + - description: ID of pet that needs to be updated + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + $ref: '#/components/requestBodies/inline_object' + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + responses: + "405": + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Updates a pet in the store with form data + tags: + - pet + x-contentType: application/x-www-form-urlencoded + x-accepts: application/json + x-tags: + - tag: pet + /pet/{petId}/uploadImage: + post: + operationId: uploadFile + parameters: + - description: ID of pet to update + explode: false + in: path + name: petId + required: true + schema: + format: int64 + type: integer + style: simple + requestBody: + $ref: '#/components/requestBodies/inline_object_1' + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image + tags: + - pet + x-contentType: multipart/form-data + x-accepts: application/json + x-tags: + - tag: pet + /store/inventory: + get: + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + "200": + content: + application/json: + schema: + additionalProperties: + format: int32 + type: integer + type: object + description: successful operation + security: + - api_key: [] + summary: Returns pet inventories by status + tags: + - store + x-accepts: application/json + x-tags: + - tag: store + /store/order: + post: + operationId: placeOrder + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: store + /store/order/{orderId}: + delete: + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - description: ID of the order that needs to be deleted + explode: false + in: path + name: orderId + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Delete purchase order by ID + tags: + - store + x-accepts: application/json + x-tags: + - tag: store + get: + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generated exceptions + operationId: getOrderById + parameters: + - description: ID of pet that needs to be fetched + explode: false + in: path + name: orderId + required: true + schema: + format: int64 + maximum: 5 + minimum: 1 + type: integer + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + description: successful operation + "400": + description: Invalid ID supplied + "404": + description: Order not found + summary: Find purchase order by ID + tags: + - store + x-accepts: application/json + x-tags: + - tag: store + /user: + post: + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Create user + tags: + - user + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user + /user/createWithArray: + post: + operationId: createUsersWithArrayInput + requestBody: + $ref: '#/components/requestBodies/UserArray' + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user + /user/createWithList: + post: + operationId: createUsersWithListInput + requestBody: + $ref: '#/components/requestBodies/UserArray' + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Creates list of users with given input array + tags: + - user + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user + /user/login: + get: + operationId: loginUser + parameters: + - description: The user name for login + explode: true + in: query + name: username + required: true + schema: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ + type: string + style: form + - description: The password for login in clear text + explode: true + in: query + name: password + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + description: successful operation + headers: + Set-Cookie: + description: Cookie authentication key for use with the `api_key` apiKey + authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple + X-Rate-Limit: + description: calls per hour allowed by the user + explode: false + schema: + format: int32 + type: integer + style: simple + X-Expires-After: + description: date in UTC when token expires + explode: false + schema: + format: date-time + type: string + style: simple + "400": + description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/logout: + get: + operationId: logoutUser + responses: + default: + description: successful operation + security: + - api_key: [] + summary: Logs out current logged in user session + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + /user/{username}: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - description: The name that needs to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - api_key: [] + summary: Delete user + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + get: + operationId: getUserByName + parameters: + - description: The name that needs to be fetched. Use user1 for testing. + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + description: successful operation + "400": + description: Invalid username supplied + "404": + description: User not found + summary: Get user by user name + tags: + - user + x-accepts: application/json + x-tags: + - tag: user + put: + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - description: name that need to be deleted + explode: false + in: path + name: username + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + responses: + "400": + description: Invalid user supplied + "404": + description: User not found + security: + - api_key: [] + summary: Updated user + tags: + - user + x-contentType: application/json + x-accepts: application/json + x-tags: + - tag: user +components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + inline_object: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/inline_object' + inline_object_1: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/inline_object_1' + schemas: + Order: + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + title: Pet Order + type: object + xml: + name: Order + Category: + description: A category for a pet + example: + name: name + id: 6 + properties: + id: + format: int64 + type: integer + name: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ + type: string + title: Pet category + type: object + xml: + name: Category + User: + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + properties: + id: + format: int64 + type: integer + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + description: User Status + format: int32 + type: integer + title: a User + type: object + xml: + name: User + Tag: + description: A tag for a pet + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + title: Pet Tag + type: object + xml: + name: Tag + Pet: + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + deprecated: true + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + title: a Pet + type: object + xml: + name: Pet + ApiResponse: + description: Describes the result of uploading an image resource + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + title: An uploaded response + type: object + inline_object: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + inline_object_1: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object + securitySchemes: + petstore_auth: + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + type: oauth2 + api_key: + in: header + name: api_key + type: apiKey diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml index 737d7740cd59..d6ebd909ee86 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/pom.xml @@ -9,12 +9,12 @@ 1.7 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java index 7c04dd3bba6b..cac2bbc73b8f 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java index 29b8c0d8176d..7081ba1a4304 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java @@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index aaed20e877f5..c28517ba229d 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java index 5b4cc8611ca9..97a3ec705b7b 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java @@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java index 5d9974b56913..9b0ba8bd7203 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java index 27741595f571..781b593f564e 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java @@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java index 34bae16b8986..61d4ebb31830 100644 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,8 +1,8 @@ package org.openapitools.configuration; +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; diff --git a/samples/openapi3/server/petstore/springboot-delegate/pom.xml b/samples/openapi3/server/petstore/springboot-delegate/pom.xml index 35758ea64964..8edd9579ef5c 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/pom.xml +++ b/samples/openapi3/server/petstore/springboot-delegate/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java index 34bae16b8986..61d4ebb31830 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,8 +1,8 @@ package org.openapitools.configuration; +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml b/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml index 1034cd0499da..7759fcc3928a 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java index 34bae16b8986..61d4ebb31830 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,8 +1,8 @@ package org.openapitools.configuration; +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; diff --git a/samples/openapi3/server/petstore/springboot-reactive/pom.xml b/samples/openapi3/server/petstore/springboot-reactive/pom.xml index a6268c2794f7..098af25f1834 100644 --- a/samples/openapi3/server/petstore/springboot-reactive/pom.xml +++ b/samples/openapi3/server/petstore/springboot-reactive/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java index b1e5bfc21ee5..fadcaeb03c60 100644 --- a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,14 +1,15 @@ package org.openapitools.configuration; +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.context.annotation.Bean; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.ServerResponse; diff --git a/samples/openapi3/server/petstore/springboot-useoptional/pom.xml b/samples/openapi3/server/petstore/springboot-useoptional/pom.xml index 800e0576cb50..975547fc709c 100644 --- a/samples/openapi3/server/petstore/springboot-useoptional/pom.xml +++ b/samples/openapi3/server/petstore/springboot-useoptional/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java index 34bae16b8986..61d4ebb31830 100644 --- a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,8 +1,8 @@ package org.openapitools.configuration; +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; diff --git a/samples/openapi3/server/petstore/springboot/pom.xml b/samples/openapi3/server/petstore/springboot/pom.xml index d0efb3028cea..4320644df2cc 100644 --- a/samples/openapi3/server/petstore/springboot/pom.xml +++ b/samples/openapi3/server/petstore/springboot/pom.xml @@ -9,12 +9,12 @@ 1.8 ${java.version} ${java.version} - 2.1.11 + 1.6.4 org.springframework.boot spring-boot-starter-parent - 2.5.8 + 2.6.2 src/main/java @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} + org.springdoc + springdoc-openapi-ui + ${springdoc.version} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java index 34bae16b8986..61d4ebb31830 100644 --- a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,8 +1,8 @@ package org.openapitools.configuration; +import org.springframework.context.annotation.Bean; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java index c9ae29ba1fea..ec8ea57868a8 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -1,7 +1,6 @@ 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; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java index aa5e668384ee..4bac5c6a4d42 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java @@ -12,7 +12,6 @@ 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; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index e1119b1010d6..64dd84c74f47 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -1,7 +1,6 @@ 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; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java index ba115c2cd0a4..8c66ba7d8b56 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/PetApiController.java @@ -4,7 +4,6 @@ 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; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java index d25fe52ea15c..021d8d718350 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/StoreApiController.java @@ -2,7 +2,6 @@ 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; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java index af6939bbb160..e72538504624 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/UserApiController.java @@ -3,7 +3,6 @@ package org.openapitools.api; import java.util.List; import org.threeten.bp.OffsetDateTime; import org.openapitools.model.User; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-reactive/README.md b/samples/server/petstore/springboot-reactive/README.md index 55dc732c1b00..b890fea09364 100644 --- a/samples/server/petstore/springboot-reactive/README.md +++ b/samples/server/petstore/springboot-reactive/README.md @@ -8,6 +8,8 @@ This server was generated by the [OpenAPI Generator](https://openapi-generator.t By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. +The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) + Start your server as a simple java application Change default port value in application.properties \ No newline at end of file diff --git a/samples/server/petstore/springboot-reactive/pom.xml b/samples/server/petstore/springboot-reactive/pom.xml index 6f5e06c6e297..d543d7100354 100644 --- a/samples/server/petstore/springboot-reactive/pom.xml +++ b/samples/server/petstore/springboot-reactive/pom.xml @@ -9,7 +9,7 @@ 1.8 ${java.version} ${java.version} - 1.6.3 + 2.9.2 org.springframework.boot @@ -34,10 +34,11 @@ org.springframework.data spring-data-commons + - io.swagger - swagger-annotations - ${swagger-core-version} + io.springfox + springfox-swagger2 + ${springfox.version} diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java index 254af0225142..a7a2c4e7dc40 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.reactive.config.CorsRegistry; -import org.springframework.web.reactive.config.ResourceHandlerRegistry; import org.springframework.web.reactive.config.WebFluxConfigurer; @SpringBootApplication @@ -47,11 +46,6 @@ public class OpenAPI2SpringBoot implements CommandLineRunner { .allowedMethods("*") .allowedHeaders("Content-Type"); }*/ - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); - } }; } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java index 0f78f2944335..de9aadfd5708 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; @@ -56,7 +57,7 @@ public interface AnotherFakeApi { ) default Mono> call123testSpecialTags( @ApiParam(value = "client model", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().call123testSpecialTags(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index 575a4e23910b..c05f795e57b3 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -1,5 +1,6 @@ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import org.openapitools.model.Client; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java index 5471ba1820dd..61bd43b6a67f 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; @@ -65,7 +66,7 @@ public interface FakeApi { ) default Mono> createXmlItem( @ApiParam(value = "XmlItem Body", required = true) @Valid @RequestBody Mono xmlItem, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().createXmlItem(xmlItem, exchange); } @@ -95,7 +96,7 @@ public interface FakeApi { ) default Mono> fakeOuterBooleanSerialize( @ApiParam(value = "Input boolean as post body") @Valid @RequestBody(required = false) Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().fakeOuterBooleanSerialize(body, exchange); } @@ -125,7 +126,7 @@ public interface FakeApi { ) default Mono> fakeOuterCompositeSerialize( @ApiParam(value = "Input composite as post body") @Valid @RequestBody(required = false) Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().fakeOuterCompositeSerialize(body, exchange); } @@ -155,7 +156,7 @@ public interface FakeApi { ) default Mono> fakeOuterNumberSerialize( @ApiParam(value = "Input number as post body") @Valid @RequestBody(required = false) Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().fakeOuterNumberSerialize(body, exchange); } @@ -185,7 +186,7 @@ public interface FakeApi { ) default Mono> fakeOuterStringSerialize( @ApiParam(value = "Input string as post body") @Valid @RequestBody(required = false) Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().fakeOuterStringSerialize(body, exchange); } @@ -214,7 +215,7 @@ public interface FakeApi { ) default Mono> testBodyWithFileSchema( @ApiParam(value = "", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testBodyWithFileSchema(body, exchange); } @@ -244,7 +245,7 @@ public interface FakeApi { default Mono> testBodyWithQueryParams( @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query, @ApiParam(value = "", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testBodyWithQueryParams(query, body, exchange); } @@ -275,7 +276,7 @@ public interface FakeApi { ) default Mono> testClientModel( @ApiParam(value = "client model", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testClientModel(body, exchange); } @@ -335,7 +336,7 @@ public interface FakeApi { @ApiParam(value = "None") @Valid @RequestPart(value = "dateTime", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime, @ApiParam(value = "None") @Valid @RequestPart(value = "password", required = false) String password, @ApiParam(value = "None") @Valid @RequestPart(value = "callback", required = false) String paramCallback, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, exchange); } @@ -380,7 +381,7 @@ public interface FakeApi { @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, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, exchange); } @@ -418,7 +419,7 @@ public interface FakeApi { @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, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, exchange); } @@ -446,7 +447,7 @@ public interface FakeApi { ) default Mono> testInlineAdditionalProperties( @ApiParam(value = "request body", required = true) @Valid @RequestBody Mono> param, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testInlineAdditionalProperties(param, exchange); } @@ -476,7 +477,7 @@ public interface FakeApi { default Mono> testJsonFormData( @ApiParam(value = "field1", required = true) @Valid @RequestPart(value = "param", required = true) String param, @ApiParam(value = "field2", required = true) @Valid @RequestPart(value = "param2", required = true) String param2, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testJsonFormData(param, param2, exchange); } @@ -512,7 +513,7 @@ public interface FakeApi { @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, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, exchange); } @@ -552,7 +553,7 @@ public interface FakeApi { @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId, @ApiParam(value = "file to upload", required = true) @RequestPart(value = "requiredFile", required = true) Flux requiredFile, @ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java index 0193067433b9..f6d86d18abc0 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,5 +1,6 @@ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java index 6a78bd00fe93..a693af64814d 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import org.openapitools.model.Client; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; @@ -59,7 +60,7 @@ public interface FakeClassnameTestApi { ) default Mono> testClassname( @ApiParam(value = "client model", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().testClassname(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index bd1f7f3542f8..527bedeecf90 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -1,5 +1,6 @@ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import org.openapitools.model.Client; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java index 4277d5fc01bf..21c34a69aea3 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; import org.springframework.core.io.Resource; @@ -64,7 +65,7 @@ public interface PetApi { ) default Mono> addPet( @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().addPet(body, exchange); } @@ -101,7 +102,7 @@ public interface PetApi { default Mono> deletePet( @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId, @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().deletePet(petId, apiKey, exchange); } @@ -140,7 +141,7 @@ public interface PetApi { ) default Mono>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List status, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().findPetsByStatus(status, exchange); } @@ -180,7 +181,7 @@ public interface PetApi { ) default Mono>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set tags, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().findPetsByTags(tags, exchange); } @@ -217,7 +218,7 @@ public interface PetApi { ) default Mono> getPetById( @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().getPetById(petId, exchange); } @@ -257,7 +258,7 @@ public interface PetApi { ) default Mono> updatePet( @ApiParam(value = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().updatePet(body, exchange); } @@ -295,7 +296,7 @@ public interface PetApi { @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, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().updatePetWithForm(petId, name, status, exchange); } @@ -335,7 +336,7 @@ public interface PetApi { @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") @RequestPart(value = "file", required = false) Flux file, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().uploadFile(petId, additionalMetadata, file, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java index b4c51ede9184..abdf3efc6215 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -1,5 +1,6 @@ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import org.openapitools.model.ModelApiResponse; import org.openapitools.model.Pet; import org.springframework.core.io.Resource; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java index 6d31ec918325..c3aef13167ed 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; import org.openapitools.model.Order; import io.swagger.annotations.*; @@ -56,7 +57,7 @@ public interface StoreApi { ) default Mono> deleteOrder( @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") String orderId, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().deleteOrder(orderId, exchange); } @@ -88,7 +89,7 @@ public interface StoreApi { produces = { "application/json" } ) default Mono>> getInventory( - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().getInventory(exchange); } @@ -122,7 +123,7 @@ public interface StoreApi { ) default Mono> getOrderById( @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") Long orderId, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().getOrderById(orderId, exchange); } @@ -153,7 +154,7 @@ public interface StoreApi { ) default Mono> placeOrder( @ApiParam(value = "order placed for purchasing the pet", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().placeOrder(body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java index d4f1e2efbf99..ecc745c202ff 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -1,5 +1,6 @@ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import java.util.Map; import org.openapitools.model.Order; import org.springframework.http.HttpStatus; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java index 923cedcc6469..d2efdab90238 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import java.util.List; import java.time.OffsetDateTime; import org.openapitools.model.User; @@ -55,7 +56,7 @@ public interface UserApi { ) default Mono> createUser( @ApiParam(value = "Created user object", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().createUser(body, exchange); } @@ -82,7 +83,7 @@ public interface UserApi { ) default Mono> createUsersWithArrayInput( @ApiParam(value = "List of user object", required = true) @Valid @RequestBody Flux body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().createUsersWithArrayInput(body, exchange); } @@ -109,7 +110,7 @@ public interface UserApi { ) default Mono> createUsersWithListInput( @ApiParam(value = "List of user object", required = true) @Valid @RequestBody Flux body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().createUsersWithListInput(body, exchange); } @@ -139,7 +140,7 @@ public interface UserApi { ) default Mono> deleteUser( @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().deleteUser(username, exchange); } @@ -172,7 +173,7 @@ public interface UserApi { ) default Mono> getUserByName( @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().getUserByName(username, exchange); } @@ -205,7 +206,7 @@ public interface UserApi { default Mono> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().loginUser(username, password, exchange); } @@ -230,7 +231,7 @@ public interface UserApi { value = "/user/logout" ) default Mono> logoutUser( - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().logoutUser(exchange); } @@ -262,7 +263,7 @@ public interface UserApi { default Mono> updateUser( @ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username, @ApiParam(value = "Updated user object", required = true) @Valid @RequestBody Mono body, - final ServerWebExchange exchange + @ApiIgnore final ServerWebExchange exchange ) { return getDelegate().updateUser(username, body, exchange); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java index 063cd6d0ee87..3e561778a3e7 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -1,5 +1,6 @@ package org.openapitools.api; +import springfox.documentation.annotations.ApiIgnore; import java.util.List; import java.time.OffsetDateTime; import org.openapitools.model.User; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java index b1e5bfc21ee5..60a69461eb5e 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/configuration/HomeController.java @@ -1,21 +1,12 @@ package org.openapitools.configuration; -import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; -import org.springframework.util.StreamUtils; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.context.annotation.Bean; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.ServerResponse; -import java.io.IOException; -import java.io.InputStream; import java.net.URI; -import java.nio.charset.Charset; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RouterFunctions.route; @@ -26,35 +17,11 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r @Controller public class HomeController { - private static YAMLMapper yamlMapper = new YAMLMapper(); - - @Value("classpath:/openapi.yaml") - private Resource openapi; - - @Bean - public String openapiContent() throws IOException { - try(InputStream is = openapi.getInputStream()) { - return StreamUtils.copyToString(is, Charset.defaultCharset()); - } - } - - @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") - @ResponseBody - public String openapiYaml() throws IOException { - return openapiContent(); - } - - @GetMapping(value = "/openapi.json", produces = "application/json") - @ResponseBody - public Object openapiJson() throws IOException { - return yamlMapper.readValue(openapiContent(), Object.class); - } - @Bean RouterFunction index() { return route( GET("/"), - req -> ServerResponse.temporaryRedirect(URI.create("swagger-ui/index.html?url=../openapi.json")).build() + req -> ServerResponse.temporaryRedirect(URI.create("swagger-ui.html")).build() ); } diff --git a/samples/server/petstore/springboot-reactive/src/main/resources/application.properties b/samples/server/petstore/springboot-reactive/src/main/resources/application.properties index 9d06609db665..ceca4a9e0d05 100644 --- a/samples/server/petstore/springboot-reactive/src/main/resources/application.properties +++ b/samples/server/petstore/springboot-reactive/src/main/resources/application.properties @@ -1,3 +1,4 @@ +springfox.documentation.swagger.v2.path=/api-docs server.port=80 spring.jackson.date-format=org.openapitools.RFC3339DateFormat spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java index 26b35dd83986..7ae394a6c746 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -1,7 +1,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java index 78cddbd6dd52..a9830bcc6483 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeApiController.java @@ -12,7 +12,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index 498a7ee2e459..477a1180d788 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -1,7 +1,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java index 18e06dce43de..78913cd2534a 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiController.java @@ -5,7 +5,6 @@ import org.openapitools.model.ModelApiResponse; import org.springframework.data.domain.Pageable; import org.openapitools.model.Pet; import org.springframework.core.io.Resource; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java index 9cc8ee421f69..8fd7fe5fa872 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/StoreApiController.java @@ -2,7 +2,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java index 777032bef5d4..3bc638dbeb9d 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/UserApiController.java @@ -3,7 +3,6 @@ package org.openapitools.api; import java.util.List; import org.threeten.bp.OffsetDateTime; import org.openapitools.model.User; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java index c9ae29ba1fea..ec8ea57868a8 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/AnotherFakeApiController.java @@ -1,7 +1,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java index e0f6cf75c832..848fe0e982f8 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeApiController.java @@ -12,7 +12,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java index e1119b1010d6..64dd84c74f47 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/FakeClassnameTestApiController.java @@ -1,7 +1,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java index 139d599af041..8e3fd4cebffc 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApiController.java @@ -5,7 +5,6 @@ import org.openapitools.model.ModelApiResponse; import org.springframework.data.domain.Pageable; import org.openapitools.model.Pet; import org.springframework.core.io.Resource; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java index d25fe52ea15c..021d8d718350 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/StoreApiController.java @@ -2,7 +2,6 @@ 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; diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java index af6939bbb160..e72538504624 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/UserApiController.java @@ -3,7 +3,6 @@ package org.openapitools.api; import java.util.List; import org.threeten.bp.OffsetDateTime; import org.openapitools.model.User; -import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity;