Automatically generate OpenAPI specification
Swagger UI available at /api/swagger Open API specification available at /api/v3/api-docs
This commit is contained in:
parent
136091c364
commit
a6c2a77e80
5
pom.xml
5
pom.xml
@ -267,6 +267,11 @@
|
||||
<artifactId>flyway-mysql</artifactId>
|
||||
<version>${flyway.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -52,6 +52,11 @@
|
||||
<artifactId>wicket-spring</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>se.su.dsv.scipro</groupId>
|
||||
<artifactId>view</artifactId>
|
||||
|
@ -4,6 +4,7 @@ import org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
@ -14,6 +15,27 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
||||
@ComponentScan("se.su.dsv.scipro.api")
|
||||
public class ApiConfig {
|
||||
@Bean
|
||||
@Order(1)
|
||||
public SecurityFilterChain documentationSecurity(
|
||||
HttpSecurity http,
|
||||
HandlerMappingIntrospector introspector,
|
||||
WebMvcProperties webMvcProperties)
|
||||
throws Exception
|
||||
{
|
||||
MvcRequestMatcher.Builder mvc = new MvcRequestMatcher.Builder(introspector)
|
||||
.servletPath(webMvcProperties.getServlet().getPath());
|
||||
return http
|
||||
.securityMatchers(matchers -> matchers
|
||||
.requestMatchers(
|
||||
mvc.pattern("/v3/api-docs/**"),
|
||||
mvc.pattern("/swagger"),
|
||||
mvc.pattern("/swagger-ui/**")))
|
||||
.authorizeHttpRequests(authorize -> authorize.anyRequest().permitAll())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(2)
|
||||
public SecurityFilterChain apiSecurity(
|
||||
HttpSecurity http,
|
||||
HandlerMappingIntrospector introspector,
|
||||
|
@ -10,3 +10,5 @@ spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.Ph
|
||||
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
|
||||
|
||||
spring.mvc.servlet.path=/api
|
||||
|
||||
springdoc.swagger-ui.path=/swagger
|
||||
|
Loading…
x
Reference in New Issue
Block a user