feat: add Swagger/OpenAPI documentation
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -66,6 +66,11 @@
|
|||||||
<version>${jjwt.version}</version>
|
<version>${jjwt.version}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>2.5.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.example.bankcards.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.Components;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class OpenApiConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OpenAPI openAPI() {
|
||||||
|
return new OpenAPI()
|
||||||
|
.info(
|
||||||
|
new Info()
|
||||||
|
.title("Bank Card Management API")
|
||||||
|
.description("REST API for managing bank cards")
|
||||||
|
.version("1.0")
|
||||||
|
)
|
||||||
|
.addSecurityItem(
|
||||||
|
new SecurityRequirement().addList("Bearer Authentication")
|
||||||
|
)
|
||||||
|
.components(
|
||||||
|
new Components().addSecuritySchemes(
|
||||||
|
"Bearer Authentication",
|
||||||
|
new SecurityScheme()
|
||||||
|
.type(SecurityScheme.Type.HTTP)
|
||||||
|
.scheme("bearer")
|
||||||
|
.bearerFormat("JWT")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import com.example.bankcards.security.JwtAuthenticationFilter;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.AuthenticationProvider;
|
import org.springframework.security.authentication.AuthenticationProvider;
|
||||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||||
@@ -38,6 +37,12 @@ public class SecurityConfig {
|
|||||||
auth
|
auth
|
||||||
.requestMatchers("/api/auth/**")
|
.requestMatchers("/api/auth/**")
|
||||||
.permitAll()
|
.permitAll()
|
||||||
|
.requestMatchers(
|
||||||
|
"/swagger-ui/**",
|
||||||
|
"/v3/api-docs/**",
|
||||||
|
"/swagger-ui.html"
|
||||||
|
)
|
||||||
|
.permitAll()
|
||||||
.requestMatchers("/api/admin/**")
|
.requestMatchers("/api/admin/**")
|
||||||
.hasAuthority("ROLE_ADMIN")
|
.hasAuthority("ROLE_ADMIN")
|
||||||
.anyRequest()
|
.anyRequest()
|
||||||
|
|||||||
@@ -19,3 +19,7 @@ app:
|
|||||||
expiration: 86400000
|
expiration: 86400000
|
||||||
card:
|
card:
|
||||||
encryption-key: 1234567890123456
|
encryption-key: 1234567890123456
|
||||||
|
|
||||||
|
springdoc:
|
||||||
|
swagger-ui:
|
||||||
|
path: /swagger-ui.html
|
||||||
|
|||||||
Reference in New Issue
Block a user