0Pricing
Spring Boot 4 Microservices & REST APIs · Pelajaran

Menambahkan SpringDoc ke Proyek Anda

Buat dokumentasi OpenAPI secara otomatis.

Menambahkan SpringDoc ke Proyek Anda adalah pelajaran Spring Boot 4 Microservices & REST APIs gratis di CoddyKit. Ini adalah pelajaran 1 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Spring Boot 4 Microservices & REST APIs, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Spring Boot 4 Microservices & REST APIs mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

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

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Menambahkan SpringDoc ke Proyek Anda” gratis?

Ya — teks lengkap “Menambahkan SpringDoc ke Proyek Anda” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Spring Boot 4 Microservices & REST APIs, upgrade ke CoddyKit PRO. Kursus Spring Boot 4 Microservices & REST APIs mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Menambahkan SpringDoc ke Proyek Anda”?

Buat dokumentasi OpenAPI secara otomatis. Kamu berlatih Spring Boot 4 Microservices & REST APIs dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Spring Boot 4 Microservices & REST APIs?

Tidak diperlukan pengalaman sebelumnya. Spring Boot 4 Microservices & REST APIs di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 1 dari 4.

Berapa lama pelajaran “Menambahkan SpringDoc ke Proyek Anda” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Spring Boot 4 Microservices & REST APIs ini?

Ya. Setiap pelajaran Spring Boot 4 Microservices & REST APIs menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Menambahkan SpringDoc ke Proyek Anda
  2. Mendokumentasikan Endpoint dan Model
  3. Menyesuaikan Spesifikasi OpenAPI
  4. Antarmuka Pengguna Swagger
← Kembali ke Spring Boot 4 Microservices & REST APIs