0Pricing
Spring Boot 4 Microservices & REST APIs · Lección

Swagger UI

Explore y pruebe API de forma interactiva

Swagger UI es una lección gratuita de Spring Boot 4 Microservices & REST APIs en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Spring Boot 4 Microservices & REST APIs, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Spring Boot 4 Microservices & REST APIs incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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

Preguntas frecuentes

¿La lección «Swagger UI» es gratis?

Sí — el texto completo de «Swagger UI» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Spring Boot 4 Microservices & REST APIs, actualiza a CoddyKit PRO. El curso de Spring Boot 4 Microservices & REST APIs incluye 4 lecciones en total.

¿Qué aprenderé en «Swagger UI»?

Explore y pruebe API de forma interactiva Practicas Spring Boot 4 Microservices & REST APIs con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Spring Boot 4 Microservices & REST APIs?

No se requiere experiencia previa. Spring Boot 4 Microservices & REST APIs en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Swagger UI»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Spring Boot 4 Microservices & REST APIs?

Sí. Cada lección de Spring Boot 4 Microservices & REST APIs incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Añadir SpringDoc a su proyecto
  2. Documentar endpoints y modelos
  3. Personalizar la especificación de OpenAPI
  4. Swagger UI
← Volver a Spring Boot 4 Microservices & REST APIs