Swagger注解-@Api
Swagger注解-@ApiOperation
Swagger注解-@ApiImplicitParams 和 @ApiImplicitParam
Swagger注解-@ApiModel 和 @ApiModelProperty
Swagger注解-@ApiResponses 和 @ApiResponse
Swagger注解-@ResponseHeader
Swagger注解-@ApiParam
Swagger注解-@Authorization 和 @AuthorizationScope
Swagger注解-@SwaggerDefinition
Swagger注解-@ExternalDocs
Springboot 集成 Swagger GitHub 地址
@ApiImplicitParams
使用场景
在 Rest 接口方法上使用来指定请求参数
概述
在 Rest 接口方法上使用来指定请求参数
属性
| 属性名称 | 数据类型 | 默认值 | 说明 |
|---|---|---|---|
| value | ApiImplicitParam[] | API 可用的参数列表 |
@ApiImplicitParam
使用场景
场景一:在 Rest 接口上单独使用
@ApiImplicitParam 在 Rest 接口上单独使用的时候,表示单个请求参数
场景二:在 Rest 接口上和 @ApiImplicitParams 组合使用
@ApiImplicitParam 在 Rest 接口上和 @ApiImplicitParams 组合时候,表示多个请求参数
概述
表示 Rest 接口的单个请求参数,可与 @ApiImplicitParams 组合使用来表示多个请求参数
属性
| 属性名称 | 数据类型 | 默认值 | 说明 |
|---|---|---|---|
| name | String | “” | 参数名称(实体类字段名称) |
| value | String | “” | 参数简要说明 |
| defaultValue | String | “” | 描述参数的默认值 |
| allowableValues | String | “” | 限制此参数接收的值,可使用的值或值得范围 |
| required | boolean | false | 指定是否为必填参数,false:非必传参数; true:必传参数 |
| access | String | “” | 参数过滤,参考: io.swagger.core.filter.SwaggerSpecFilte |
| allowMultiple | boolean | false | 指定参数是否可以通过多次出现来接收多个值 |
| dataType | String | “” | 参数的数据类型,可以使类名或原始数据类型 |
| dataTypeClass | Class<?> | Void.class | 参数的类,如果提供则覆盖 dataType |
| paramType | String | “” | 参数的参数类型,有效值为 path, query, body, header, form |
| example | String | “” | 非请求体(body)参数的单个请求示例 |
| examples | Example | @Example(value = @ExampleProperty(mediaType = “”, value = “”)) | 参数示例,仅适用于 BodyParameters(请求体类型的) |
| type | String | “” | 添加覆盖检测到的类型的功能 |
| format | String | “” | 添加提供自定义格式的功能 |
| allowEmptyValue | boolean | false | 添加将 format 设置为空的功能 |
| readOnly | boolean | false | 添加被指定为只读的能力 |
| collectionFormat | String | “” | 添加使用 array 类型 collectionFormat 的功能 |
Swagger注解-@Api
Swagger注解-@ApiOperation
Swagger注解-@ApiImplicitParams 和 @ApiImplicitParam
Swagger注解-@ApiModel 和 @ApiModelProperty
Swagger注解-@ApiResponses 和 @ApiResponse
Swagger注解-@ResponseHeader
Swagger注解-@ApiParam
Swagger注解-@Authorization 和 @AuthorizationScope
Swagger注解-@SwaggerDefinition
Swagger注解-@ExternalDocs
Springboot 集成 Swagger GitHub 地址

本文深入解析Swagger注解的使用场景及属性,包括@Api、@ApiOperation、@ApiImplicitParams、@ApiImplicitParam等,帮助开发者更好地理解和应用这些注解,提升RESTful API的文档自动生成效果。
3648

被折叠的 条评论
为什么被折叠?



