Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Source DocumentationProvider, spring-mvc decommission #11531

Merged

Conversation

cachescrubber
Copy link
Contributor

@cachescrubber cachescrubber commented Feb 5, 2022

Finish the DocumentationProvider Story (#11258)

Changes

When source is selected as DocumentationProvider, the original openapi spec is copied to the project and
is exposed via /openapi.{json,yaml}. Swagger-ui, if enabled, is configured to show this spec.

  • SpringCodegen now implements SwaggerUIFeatures. Use the useSwaggerUI parameter with the spring-boot library to use it. Swagger UI is enabled by default.
  • Upgrade swagger-ui to 4.4.1 including a customised swagger-ui.html
  • The SpringBootApplication class is renamed to OpenApiGeneratorApplication.java.
  • Introduce SpringBootTest.mustache as OpenApiGeneratorApplicationTests.java.
  • Remove option openapiDocketConfig. Replaced by documentationProvider=springfox.

Deprecation Warnings

  • springfox (documentationProvider): Springfox is deprecated for removal in version 7.0.0 of openapi-generator. The project seems to be no longer maintained (last commit is of Oct 14, 2020). It works with Spring Boot 2.5.x but not with 2.6. Spring Boot 2.5 is supported until 2022-05-19. Users of openapi-generator should migrate to the springdoc documentation provider which is, as an added bonus, OpenAPI v3 compatible.

Removals

  • spring-mvc (Library): The Spring MVC library is going to be removed in version 6.0.0 of openapi-generator. Users should upgrade to the Spring Boot based library. Since the library is based on dependencies which are declared EOL (spring-framework 4.x) and we have no plans to move it forward, it has to be removed for security and maintenance reasons.

Users who need to support Swagger1 Annotations (Annotate Model and Api using the Swagger Annotations 1.x library) could do so independently of Springfox using annotationLibrary=swagger1.

  • Shown in the command line help
  • Added to the generated documentation (spring.md)
  • Added to the generated README.md
  • Logged at WARNING level on each invocation.

PR checklist

  • [x ] Read the contribution guidelines.
  • [ x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • [ x] Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • [ x] File the PR against the correct branch: master (5.3.0), 6.0.x
  • [ x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@cachescrubber
Copy link
Contributor Author

re-open to trigger CI

@cachescrubber cachescrubber reopened this Feb 6, 2022
@cachescrubber
Copy link
Contributor Author

There is a new spring-boot sample, spring-boot-source.yaml. It has should be registered as a new CI build.

@cachescrubber
Copy link
Contributor Author

@wing328 , @welshm FYI

Copy link
Contributor

@welshm welshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor comment - I think that interface only is not exclusive to swagger-ui

# Conflicts:
#	modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/openapi2SpringBoot.mustache
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java
#	samples/server/petstore/java-camel/src/main/java/org/openapitools/OpenAPI2SpringBoot.java
#	samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES
#	samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java
#	samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/.openapi-generator/FILES
#	samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java
#	samples/server/petstore/springboot-spring-pageable-without-j8/.openapi-generator/FILES
#	samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java
@cachescrubber
Copy link
Contributor Author

@wing328 Could you remove the sprng-mvc samples from the CI configuration?

# Conflicts:
#	modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
@cachescrubber
Copy link
Contributor Author

Could you remove the sprng-mvc samples from the CI configuration?

I think I have done it with 87367b6. Please review.

Copy link
Contributor

@welshm welshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone requests the ability to generate the HTML with interfaces inky later, it's easy enough to reevaluate if that's a valid configuration we'd want to support.

Only other comment is about generating tests (I think there's a global generator property on whether or not tests should be output)

@wing328 wing328 changed the title Implement Source DocumentationProvider Implement Source DocumentationProvider, spring-mvc decomissino Feb 12, 2022
@wing328 wing328 changed the title Implement Source DocumentationProvider, spring-mvc decomissino Implement Source DocumentationProvider, spring-mvc decommission Feb 12, 2022
# Conflicts:
#	samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestHeadersApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java
…der' into feature/sourceDocumentationProvider
@cachescrubber
Copy link
Contributor Author

Circle-CI failures are not caused by this pr IMO.

@wing328
Copy link
Member

wing328 commented Feb 12, 2022

CircleCI failures not related to this PR.

@wing328 wing328 merged commit 0ed147e into OpenAPITools:master Feb 12, 2022
@cachescrubber cachescrubber deleted the feature/sourceDocumentationProvider branch February 12, 2022 10:01
@boardtc
Copy link

boardtc commented Jan 20, 2023

fyi, Moving from 5.0.0 to 6.3.0-SNAPSHOT.a s suggested I tried spring-boot, but it does not recognise that library unless generatorName is set to spring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants