7

There are 2 ways to add OpenAPI 3 to a Spring Boot project.

  • <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    

https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/

  • <groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    

https://medium.com/@hala3k/setting-up-swagger-3-with-spring-boot-2-a7c1c3151545

There are also migration issues for configuration and annotations.

The question is: are there any reasons to make a choice between them for a Spring Boot project?

UPDATE: make the migration to OpenAPI 3. Not too hard :) Maybe it will be helpful:

OpenApiConfig, pom.xml, Описание

Paulo Merson
  • 13,270
  • 8
  • 79
  • 72
Grigory Kislin
  • 16,647
  • 10
  • 125
  • 197
  • `springdoc` is a more manageable project. You will get the query support if you posted the query over Github – SSK Dec 21 '20 at 04:49

1 Answers1

7

There's an obvious reason for choosing Springdoc over Springfox in this case. The reason being, springdoc-openapi-ui is a standalone library while springfox-boot-starter pulls in the Spring dependencies transitively. Having taken a look at what the POM looks like, Springfox has a wrapper for many of the Spring projects. Also for the Swagger UI, you need an extra dependency for Springfox.

Thus using Springdoc gives you more control over Swagger integration which is optional, in case you would like to go for a static documentation framework like Spring REST Docs

As far as the migration guide mentioned is concerned, it's for migrating Springfox 2.x projects to Springdoc. Springdoc supports OpenAPI 3.x and not 2.x, while Springfox supports both versions of the specification.

Debargha Roy
  • 2,320
  • 1
  • 15
  • 34
  • What's the point to use Springdoc (Open API 3) without Swagger? – Blocked Dec 23 '22 at 20:23
  • 2
    Guess you're mislead by the phrase `Springdoc gives you more control over Swagger integration which is optional`. Meant to say, if you want Swagger with Spring you add Springdoc. If you don't want Swagger, you continue to use Spring on its own. Unlike Springfox where every Spring dependency is present transitively. On a side note, you can use Springdoc to generate the OpenAPI specification file and use the file directly for custom documentation, i.e., not using Swagger but using Springdoc. – Debargha Roy Dec 24 '22 at 06:55