This Is an spring boot 3.1.3 project and integrate swagger open api 3.1.0 with InMemory Basic Auth
1 . Add Spring doc web mvc dependancy https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-webmvc-ui
2 . Enable Swagger UI and path . Add below properties into application.properties
springdoc.swagger-ui.enabled=true
springdoc.api-docs.enabled=true
springdoc.api-docs.path=/docs
springdoc.swagger-ui.path=/docs/openapi.html
-
Permit access to specific swagger URL in security filter chain
@Bean SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http.csrf(httpSecurityCsrfConfigurer -> httpSecurityCsrfConfigurer.disable()) .authorizeHttpRequests((authorize) -> { authorize.requestMatchers("/docs/**").permitAll(); authorize.anyRequest().authenticated(); }).httpBasic(Customizer.withDefaults()); return http.build(); }
4 . Swagger UI
5 . testing with postman