First of all, in advance, thanks for all the replies.
Now let's move on to the problem. Today, i installed all the 3.0.0 Swagger dependencies for a Spring Boot project (boot-starter, swagger2 and swagger-ui). Everything is working as it should, but i can't change the apiInfo informantion in the Docket builder.
Gradle:
implementation "io.springfox:springfox-boot-starter:3.0.0"
implementation "io.springfox:springfox-swagger2:3.0.0"
implementation "io.springfox:springfox-swagger-ui:3.0.0"
SpringFoxConfig.java:
package io.ubivis.swagger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Configuration
public class SpringFoxConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(metaData());
}
private ApiInfo metaData() {
return new ApiInfoBuilder()
.title("Spring Boot REST API")
.description("Spring Boot REST API for Space Study")
.version("1.0.0")
.license("Apache 2.0")
.contact(new Contact("XYZ", "XYZ.com", "[email protected]"))
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
.build();
}
}
Even with the metaData function being called in the Docket builder, Swagger just ignores it and doesn't change any of the default information.
Does anyone knows how to fix this? Thanks!
Edit:
Just realized that I can't change anything of the default values. Even when I try to change the GlobalResponseMessage:
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.POST, responseMessageForGet())
.apiInfo(metaData());
}
Nothing happens and the page keep showing the default globalResponseMessage.
In this edit, I tried to downgrade the dependency to version 2.9.2, seeking where could be my problem. But I do still have the same problem (and now another one lol).