I am using the spring-fox2 @ApiImplicitParam
annotation to make the swagger-ui show a box for including an Authorization header with a request:
@ApiImplicitParams({
@ApiImplicitParam(
name="Authorization",
value="authorization header containing the bearer token",
paramType = "header"
)
})
public void someControllerMethod() {
...
}
This works fine, but I need this authorization header for each method in the controller. Copying and pasting this is code smell. Can I define some kind of shortcut annotation for this? Is there a different way of telling swagger-ui to create an input field for the authorization header?
Thanks!
An alternative approach to you problem is to not use annotations at all. Instead use the docket to add global operation parameters see #22. You can add headers to all the operations in your docket.
The downside to this approach might be that you might end up with multiple dockets configured such that you pre-select (see #4, #5, #6) which operations to add these parameters to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With