2021
09-20
09-20
swagger2隐藏在API文档显示某些参数的操作
swagger2隐藏在API文档显示某些参数有时候,利用swagger2建立API文档时,有些参数是需要隐藏在API文档显示,在方法中,参数的名字前加上@ApiIgnore就可以了:@PostMapping("modi/certificate")@ApiResponses({@ApiResponse(code=0,message="请求成功"),@ApiResponse(code=10031,message="商家的营业执照已经存在,不能重复入驻")})@ApiOperation(value="修改商家证照资料",notes="修改商家证照资料",resp...
继续阅读 >
swagger是一个功能强大的在线API文档的框架,提供了优雅的API在线文档的查阅和测试功能。利用swagger2可以很方便的构建RESTful风格的API文档,在springboot中使用也非常方便,主要是在controller前配置添加注解就可以了,详细配置过程如下:1.maven依赖包使用目前最新版本为例,pom.xml添加的代码如下<!--https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui--><dependency><groupId>io.springf...
最近使用最新的SpringBoot2.0集成Swagger2的时候遇到一个问题,集成之后打开Swagger页面的时候出现404,后台提示找不到swagger-ui的页面。于是我看了下项目依赖swagger的结构:可以看到swagger-ui.html在META-INF/resources目录下,所以我们需要手动的将静态资源路径指向这里,在java中配置为:importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;importorg.spr...
1.添加Swagger2依赖<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.2.2</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.2.2</version></dependency>2配置类@Configuration@EnableSwagger2publicclassSwagger2{@BeanpublicDocketcreateRestApi(){returnnewDocket(...