一、POM.xml
二、配置类
三、静态资源路径转换配置类(实现webMvcConfigurer接口)
四、放开权限
.antMatchers("/swagger-ui.html").permitAll()
.antMatchers("/swagger-resources/**").permitAll()
.antMatchers("/images/**").permitAll()
.antMatchers("/webjars/**").permitAll()
.antMatchers("/v2/api-docs").permitAll()
.antMatchers("/configuration/ui").permitAll()
.antMatchers("/configuration/security").permitAll()
如果出现Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually则表示有资源漏设置,补permit即可。
五、注意事项
1.对@RequestBody的map类型参数支持不太好,没法给出示例(得自己扩展,具体可以百度一下,有示例)
2.对@RquestBody的实体类型的支持比对map类型参数支持好,可通过@ApiModel @ApiModelProperties来设置哪些属性要隐藏,哪些必填等。