Swagger UI
APIを対話的に確認・テストします
「Swagger UI」はCoddyKit上の無料Spring Boot 4 Microservices & REST APIsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSpring Boot 4 Microservices & REST APIs学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Spring Boot 4 Microservices & REST APIsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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
よくある質問
「Swagger UI」レッスンは無料ですか?
はい。「Swagger UI」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Spring Boot 4 Microservices & REST APIsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Spring Boot 4 Microservices & REST APIsコースには全4レッスンが含まれています。
「Swagger UI」で何を学びますか?
APIを対話的に確認・テストします ブラウザで直接実行するハンズオンコードでSpring Boot 4 Microservices & REST APIsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Spring Boot 4 Microservices & REST APIsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのSpring Boot 4 Microservices & REST APIsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「Swagger UI」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このSpring Boot 4 Microservices & REST APIsレッスンでコードを書いて実行できますか?
はい。すべてのSpring Boot 4 Microservices & REST APIsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。