Swagger注解-@ApiOperation

本文深入解析Swagger注解的使用,包括@ApiOperation、@ApiImplicitParams等,阐述如何通过这些注解描述REST接口,提高API文档的自动生成效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


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 地址


使用场景

在 Rest 接口上使用

概述

描述针对特定路径的操作,通常是 HTTP 方法。具有等效路径的操作被分到单个分组中。HTTP 方法和路径的组合创建了一个独特的操作

属性

属性名称数据类型默认值说明
valueString接口简要说明,120字符或更少
notesString“”接口详细描述
tagsString[]“”tag 列表,可用于按自愿或任何其它限定符对操作进行逻辑分组
responseClass<?>Void.class接口返回类型
responseContainerString“”声明包装响应的容器。有效值为 List,Set,Map,任何其它值都将被忽略
responseReferenceString“”指定对响应类型的引用,本地/远程引用,并将覆盖任何其它指定的response()类
httpMethodString“”请求方式:“GET”, “HEAD”, “POST”, “PUT”, “DELETE”, “OPTIONS” and “PATCH”,如果未指定则使用除"PATH"之外的其它所有
nicknameString“”第三方工具使用operationId来唯一表示此操作
producesString“”采用逗号分隔的 content types 类型的返回数据,例如:application/json,application/xml
consumesString“”采用逗号分隔的 content types 类型的入参数据类型,例如:application/json,application/xml
protocolsString“”指定协议类型:http,https,ws,wss,多个协议使用逗号进行分隔
authorizationsAuthorization[]@Authorization(value = “”)获取此操作的授权列表
hiddenbooleanfalse是否隐藏操作列表中的操作
responseHeadersResponseHeader[]@ResponseHeader(name = “”, response = Void.class)指定 response header 信息列表
codeint200HTTP返回状态码
extensionsExtension[]@Extension(properties = @ExtensionProperty(name = “”, value = “”))可选的扩展数组

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 地址


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值