I intend to modify the title and description. The method I discovered through online search involves using ApiInfoBuilder() to construct an ApiInfo, which is then passed to the Docket object. Despite my attempts with numerous samples and variations, none of them have proven effective in my case. My code is pretty straightforward
@Configuration
@ComponentScan
@EnableSwagger2
ApiInfo apiInfo =
new ApiInfoBuilder()
.title("Demo Test API")
.description("Demo test API task")
.license("© 2021 by my")
.build();
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo)
.select()
.apis(RequestHandlerSelectors.basePackage("my.pachage.com"))
.paths(PathSelectors.any())
.build();
I'm using 3.0.0 version.
No matter which ApiInfoBuilder parameters gets, the title on the Swagger page remains unaffected.
Please advice, what I'm missing here.
You are using Swagger 3 (OpenAPI) but trying to configure Swagger 2.
To configure OpenAPI you need to provide OpenAPI
bean:
@Configuration
public class SwaggerConfiguration {
@Bean
OpenAPI api() {
return new OpenAPI()
.info(new Info()
.title("title")
.description("description")
.license(new License()
.name("AGPLv3")
.url("https://www.gnu.org/licenses/agpl-3.0.html")));
}
}