Springdoc-openapi: How to expose Swagger UI without authentication?

Created on 6 Dec 2019  路  4Comments  路  Source: springdoc/springdoc-openapi

Hi,

I'm glad that found this new project instead of SpringFox which is quite outdated now!

But I'm having issues with exposing the Swagger UI without requiring authentication, can you help me with that please?
I'm using Spring Boot 2.2.1 with Spring Security Starter

Thanks in advance

Most helpful comment

Hi @durimkryeziu ,

Adding this to your WebSecurityConfiguration class should do the trick.

@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    public void configure(WebSecurity web)  {
        web.ignoring().antMatchers("/v3/api-docs",
                "/swagger-ui.html",
                "/swagger-ui/**");
    }
}

All 4 comments

Hi @durimkryeziu ,

Adding this to your WebSecurityConfiguration class should do the trick.

@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    public void configure(WebSecurity web)  {
        web.ignoring().antMatchers("/v3/api-docs",
                "/swagger-ui.html",
                "/swagger-ui/**");
    }
}

Just tested, it works perfect!

Thank you @springdoc

can you share entire class along with imports

can you share entire class along with imports

You have a full working example on demos:

Was this page helpful?
0 / 5 - 0 ratings