Learn / Frameworks / Spring Boot / OpenAPI with springdoc

Spring Boot · Lesson 11 of 15

OpenAPI with springdoc

Generate Swagger UI from your controllers and document security.

  • Intermediate
  • 14 min read
  • 3 objectives

Before this lessonLesson 10: Actuator, Health and Metrics

What you will learn

  • Add springdoc
  • Annotate operations
  • Show a Bearer scheme

Your Progress

0 of 15 lessons 0%

  • Lessons0 / 15
  • Completed0
  • Est. time left~ 4 hours

Create a free account to keep your progress on every device.

springdoc-openapi reads your controllers and produces Swagger UI at /swagger-ui.html.

Setup

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
@OpenAPIDefinition(info = @Info(title = "Tasks API", version = "1.0"))
@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT")
@RestController
class TaskController {
    @Operation(summary = "List tasks")
    @SecurityRequirement(name = "bearer")
    @GetMapping("/api/tasks")
    List<TaskDto> list() { ... }
}

Records used as request bodies show up as schemas automatically. Hide internal endpoints with @Hidden.

Up next · Lesson 12Uploads and SchedulingMultipart files, size limits and @Scheduled jobs.