0Pricing
Spring Boot 4 Microservices & REST APIs · Lekcja

Dodawanie SpringDoc do projektu

Automatycznie generuj dokumentację OpenAPI

Dodawanie SpringDoc do projektu to bezpłatna lekcja Spring Boot 4 Microservices & REST APIs na CoddyKit. To lekcja 1 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.

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 @RestController mappings
  • 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 document

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

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

What 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: false

Quick 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

Często zadawane pytania

Czy lekcja „Dodawanie SpringDoc do projektu” jest bezpłatna?

Tak — pełny tekst „Dodawanie SpringDoc do projektu” 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 „Dodawanie SpringDoc do projektu”?

Automatycznie generuj dokumentację OpenAPI Ć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 1 z 4.

Ile czasu zajmuje lekcja „Dodawanie SpringDoc do projektu”?

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