0PricingLogin
Spring Boot 4 Microservices & REST APIs · Lesson

Customizing the OpenAPI Spec

Add metadata, servers, and security schemes.

Customizing the whole spec

Beyond per-endpoint annotations, you can shape the entire document - title, version, contact, license, servers and security - by defining an OpenAPI bean.

Defining an OpenAPI bean

Return an OpenAPI object from a @Bean method and SpringDoc uses it as the base document.

@Bean
public OpenAPI customOpenAPI() {
    return new OpenAPI()
            .info(new Info()
                .title("Orders API")
                .version("v1")
                .description("Public ordering service"));
}

All lessons in this course

  1. Adding SpringDoc to Your Project
  2. Documenting Endpoints and Models
  3. Customizing the OpenAPI Spec
  4. Swagger UI
← Back to Spring Boot 4 Microservices & REST APIs