0Pricing
Spring Boot 4 Microservices & REST APIs · Lekcja

Swagger UI

Interaktywnie poznawaj i testuj API

Swagger UI to bezpłatna lekcja Spring Boot 4 Microservices & REST APIs na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Spring Boot 4 Microservices & REST APIs, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Spring Boot 4 Microservices & REST APIs zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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.html

Try 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: /docs

Sorting 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: alpha

Trying 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: true

Display 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: true

Securing 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

Często zadawane pytania

Czy lekcja „Swagger UI” jest bezpłatna?

Tak — pełny tekst „Swagger UI” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Spring Boot 4 Microservices & REST APIs, przejdź na CoddyKit PRO. Kurs Spring Boot 4 Microservices & REST APIs zawiera 4 lekcji w sumie.

Co nauczysz się w „Swagger UI”?

Interaktywnie poznawaj i testuj API Ćwiczysz Spring Boot 4 Microservices & REST APIs z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Spring Boot 4 Microservices & REST APIs?

Nie wymagamy żadnego doświadczenia. Spring Boot 4 Microservices & REST APIs w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Swagger UI”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Spring Boot 4 Microservices & REST APIs?

Tak. Każda lekcja Spring Boot 4 Microservices & REST APIs zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Dodawanie SpringDoc do projektu
  2. Dokumentowanie endpointów i modeli
  3. Dostosowywanie specyfikacji OpenAPI
  4. Swagger UI
← Powrót do Spring Boot 4 Microservices & REST APIs