Reputation: 946
Say I created a global parameter token
for all my APIs:
List<Parameter> commonParameters = new ArrayList<>();
commonParameters.add(new ParameterBuilder()
.name("token")
.description("Token for api access")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build());
return new Docket(DocumentationType.SWAGGER_2)
.globalOperationParameters(commonParameters)
// rest ignored .....
This token is required for almost every API, except one that can be publicly accessed. How do I exclude this one API from the global operation parameter?
Upvotes: 1
Views: 2404
Reputation: 6630
The only workaround I found is to override globally defined header by using @ApiImplicitParams
annotation.
So in your case:
@ApiImplicitParams({
//Overriding global behavior.
@ApiImplicitParam(
name = "token")
})
Unfortunately, header will be still visible on swagger, but parameter won't be marked as required.
Upvotes: 0
Reputation: 15193
Currently exclusion for globalOperationParameters
is not provided and there's an open feature request for the same in this GitHub issue.
Upvotes: 2