[online] Replace springfox with springdoc

Merged
CH
1d ago
+199-156

Replace springfox 3.0.0 with springdoc-openapi 1.8.0 in openapi-generator-online.

springfox is unmaintained (last release July 2020) and only works on Spring Boot 2.6+ with the ant-path-matcher workaround added in #25731. springdoc 1.8.0 is springdoc's Spring Boot 2 line.

Changes

  • The springfox Docket becomes an OpenAPI bean, and the Swagger 1 annotations become OpenAPI 3 ones.
  • The ant-path-matcher workaround and ParameterAllowableValuesPlugin (which had no visible effect) are removed.
  • GENERATOR_HOST becomes the server URL, without trailing slashes.
  • New test for /api-docs.

What changes for users

  • /api-docs is OpenAPI 3.0.1 instead of Swagger 2.0, with the same operations and models.
  • springfox's /swagger-resources endpoints are gone, and URLs with a doubled slash return 404.
  • -Dspringfox.documentation.swagger.v2.host no longer applies; use GENERATOR_HOST.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Replaces springfox with springdoc-openapi in openapi-generator-online so /api-docs now serves an OpenAPI 3.0.1 document instead of Swagger 2.0, with the same seven operations, tags, models, and alphabetical path order.

User-facing changes

  • springfox's /swagger-resources endpoints are gone, and URLs with a doubled slash return 404.
  • -Dspringfox.documentation.swagger.v2.host no longer applies; use GENERATOR_HOST.

Implementation notes

  • Swagger 1 annotations are replaced with OpenAPI 3 annotations, including documenting the free-form spec field as an object.
  • The ant-path-matcher workaround and the ParameterAllowableValuesPlugin are removed.
  • GENERATOR_HOST becomes the server URL, without trailing slashes; unparseable values are logged and ignored.
  • Without GENERATOR_HOST, the server URL from the request drops an http scheme.
  • springdoc's swagger-core is excluded so the generator keeps the version its swagger-parser needs.
  • Added a test for /api-docs to verify the API description and server URL handling.