1@Bean
2public Docket api() {
3 return new Docket(DocumentationType.SWAGGER_2)
4 .select()
5 .apis(RequestHandlerSelectors.basePackage("com.xxx.yyy.resource"))
6 .paths(PathSelectors.any())
7 .build()
8 .globalOperationParameters(commonParameters())
9 .apiInfo(apiInfo())
10 .ignoredParameterTypes(TokenInfo.class, HttpServletRequest.class, HttpServletResponse.class)
11 .securityContexts(Lists.newArrayList(securityContext()))
12 .securitySchemes(Lists.newArrayList(apiKey()));
13}
14
15
16private List<Parameter> commonParameters() {
17 List<Parameter> parameters = new ArrayList<Parameter>();
18 parameters.add(new ParameterBuilder()
19 .name("access_token")
20 .description("token for authorization")
21 .modelRef(new ModelRef("string"))
22 .parameterType("query")
23 .required(true)
24 .build());
25
26 return parameters;
27}