Añadir SpringDoc a su proyecto
Genere documentación de OpenAPI automáticamente
Añadir SpringDoc a su proyecto es una lección gratuita de Spring Boot 4 Microservices & REST APIs en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Spring Boot 4 Microservices & REST APIs, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Spring Boot 4 Microservices & REST APIs incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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
Preguntas frecuentes
¿La lección «Añadir SpringDoc a su proyecto» es gratis?
Sí — el texto completo de «Añadir SpringDoc a su proyecto» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Spring Boot 4 Microservices & REST APIs, actualiza a CoddyKit PRO. El curso de Spring Boot 4 Microservices & REST APIs incluye 4 lecciones en total.
¿Qué aprenderé en «Añadir SpringDoc a su proyecto»?
Genere documentación de OpenAPI automáticamente Practicas Spring Boot 4 Microservices & REST APIs con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Spring Boot 4 Microservices & REST APIs?
No se requiere experiencia previa. Spring Boot 4 Microservices & REST APIs en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.
¿Cuánto tiempo toma la lección «Añadir SpringDoc a su proyecto»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Spring Boot 4 Microservices & REST APIs?
Sí. Cada lección de Spring Boot 4 Microservices & REST APIs incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Añadir SpringDoc a su proyecto
- Documentar endpoints y modelos
- Personalizar la especificación de OpenAPI
- Swagger UI