java spring swagger annotations code example
Example: swagger apiimplicitparam all endpoints
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.xxx.yyy.resource"))
.paths(PathSelectors.any())
.build()
.globalOperationParameters(commonParameters())
.apiInfo(apiInfo())
.ignoredParameterTypes(TokenInfo.class, HttpServletRequest.class, HttpServletResponse.class)
.securityContexts(Lists.newArrayList(securityContext()))
.securitySchemes(Lists.newArrayList(apiKey()));
}
private List<Parameter> commonParameters() {
List<Parameter> parameters = new ArrayList<Parameter>();
parameters.add(new ParameterBuilder()
.name("access_token")
.description("token for authorization")
.modelRef(new ModelRef("string"))
.parameterType("query")
.required(true)
.build());
return parameters;
}