首先我们看源码的注释部分:
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