- 给一些接口,实体类,方法的参数等加上注释
//给实体类添加注释
@ApiModel("用户实体类")
public class User {
@ApiModelProperty("用户名")
public String name;
@ApiModelProperty("密码")
public String passwrod;
}
*/
@RestController
public class test {
//
@ApiOperation("hello控制类")
@GetMapping("/test")
public String text(){
return "hello";
}
//只要我们的接口中,返回值中存在实体类,他就会被扫描到swagger中
@PostMapping("/User")
public User User(){
return new User();
}
}
2.可以分多个组,每个组可用不同的配置
public Docket docket1(){
return new Docket(DocumentationType.SWAGGER_2).groupName("A");
}
@Bean
public Docket docket2(){
return new Docket(DocumentationType.SWAGGER_2).groupName("B");
}
@Bean
public Docket docket3(){
return new Docket(DocumentationType.SWAGGER_2).groupName("C");
}
3,测试接口,类似postman的功能
接口测试的结果就出来啦