美文网首页
Swagger2使用

Swagger2使用

作者: 前进的码农 | 来源:发表于2020-01-08 17:48 被阅读0次

常用注解说明

具体使用见git代码

@Api 作用于类tags用户描述该类的作用也可以理解为模块
@ApiOperation()用于方法;
表示一个http请求的操作
@ApiParam()用于方法,参数,字段说明;
表示对参数的添加元数据(说明或是否必填等)
@ApiModel()用于类
表示对类进行说明,用于参数用实体类接收
@ApiModelProperty()用于方法,字段
表示对model属性的说明或者数据操作更改
@ApiIgnore()用于类,方法,方法参数
表示这个方法或者类被忽略
@ApiImplicitParam() 用于方法 和ApiParam差不多
表示单独的请求参数
@ApiImplicitParams() 用于方法,包含多个 @ApiImplicitParam
作用于方法
@ApiResponses
@ApiResponse 返回状态码说明

登录密码配置

#配置swagger登录
swagger.production=false
swagger.basic.enable=true
swagger.basic.username=admin
swagger.basic.password=admin12

POM配置

 <!--swagger2-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!--swagger2 ui 基于bootstrap-->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>swagger-bootstrap-ui</artifactId>
            <version>1.9.3</version>
        </dependency>

项目实例

https://github.com/suethan/swgger2

相关文章

网友评论

      本文标题:Swagger2使用

      本文链接:https://www.haomeiwen.com/subject/pebsactx.html