Swagger UI
Esplori e testi le API in modo interattivo.
Swagger UI è una lezione Spring Boot 4 Microservices & REST APIs gratuita su CoddyKit. Questa è la lezione 4 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.
What is Swagger UI?
Swagger UI renders your OpenAPI spec as an interactive web page. Developers can browse endpoints, read schemas, and send live requests - all from the browser.
Where it lives
With the -ui starter, Swagger UI is served at /swagger-ui.html by default. It loads the spec from /v3/api-docs.
// open in a browser:
// http://localhost:8080/swagger-ui.htmlTry it out
Each operation has a Try it out button. You fill in parameters and body, click Execute, and the UI shows the real request URL, response status, headers and body.
Reading the schema view
The Schemas section at the bottom lists every model with field types, descriptions and examples taken from your @Schema annotations.
Changing the UI path
Relocate the UI with a property - useful when serving docs under a custom route.
# application.yml
springdoc:
swagger-ui:
path: /docsSorting endpoints and tags
By default operations appear in an unsorted order. Properties let you sort operations and tags alphabetically for a cleaner page.
springdoc:
swagger-ui:
operations-sorter: alpha
tags-sorter: alphaTrying secured endpoints
If you declared a security scheme, the UI shows an Authorize button. Enter a token once and it is attached to every secured request you try.
Filtering operations
Enable a search box to filter the long list of endpoints by name, which helps in large APIs.
springdoc:
swagger-ui:
filter: trueDisplay options
You can control how much is expanded by default and whether request duration is shown, tuning the UI for your team's taste.
springdoc:
swagger-ui:
doc-expansion: none # collapse all by default
display-request-duration: trueSecuring the UI itself
Swagger UI exposes your API surface. In production, protect /swagger-ui/** and /v3/api-docs/** with Spring Security, or disable them, so they are not publicly browsable.
// permit only authenticated users
http.authorizeHttpRequests(a -> a
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**").authenticated()
.anyRequest().permitAll());UI vs spec - division of labor
Remember: Swagger UI is just a viewer. The source of truth is the OpenAPI spec generated from your code and annotations. Improve the docs by improving annotations, not the UI.
Quick Check
Confirm your Swagger UI knowledge.
Recap
You explored Swagger UI:
- Served at
/swagger-ui.html, backed by/v3/api-docs - Try it out sends live requests; Authorize adds tokens
- Sort, filter and expansion are configurable via properties
- Protect or disable the UI in production
Domande Frequenti
La lezione «Swagger UI» è gratuita?
Sì — il testo completo di «Swagger UI» è 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 «Swagger UI»?
Esplori e testi le API in modo interattivo. 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 4 di 4.
Quanto tempo richiede la lezione «Swagger UI»?
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