Adding SpringDoc to Your Project
Generate OpenAPI docs automatically.
Adding SpringDoc to Your Project is a free Spring Boot 4 Microservices & REST APIs lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Spring Boot 4 Microservices & REST APIs learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why document your API?
An API without docs is hard to consume. OpenAPI (formerly Swagger) is a standard, machine-readable description of your REST API that powers interactive docs, client generation and contract testing.
What SpringDoc does
SpringDoc OpenAPI inspects your Spring controllers at runtime and generates the OpenAPI spec automatically - no hand-written YAML needed.
- Reads your
@RestControllermappings - Serves the spec and a Swagger UI
Adding the starter (Maven)
Add the springdoc-openapi-starter-webmvc-ui dependency. The -ui variant bundles Swagger UI as well as the JSON spec.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>Adding the starter (Gradle)
The Gradle coordinates are the same artifact.
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0"WebMVC vs WebFlux
Pick the starter matching your stack:
- Servlet apps ->
springdoc-openapi-starter-webmvc-ui - Reactive apps ->
springdoc-openapi-starter-webflux-ui
Zero config to start
With just the dependency, start the app and SpringDoc auto-configures everything. You immediately get the generated spec and UI without writing any code.
The generated JSON endpoint
The raw OpenAPI document is served at /v3/api-docs by default. This JSON can feed code generators, Postman, or API gateways.
// GET http://localhost:8080/v3/api-docs
// returns the full OpenAPI 3 JSON documentThe Swagger UI endpoint
The interactive UI is at /swagger-ui.html. It lists every endpoint and lets you try requests in the browser.
// open http://localhost:8080/swagger-ui.htmlChanging the default paths
You can relocate the spec and UI via properties, useful behind a gateway or to avoid collisions.
# application.yml
springdoc:
api-docs:
path: /api-docs
swagger-ui:
path: /docs.htmlWhat gets detected automatically
SpringDoc infers a lot with no annotations: paths, HTTP methods, path/query params, request and response body schemas from your DTO classes, and response status codes.
Disabling in production (optional)
Some teams expose docs only in non-prod. Toggle with properties so the spec and UI are not served in production.
# disable everywhere
springdoc:
api-docs:
enabled: false
swagger-ui:
enabled: falseQuick Check
Confirm the basics of adding SpringDoc.
Recap
You bootstrapped API docs:
- SpringDoc generates the OpenAPI spec from your controllers
- Add
springdoc-openapi-starter-webmvc-ui(or webflux) - Spec at
/v3/api-docs, UI at/swagger-ui.html - Paths and enablement are configurable via properties
Frequently asked questions
Is the “Adding SpringDoc to Your Project” lesson free?
Yes — the full text of “Adding SpringDoc to Your Project” is free to read here on the web, and the Spring Boot 4 Microservices & REST APIs course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Spring Boot 4 Microservices & REST APIs course, upgrade to CoddyKit PRO.
What will I learn in “Adding SpringDoc to Your Project”?
Generate OpenAPI docs automatically. You practise Spring Boot 4 Microservices & REST APIs with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Spring Boot 4 Microservices & REST APIs?
No prior experience is required. Spring Boot 4 Microservices & REST APIs on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Adding SpringDoc to Your Project” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Spring Boot 4 Microservices & REST APIs lesson?
Yes. Every Spring Boot 4 Microservices & REST APIs lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Adding SpringDoc to Your Project
- Documenting Endpoints and Models
- Customizing the OpenAPI Spec
- Swagger UI