0Pricing
Spring Boot 4 Microservices & REST APIs · Aula

Adicionando SpringDoc ao seu projeto

Gere documentação OpenAPI automaticamente.

Adicionando SpringDoc ao seu projeto é uma aula grátis de Spring Boot 4 Microservices & REST APIs no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Spring Boot 4 Microservices & REST APIs, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Spring Boot 4 Microservices & REST APIs inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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

Perguntas Frequentes

A aula “Adicionando SpringDoc ao seu projeto” é grátis?

Sim — o texto completo de “Adicionando SpringDoc ao seu projeto” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Spring Boot 4 Microservices & REST APIs, atualize para CoddyKit PRO. O curso de Spring Boot 4 Microservices & REST APIs inclui 4 aulas no total.

O que vou aprender em “Adicionando SpringDoc ao seu projeto”?

Gere documentação OpenAPI automaticamente. Você pratica Spring Boot 4 Microservices & REST APIs com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Spring Boot 4 Microservices & REST APIs?

Nenhuma experiência prévia é necessária. Spring Boot 4 Microservices & REST APIs no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Adicionando SpringDoc ao seu projeto”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Spring Boot 4 Microservices & REST APIs?

Sim. Cada aula de Spring Boot 4 Microservices & REST APIs inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Adicionando SpringDoc ao seu projeto
  2. Documentando endpoints e modelos
  3. Personalizando a especificação OpenAPI
  4. Swagger UI
← Voltar para Spring Boot 4 Microservices & REST APIs