swagger 中@ApiImplicitParam()跟@ApiParam()两个注解的区别

weixin_38049770 2019-03-04 08:44:06
 开发四年只会写业务代码,分布式高并发都不会还做程序员?->>>    swagger 中@ApiImplicitParam()跟@ApiParam()两个注解的区别?
...全文
4064 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38065391 2019-06-14
  • 打赏
  • 举报
回复
首先我们看源码的注释部分: ApiParam.java: /**
* Adds additional meta-data for operation parameters.
* <p/>
* This annotation can be used only in combination of JAX-RS 1.x/2.x annotations.
*/ ApiImplicitParam.java: /**
* Represents a single parameter in an API Operation.
* <p/>
* While {@link ApiParam} is bound to a JAX-RS parameter,
* method or field, this allows you to manually define a parameter in a fine-tuned manner.
* This is the only way to define parameters when using Servlets or other non-JAX-RS
* environments.
* <p/>
* This annotation must be used as a value of {@link ApiImplicitParams}
* in order to be parsed.
*
* @see ApiImplicitParams
*/ 这就是说,@ApiParam和@ApiImplicitParam的功能是相同的,但是@ApiImplicitParam的适用范围更广。在非JAX-RS的场合(比如使用servlet提供HTTP接口),只能使用@ApiImplicitParam进行参数说明。我认为,这是因为接口并不显式展示入参的名称,所以没有地方去使用@ApiParam,只能在接口的方法声明下方写@ApiImplicitParam  

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧