0Pricing
Spring Boot 4 Microservices & REST APIs · レッスン

プロジェクトにSpringDocを追加する

OpenAPIドキュメントを自動生成します

「プロジェクトにSpringDocを追加する」はCoddyKit上の無料Spring Boot 4 Microservices & REST APIsレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSpring Boot 4 Microservices & REST APIs学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Spring Boot 4 Microservices & REST APIsコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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

よくある質問

「プロジェクトにSpringDocを追加する」レッスンは無料ですか?

はい。「プロジェクトにSpringDocを追加する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Spring Boot 4 Microservices & REST APIsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Spring Boot 4 Microservices & REST APIsコースには全4レッスンが含まれています。

「プロジェクトにSpringDocを追加する」で何を学びますか?

OpenAPIドキュメントを自動生成します ブラウザで直接実行するハンズオンコードでSpring Boot 4 Microservices & REST APIsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Spring Boot 4 Microservices & REST APIsを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのSpring Boot 4 Microservices & REST APIsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「プロジェクトにSpringDocを追加する」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このSpring Boot 4 Microservices & REST APIsレッスンでコードを書いて実行できますか?

はい。すべてのSpring Boot 4 Microservices & REST APIsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. プロジェクトにSpringDocを追加する
  2. エンドポイントとモデルをドキュメント化する
  3. OpenAPI仕様をカスタマイズする
  4. Swagger UI
← Spring Boot 4 Microservices & REST APIsに戻る