📜  swagger apiimplicitparam 所有端点 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:34.911000             🧑  作者: Mango

代码示例1
@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 commonParameters() {
    List parameters = new ArrayList();
    parameters.add(new ParameterBuilder()
            .name("access_token")
            .description("token for authorization")
            .modelRef(new ModelRef("string"))
            .parameterType("query")
            .required(true)
            .build());

    return parameters;
}