The ui load for spring-mvc (5.3.1) using springdoc-openapi-ui 1.5.2 looks more simple:
build.gradle (gradle version 6.5)
implementation 'org.springdoc:springdoc-openapi-ui:1.5.2'
The spring-boot-autoconfigure and spring-boot are not needed explicitly in dependencies section cause org.springdoc:springdoc-openapi-ui:1.5.2 already has them both (version 2.4.0).
You'll be surprised how many and what dependencies will be added to your final application.
OpenApiConfig.java
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"org.springdoc"})
@Import({org.springdoc.core.SpringDocConfiguration.class,
org.springdoc.webmvc.core.SpringDocWebMvcConfiguration.class,
org.springdoc.webmvc.ui.SwaggerConfig.class,
org.springdoc.core.SwaggerUiConfigProperties.class,
org.springdoc.core.SwaggerUiOAuthProperties.class,
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class})
class OpenApiConfig implements WebMvcConfigurer {
}
The OpenApiConfig package should be covered by component scan.
In case of Spring Security usage, you might add two url patterns and define the role in your code for the OpenAPI pages access.
<security:intercept-url pattern="/swagger*/**" access="ROLE_DEVELOPER"/>
<security:intercept-url pattern="/v3/api-docs" access="ROLE_DEVELOPER"/>
The urls to check:
http://localhost:8080/your_context_path/swagger-ui.html
http://localhost:8080/your_context_path/v3/api-docs
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…