gitmyhub

springdoc-openapi

Java ★ 3.7k updated 21d ago

Library for OpenAPI 3 with spring-boot

A Java library that automatically generates interactive API documentation for Spring Boot apps without any manual writing, just add one dependency and get a Swagger UI page and OpenAPI JSON at standard URLs.

JavaSpring BootMavenGradleSwagger UIOpenAPI 3setup: easycomplexity 2/5

springdoc-openapi is a Java library that automatically generates API documentation for Spring Boot applications. When you add it to a Spring Boot project, it inspects your application while it runs, reads the structure of your code and any annotations you have added, and produces a complete description of your API endpoints. You do not have to write the documentation manually.

The documentation it produces follows the OpenAPI 3 standard, which is a widely used format for describing REST APIs. The library outputs the documentation as a JSON or YAML file, and it also serves an interactive HTML page using Swagger UI. That page shows all your endpoints, what parameters they accept, what they return, and lets you make test requests directly from the browser. By default the HTML page appears at /swagger-ui.html and the raw JSON at /v3/api-docs.

Setting it up takes one step: add a single dependency to your Maven or Gradle build file and the library activates automatically. There is no required configuration, though optional properties let you move the documentation to a different URL path. It integrates with Spring Security and supports OAuth 2 flows, so authentication can be documented and tested through the Swagger UI as well. It also recognizes standard Java validation annotations like @NotNull and @Min to document input constraints.

Version 2 of the library targets Spring Boot 3 and Java 17. Version 1 covered Spring Boot 1 and 2, and extended paid support for version 1 is available beyond its 2023 end-of-life. The project is community-maintained and independent from the Spring Framework team at Pivotal. Sponsors include Mercedes-Benz and several other companies.

Where it fits