Aggiungere SpringDoc al progetto
Generi automaticamente la documentazione OpenAPI.
Aggiungere SpringDoc al progetto è una lezione Spring Boot 4 Microservices & REST APIs gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Spring Boot 4 Microservices & REST APIs, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Spring Boot 4 Microservices & REST APIs include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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
Domande Frequenti
La lezione «Aggiungere SpringDoc al progetto» è gratuita?
Sì — il testo completo di «Aggiungere SpringDoc al progetto» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Spring Boot 4 Microservices & REST APIs, passa a CoddyKit PRO. Il corso Spring Boot 4 Microservices & REST APIs include 4 lezioni in totale.
Cosa imparerò in «Aggiungere SpringDoc al progetto»?
Generi automaticamente la documentazione OpenAPI. Eserciti Spring Boot 4 Microservices & REST APIs con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Spring Boot 4 Microservices & REST APIs?
Non è richiesta alcuna esperienza precedente. Spring Boot 4 Microservices & REST APIs su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.
Quanto tempo richiede la lezione «Aggiungere SpringDoc al progetto»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Spring Boot 4 Microservices & REST APIs?
Sì. Ogni lezione Spring Boot 4 Microservices & REST APIs include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Aggiungere SpringDoc al progetto
- Documentare endpoint e modelli
- Personalizzare la specifica OpenAPI
- Swagger UI