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
+
- 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