Skip to content

Commit

Permalink
Implement Source DocumentationProvider, spring-mvc decommission (Op…
Browse files Browse the repository at this point in the history
…enAPITools#11531)

* - Upgrade swagger-ui to 4.4.1
- Bring homeController.mustache up-to-date
- Main class is now OpenApiGeneratorApplication
- Introduce SpringBootTest.mustache
- Remove option swaggerDocketConfig/openapiDocketConfig in favor of documentationProvider.

* Generate Samples

* Restore generator-online classes
Fix spring-mvc builds

* Generate Samples

* Do not generate SpringFoxConfiguration.java when reactive ist set.

* Fix generation of SpringFoxConfiguration

* Generate Documentation

* Reactive support: add dependency management for springdoc-openapi-webflux-ui

* Generate Samples

* Change SpringBootApplication to OpenApiGeneratorApplication

* Generate Samples

* Implement SwaggerUIFeatures in SpringCodegen

* Generate Samples

* Add useSwaggerUI: true to some test configs

* Generate Samples

* Update Documentation

* Update Documentation

* Update README.mustache

* Generate Samples

* useSwaggerUI is true by default

* Generate Samples

* Update Documentation

* Add deprecation warnings to cli opts; Log a deprecation warning

* Update Documentation

* Generate Samples

* Remove spring-mvc library

* Remove spring-mvc from project and CI configs

* Check whether the selected documentation provider requires us to boostrap swagger-ui.

* Generate Samples

* Generate samples

* Generate samples

* Generate samples
  • Loading branch information
cachescrubber authored Feb 12, 2022
1 parent b01bcfe commit 0ed147e
Show file tree
Hide file tree
Showing 656 changed files with 3,948 additions and 62,921 deletions.
18 changes: 0 additions & 18 deletions .github/.test/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -920,24 +920,6 @@
"Server: Spring"
]
},
{
"input": "spring-mvc-petstore-j8-async-server.sh",
"matches": [
"Server: Spring"
]
},
{
"input": "spring-mvc-petstore-j8-localdatetime.sh",
"matches": [
"Server: Spring"
]
},
{
"input": "spring-mvc-petstore-server.sh",
"matches": [
"Server: Spring"
]
},
{
"input": "spring-stubs.sh",
"matches": [
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/samples-spring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ jobs:
- samples/openapi3/client/petstore/spring-stubs
- samples/openapi3/client/petstore/spring-stubs-skip-default-interface
# servers
- samples/server/petstore/spring-mvc
- samples/server/petstore/spring-mvc-default-value
- samples/server/petstore/spring-mvc-j8-async
- samples/server/petstore/spring-mvc-j8-localdatetime
- samples/server/petstore/springboot
- samples/openapi3/server/petstore/springboot
- samples/server/petstore/springboot-beanvalidation
Expand Down
1 change: 1 addition & 0 deletions bin/configs/spring-boot-beanvalidation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
documentationProvider: springfox
useSwaggerUI: false
java8: true
useBeanValidation: true
artifactId: spring-boot-beanvalidation
Expand Down
10 changes: 10 additions & 0 deletions bin/configs/spring-boot-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generatorName: spring
outputDir: samples/openapi3/server/petstore/springboot-source
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: source
artifactId: springboot
snapshotVersion: "true"
hideGenerationTimestamp: "true"
1 change: 1 addition & 0 deletions bin/configs/spring-boot-springdoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
groupId: org.openapitools.openapi3
documentationProvider: springdoc
useSwaggerUI: false
artifactId: spring-boot-springdoc
snapshotVersion: "true"
hideGenerationTimestamp: "true"
8 changes: 0 additions & 8 deletions bin/configs/spring-mvc-default-values.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions bin/configs/spring-mvc-j8-async.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions bin/configs/spring-mvc-j8-localdatetime.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions bin/configs/spring-mvc-no-nullable.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions bin/configs/spring-mvc-petstore-server-spring-pageable.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions bin/configs/spring-mvc.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions docs/generators/java-camel.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|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.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|springdoc|
|documentationProvider|Select the OpenAPI documentation provider.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
Expand All @@ -61,7 +61,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|invokerPackage|root package for generated code| |org.openapitools.api|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application using the SpringFox integration.</dd><dt>**spring-mvc**</dt><dd>Spring-MVC Server application using the SpringFox integration.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd></dl>|spring-boot|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd></dl>|spring-boot|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
Expand All @@ -84,13 +84,13 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src/main/java|
|swaggerDocketConfig|Generate Spring OpenAPI Docket configuration class.| |false|
|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi|
|title|server title name or client service name| |OpenAPI Spring|
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|useBeanValidation|Use BeanValidation API annotations| |true|
|useOptional|Use Optional container for optional parameters| |false|
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|useTags|use tags for creating interface and controller classnames| |false|
|virtualService|Generates the virtual service. For more details refer - https://github.com/virtualansoftware/virtualan/wiki| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
Expand Down
6 changes: 3 additions & 3 deletions docs/generators/spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|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.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|springdoc|
|documentationProvider|Select the OpenAPI documentation provider.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|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.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>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.</dd></dl>|false|
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
Expand All @@ -54,7 +54,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|invokerPackage|root package for generated code| |org.openapitools.api|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application using the SpringFox integration.</dd><dt>**spring-mvc**</dt><dd>Spring-MVC Server application using the SpringFox integration.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd></dl>|spring-boot|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd></dl>|spring-boot|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
Expand All @@ -77,13 +77,13 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src/main/java|
|swaggerDocketConfig|Generate Spring OpenAPI Docket configuration class.| |false|
|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi|
|title|server title name or client service name| |OpenAPI Spring|
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|useBeanValidation|Use BeanValidation API annotations| |true|
|useOptional|Use Optional container for optional parameters| |false|
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|useTags|use tags for creating interface and controller classnames| |false|
|virtualService|Generates the virtual service. For more details refer - https://github.com/virtualansoftware/virtualan/wiki| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("openapi2SpringBoot.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
"OpenAPI2SpringBoot.java"));
"OpenApiGeneratorApplication.java"));

if (!interfaceOnly) {
apiTemplateFiles.put("routesImpl.mustache", "RoutesImpl.java");
Expand Down
Loading

0 comments on commit 0ed147e

Please sign in to comment.