java - How to customize tom-level properties in Spring boot and Swagger 2.0? -


does know how customize tom-level properties in spring boot , swagger 2.0?

i tried use @swaggerdefinition, not appear work. there mistake in code below?

@springbootapplication @componentscan(basepackages = { "test" }) @enableswagger2 @swaggerdefinition(info = @info(title = "my api documentation",   description = "my api documentation, version:1.0",   version = "1.0",   contact = @contact(name = "my name", email = "my_name@gmail.com", url = "http://my_page/") ,   license = @license(name = "apache 2.0", url = "http://www.apache.org/licenses/license-2.0") ) ) public class application {    public static void main(string[] args) {     springapplication.run(application.class, args);   } } 

and got following json response http://localhost:8080/v2/api-docs

{ swagger: "2.0", info: { description: "api documentation", version: "1.0", title: "api documentation", termsofservice: "urn:tos", contact: { name: "contact email" }, license: { name: "apache 2.0", url: "http://www.apache.org/licenses/license-2.0" } }, host: "localhost:8080", basepath: "/", tags: [ { name: "basic-error-controller", description: "basic error controller" } ], ... } 

the top-level properties(title, discription) supposed have changed.

i come answer myself. don't solve problem @swaggerdefinition, found alternative way.

i can overwrite docket in configuration class.

@springbootapplication @componentscan(basepackages = { "test" }) @enableswagger2 public class application {    @bean   public docket confapi() {     responsemessage msg_500 = new responsemessagebuilder().code(500).message("500 message").responsemodel(new modelref("error")).build();     return new docket(documentationtype.swagger_2).globalresponsemessage(requestmethod.get, collections.singletonlist(msg_500))         .globalresponsemessage(requestmethod.post, collections.singletonlist(msg_500))         .apiinfo(new apiinfo("my api documentation", "my api documentation, version: 1.0", "1.0", null, "my_name@gmail.com", null, null));   }    public static void main(string[] args) {     springapplication.run(application.class, args);   } } 

Comments