feat: API documentation UI

This commit is contained in:
sBubshait 2025-07-23 13:35:56 +03:00
parent cfb61fdaa4
commit 638e6343c9
2 changed files with 10 additions and 2 deletions

View File

@ -4,9 +4,12 @@ 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 io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.List;
@Configuration
public class OpenApiConfig {
@ -17,12 +20,17 @@ public class OpenApiConfig {
.title("Wesal API")
.description("Social media application API")
.version("1.0.0"))
.servers(List.of(
new Server().url("http://localhost:8080").description("Development server"),
new Server().url("https://api.wesal.online").description("Production server")
))
.addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"))
.components(new io.swagger.v3.oas.models.Components()
.addSecuritySchemes("Bearer Authentication",
new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")));
.bearerFormat("JWT")
.description("Enter JWT token (without 'Bearer ' prefix)")));
}
}

View File

@ -67,7 +67,7 @@ public class SecurityConfig {
.csrf(csrf -> csrf.disable())
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/login", "/swagger-ui/**", "/v3/api-docs/**").permitAll()
.requestMatchers("/", "/login", "/swagger-ui/**", "/v3/api-docs/**", "/docs/**", "/docs").permitAll()
.requestMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().authenticated()
)