OpenAPI-Swagger
The OpenAPI Specification, previously known as the Swagger Specification, defines a standard, language-agnostic interface to HTTP APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.
To add OpenAPI-Swagger to your project, you just need to add the following Maven (springdoc-openapi) Dependency
// pom.xml .. <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.0.2</version> </dependency> ..
After running your project, you can access the created API documentation using the following link
http://localhost:8080/swagger-ui/4.15.5/index.html
If you want to add more specialized information to the API documentation, you can use the following Bean and modify the OpenAPI information to fit the description of your project.
@SpringBootApplication public class Week4Application { public static void main(String[] args) { SpringApplication.run(Week4Application.class, args); } @Bean public OpenAPI springShopOpenAPI() { return new OpenAPI() .info(new Info().title("Products - Orders API") .description("Products - Orders API") .version("v0.0.1") .license(new License().name("Apache 2.0").url("http://springdoc.org"))) .externalDocs(new ExternalDocumentation() .description("Products - Orders Documentation") .url("http://localhost:8080/swagger-ui/4.15.5/index.html")); } }