What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a Spring MVC application, add the springdoc-openapi UI starter to generate OpenAPI 3 documentation and provide Swagger UI. The usual endpoints are /swagger-ui.html for the interactive interface, /v3/api-docs for JSON, and /v3/api-docs.yaml for YAML. If Spring Security protects the application, configure access to those documentation paths explicitly.

Choose the springdoc starter for your application

springdoc-openapi generates API documentation by inspecting the running Spring application’s configuration, classes, and annotations. For Spring MVC, choose the starter according to whether people need the interactive interface as well as the machine-readable specification.

Application and need Dependency What it provides
Spring MVC with Swagger UI org.springdoc:springdoc-openapi-starter-webmvc-ui OpenAPI output and interactive Swagger UI. The basic integration requires no additional configuration, according to the springdoc getting-started guide.
Spring MVC, API output only org.springdoc:springdoc-openapi-starter-webmvc-api Machine-readable OpenAPI endpoints without the UI starter. See the springdoc project documentation.
Reactive Spring WebFlux application Use the corresponding springdoc WebFlux starter WebFlux variants are documented by the springdoc project; choose the variant matching the application rather than an MVC starter.

Match the springdoc line to Spring Boot

Spring Boot 3.x is covered by springdoc-openapi’s v2 documentation track. The guide gives 2.9.1 as an example version for springdoc-openapi-starter-webmvc-ui; it is an example, not a guarantee that this is the newest release. Check the project’s current documentation and compatibility information before pinning a version: springdoc v2 documentation.

Add the dependency and open the documentation

In a Spring MVC project using Maven, add the UI starter as a dependency, selecting a version compatible with your Spring Boot generation. The project’s guide describes the basic integration as requiring no further configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
  <version>2.9.1</version>
</dependency>

Here, 2.9.1 is the example version listed in the springdoc v2 guide, not a recommendation that it will remain current. After starting the application, use the paths below, replacing the host and port with those used by your deployment:

Purpose Path Output
Swagger UI entry point /swagger-ui.html Interactive documentation in a browser
OpenAPI document /v3/api-docs JSON
OpenAPI document /v3/api-docs.yaml YAML

These paths are relative to the application’s context path. For example, if the app runs under a context path, prepend it to each path. The endpoint locations are documented in the getting-started guide.

Improve the generated specification with metadata

Automatic discovery gives you a generated starting point; annotations let you supply API information that cannot be reliably inferred from application code. Use @OpenAPIDefinition for API-level metadata such as title, version, license, servers, tags, and external documentation. Use @SecurityScheme to describe an authentication scheme. The project recommends placing these annotations in a Spring-managed bean for better documentation-generation performance. See the springdoc annotations documentation.

springdoc also documents support for OpenAPI 3, Swagger UI, OAuth 2, selected JSR-303 validation annotations (@NotNull, @Min, @Max, and @Size), and GraalVM native images. Validation annotations can contribute useful schema information, but the supported set named here is limited to those listed by the project documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Allow documentation through Spring Security when appropriate

If Spring Security is enabled, a request to /v3/api-docs may return 401 because the security filter chain requires authentication. If your policy is to make the documentation public, permit the documentation paths in your SecurityFilterChain and retain the application’s intended protections for other routes.

http.authorizeHttpRequests(authorize -> authorize
    .requestMatchers(
        "/v3/api-docs/**",
        "/v3/api-docs.yaml",
        "/swagger-ui/**",
        "/swagger-ui.html"
    ).permitAll()
    .anyRequest().authenticated()
);

This is an authorization example, not a requirement to expose documentation publicly. If your API documentation should remain private, require authentication for these routes instead. The paths to account for in the security configuration are listed in the springdoc Spring Security guidance.

Troubleshoot missing or inaccessible documentation

  • Swagger UI is unavailable: Confirm you added the MVC UI starter, not the API-only starter, and open /swagger-ui.html under the application context path.
  • /v3/api-docs returns 401: Check whether Spring Security requires authentication. Decide whether docs should be public or protected, then configure the documentation routes accordingly.
  • The endpoints return 404: Verify that the application is running, the correct starter matches MVC or WebFlux, and you are including any context path in the URL.
  • Dependency compatibility is uncertain: Match the springdoc major documentation line to the Spring Boot generation; Spring Boot 3.x uses the v2 line. Verify the specific release rather than assuming the example version is current.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.