|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +--- |
| 4 | + |
| 5 | + |
| 6 | +# **Introduction** |
| 7 | + |
| 8 | +springdoc-openapi java library helps automating the generation of API documentation using spring boot projects. |
| 9 | +springdoc-openapi works by examining an application at runtime to infer API semantics based on spring configurations, class structure and various annotations. |
| 10 | + |
| 11 | +Automatically generates documentation in JSON/YAML and HTML format APIs. |
| 12 | +This documentation can be completed by comments using swagger-api annotations. |
| 13 | + |
| 14 | +This library supports: |
| 15 | +* OpenAPI 3 |
| 16 | +* Spring-boot (v1 and v2) |
| 17 | +* JSR-303, specifically for @NotNull, @Min, @Max, and @Size. |
| 18 | +* Swagger-ui |
| 19 | +* Oauth 2 |
| 20 | + |
| 21 | +# **Getting Started** |
| 22 | + |
| 23 | +## Library for springdoc-openapi integration with spring-boot and swagger-ui |
| 24 | +* Automatically deploys swagger-ui to a spring-boot 2 application |
| 25 | +* Documentation will be available in HTML format, using the official [swagger-ui jars]: (https://github.com/swagger-api/swagger-ui.git). |
| 26 | +* The Swagger UI page should then be available at http://server:port/context-path/swagger-ui.html and the OpenAPI description will be available at the following url for json format: http://server:port/context-path/v3/api-docs |
| 27 | + * server: The server name or IP |
| 28 | + * port: The server port |
| 29 | + * context-path: The context path of the application |
| 30 | +* Documentation can be available in yaml format as well, on the following path : /v3/api-docs.yml |
| 31 | +* Add the library to the list of your project dependencies (No additional configuration is needed) |
| 32 | + |
| 33 | +```xml |
| 34 | + <dependency> |
| 35 | + <groupId>org.springdoc</groupId> |
| 36 | + <artifactId>springdoc-openapi-ui</artifactId> |
| 37 | + <version>@springdoc.version@</version> |
| 38 | + </dependency> |
| 39 | +``` |
| 40 | +* This step is optional: For custom path of the swagger documentation in HTML format, add a custom springdoc property, in your spring-boot configuration file: |
| 41 | + |
| 42 | +```properties |
| 43 | +# swagger-ui custom path |
| 44 | +springdoc.swagger-ui.path=/swagger-ui.html |
| 45 | +``` |
| 46 | + |
| 47 | +## [Demo application 1](https://springdoc-openapi-test-app2-silly-numbat.eu-de.mybluemix.net/). |
| 48 | +## [Demo application 2](https://springdoc-openapi-test-app1-courteous-puku.eu-de.mybluemix.net/). |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +## Source code of the Demo Applications |
| 53 | +* https://github.com/springdoc/springdoc-openapi-demos.git |
| 54 | + |
| 55 | +## Integration of the libray in a spring-boot 2 project without the swagger-ui: |
| 56 | +* Documentation will be available at the following url for json format: http://server:port/context-path/v3/api-docs |
| 57 | + * server: The server name or IP |
| 58 | + * port: The server port |
| 59 | + * context-path: The context path of the application |
| 60 | +* Documentation will be available in yaml format as well, on the following path : /v3/api-docs.yml |
| 61 | +* Add the library to the list of your project dependencies. (No additional configuration is needed) |
| 62 | + |
| 63 | +```xml |
| 64 | + <dependency> |
| 65 | + <groupId>org.springdoc</groupId> |
| 66 | + <artifactId>springdoc-openapi-core</artifactId> |
| 67 | + <version>@springdoc.version@</version> |
| 68 | + </dependency> |
| 69 | +``` |
| 70 | +* This step is optional: For custom path of the OpenAPI documentation in Json format, add a custom springdoc property, in your spring-boot configuration file: |
| 71 | + |
| 72 | +```properties |
| 73 | +# /api-docs endpoint custom path |
| 74 | +springdoc.api-docs.path=/api-docs |
| 75 | +``` |
| 76 | + |
| 77 | +## Adding API Information documentation |
| 78 | + The library uses spring-boot application auto-configured packages to scan for the following annotations in spring beans: OpenAPIDefinition and Info. |
| 79 | + These annotations declare, API Information: Title, version, licence, security, servers, tags, security and externalDocs |
| 80 | + |
| 81 | +## Error Handling for REST using @ControllerAdvice |
| 82 | +To generate documentation automatically, make sure all the methods declare the HTTP Code responses using the annotation: @ResponseStatus |
| 83 | + |
| 84 | +## spring-weblfux support with Annotated Controllers |
| 85 | +* Documentation can be available in yaml format as well, on the following path : /v3/api-docs.yml |
| 86 | +* Add the library to the list of your project dependencies (No additional configuration is needed) |
| 87 | + |
| 88 | +```xml |
| 89 | + <dependency> |
| 90 | + <groupId>org.springdoc</groupId> |
| 91 | + <artifactId>springdoc-openapi-webflux-ui</artifactId> |
| 92 | + <version>@springdoc.version@</version> |
| 93 | + </dependency> |
| 94 | +``` |
| 95 | +* This step is optional: For custom path of the swagger documentation in HTML format, add a custom springdoc property, in your spring-boot configuration file: |
| 96 | + |
| 97 | +```properties |
| 98 | +# swagger-ui custom path |
| 99 | +springdoc.swagger-ui.path=/swagger-ui.html |
| 100 | +``` |
| 101 | + |
| 102 | +## spring-weblfux with Functional Endpoints, will be available in the future release |
| 103 | +## Dependencies repository |
| 104 | + |
| 105 | +The springdoc-openapi libraries are hosted on maven central repository. |
| 106 | +The artifacts can be viewed accessed at the following locations: |
| 107 | + |
| 108 | +Releases: |
| 109 | +* [https://oss.sonatype.org/content/groups/public/org/springdoc/](https://oss.sonatype.org/content/groups/public/org/springdoc/). |
| 110 | + |
| 111 | +Snapshots: |
| 112 | +* [https://oss.sonatype.org/content/repositories/snapshots/org/springdoc/](https://oss.sonatype.org/content/repositories/snapshots/org/springdoc/). |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
0 commit comments