Adding the dependency below gives access to the swagger ui.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>
But how to edit Swagger Title and etc using this dependency. In springfox it is possible using a docket bean. How is it possible in springdocs?
Trying to edit the swagger of Springdocs.
There are two to customize your openapi template.
There are in general two ways :
1- Through java code and creating a bean config :
First way, is by configure it through java code where you implement a bean, and write documentation about it, it would look like this but i don't recommend it:
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("Custom API Title")
.description("Custom API Description")
.version("1.0.0")
.contact(new Contact()
.name("API Support")
.url("http://example.com/contact")
.email("support@example.com"))
.license(new License()
.name("Apache 2.0")
.url("http://springdoc.org")))
.externalDocs(new ExternalDocumentation()
.description("Full Documentation")
.url("http://example.com/docs"));
}
}
2- yaml/properties config
Second way is to create template using springdoc-openapi
and create either yml or properties file with documentation about your openapi, then when your application is running you can see the documentation.
It would look like this :
springdoc:
api-docs:
path: /v3/api-docs
swagger-ui:
path: /swagger-ui.html
info:
title: Custom API Title
description: Custom API Description
version: 1.0.0
contact:
name: API Support
url: http://example.com/contact
email: support@example.com
license:
name: Apache 2.0
url: http://springdoc.org
external-docs:
description: Full Documentation
url: http://example.com/docs