我已经为我的应用程序中列出的所有控制器设置了Swagger。但是,我希望它能够获得Spring Security Logout端点,但我找不到让它工作的方法。正如您从下面的代码片段中看到的,我为用户指定了一个logoutUrl来使其会话无效。我已经尝试过类级注释标记和方法级别,但没有运气。有什么想法吗?
@Override
public void configure(HttpSecurity http) throws Exception {
http.addFilter(someFilter());
http.headers().and().csrf().disable()
.authorizeRequests()
.antMatchers("endpoint",
"endpoint",
"endpoint",
"endpoint",
"endpoint",
"endpoint",
"endpoint").permitAll()
.anyRequest().authenticated()
.and()
.logout().logoutUrl("endpoint/logout").invalidateHttpSession(true).logoutSuccessHandler(logoutSuccessHandler);
}
我的Swagger Docket配置如下:
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(new ApiInfo("API",
"Provides API's",
"1.0",
null,
"someEmail@nowhere.com",
null,
null))
.useDefaultResponseMessages(false)
.pathProvider(new RelativePathProvider(servletContext) {
@Override
protected String applicationPath() {
return super.applicationPath() + "/path";
}
@Override
protected String getDocumentationPath() {
return super.getDocumentationPath() + "/path";
}
});
}
答案 0 :(得分:0)
Spring Fox插件使用Spring bean来构建API文档。看一下这个答案:https://stackoverflow.com/a/42720435/439171