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
- Adding SpringDoc to Your Project
- Documenting Endpoints and Models
- Customizing the OpenAPI Spec
- Swagger UI