Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Library for OpenAPI 3 with spring-boot

License

NotificationsYou must be signed in to change notification settings

springdoc/springdoc-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

OctocatBuild StatusQuality GateKnown VulnerabilitiesStack Exchange questions

IMPORTANT:springdoc-openapi v1.8.0 is the latest Open Source release supporting Spring Boot 2.x and 1.x.

An extended support forspringdoc-openapi v1project is now available for organizations that need support beyond 2023.

For more details, feel free to reach out:sales@springdoc.org

springdoc-openapi is onOpen Collective. If you ❤️ this project consider becoming asponsor.

This project is sponsored by

  

Table of Contents

Introduction

The springdoc-openapi Java library helps automating the generation of API documentationusing Spring Boot projects.springdoc-openapi works by examining an application at runtime to infer API semanticsbased on Spring configurations, class structure and various annotations.

The library automatically generates documentation in JSON/YAML and HTML formatted pages.The generated documentation can be complemented usingswagger-api annotations.

This library supports:

  • OpenAPI 3
  • Spring-boot v3 (Java 17 & Jakarta EE 9)
  • JSR-303, specifically for @NotNull, @Min, @Max, and @Size.
  • Swagger-ui
  • OAuth 2
  • GraalVM native images

The following video introduces the Library:

Forspring-boot v3 support, make sure you usespringdoc-openapi v2

This is a community-based project, not maintained by the Spring Framework Contributors (Pivotal)

Getting Started

Library for springdoc-openapi integration with spring-boot and swagger-ui

  • Automatically deploys swagger-ui to a Spring Boot 3.x application
  • Documentation will be available in HTML format, using theofficialswagger-ui jars.
  • The Swagger UI page should then be available athttp://server:port/context-path/swagger-ui.html and the OpenAPI description will be available at thefollowing url for json format:http://server:port/context-path/v3/api-docs
    • server: The server name or IP
    • port: The server port
    • context-path: The context path of the application
  • Documentation can be available in yaml format as well, on the following path:/v3/api-docs.yaml
  • Add thespringdoc-openapi-ui library to the list of your project dependencies (Noadditional configuration is needed):

Maven

   <dependency>      <groupId>org.springdoc</groupId>      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>      <version>last-release-version</version>   </dependency>

Gradle

implementation'org.springdoc:springdoc-openapi-starter-webmvc-ui:latest'
  • This step is optional: For custom path of the swagger documentation in HTML format, adda custom springdoc property, in your spring-boot configuration file:
# swagger-ui custom pathspringdoc.swagger-ui.path=/swagger-ui.html

Spring-boot with OpenAPI Demo applications.

Branching

Integration of the library in a Spring Boot 3.x project without the swagger-ui:

  • Documentation will be available at the following url for json format:http://server:port/context-path/v3/api-docs
    • server: The server name or IP
    • port: The server port
    • context-path: The context path of the application
  • Documentation will be available in yaml format as well, on the followingpath :/v3/api-docs.yaml
  • Add the library to the list of your project dependencies. (No additional configurationis needed)

Maven

   <dependency>      <groupId>org.springdoc</groupId>      <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>      <version>last-release-version</version>   </dependency>

Gradle

implementation'org.springdoc:springdoc-openapi-starter-webmvc-ui:latest'
  • This step is optional: For custom path of the OpenAPI documentation in Json format, adda custom springdoc property, in your spring-boot configuration file:
# /api-docs endpoint custom pathspringdoc.api-docs.path=/api-docs
  • This step is optional: If you want to disablespringdoc-openapi endpoints, add acustom springdoc property, in yourspring-boot configuration file:
# disable api-docsspringdoc.api-docs.enabled=false

Error Handling for REST using @ControllerAdvice

To generate documentation automatically, make sure all the methods declare the HTTP Coderesponses using the annotation: @ResponseStatus.

Adding API Information and Security documentation

The library uses spring-boot application auto-configured packages to scan for thefollowing annotations in spring beans: OpenAPIDefinition and Info.These annotations declare, API Information: Title, version, licence, security, servers,tags, security and externalDocs.For better performance of documentation generation, declare@OpenAPIDefinitionand@SecurityScheme annotations within a Spring managed bean.

spring-webflux support with Annotated Controllers

  • Documentation can be available in yaml format as well, on the following path :/v3/api-docs.yaml
  • Add the library to the list of your project dependencies (No additional configurationis needed)

Maven

   <dependency>      <groupId>org.springdoc</groupId>      <artifactId>springdoc-openapi-starter-webflux-ui</artifactId>      <version>last-release-version</version>   </dependency>

Gradle

implementation'org.springdoc:springdoc-openapi-starter-webmvc-ui:latest'
  • This step is optional: For custom path of the swagger documentation in HTML format, adda custom springdoc property, in your spring-boot configuration file:
# swagger-ui custom pathspringdoc.swagger-ui.path=/swagger-ui.html

Thespringdoc-openapi libraries are hosted on maven central repository.The artifacts can be viewed accessed at the following locations:

Releases:

Snapshots:

Acknowledgements

Contributors

springdoc-openapi is relevant and updated regularly due to the valuable contributions fromitscontributors.

Thanks you all for your support!

Additional Support

  • Spring Team - Thanks for their support by sharing all relevantresources around Spring projects.
  • JetBrains - Thanks a lot forsupporting springdoc-openapi project.

JenBrains logo


[8]ページ先頭

©2009-2025 Movatter.jp