Add swagger

This commit is contained in:
2025-12-10 11:04:06 +01:00
parent e5182591b9
commit 650b33111a
4 changed files with 36 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ A Spring Boot overlay server for Twitch broadcasters and their channel admins. B
- In-memory channel directory optimized with lock-free collections for fast updates. - In-memory channel directory optimized with lock-free collections for fast updates.
- Optional SSL with local self-signed keystore support. - Optional SSL with local self-signed keystore support.
- Dockerfile, Makefile, CI workflow, and Maven build. - Dockerfile, Makefile, CI workflow, and Maven build.
- OpenAPI/Swagger UI docs available at `/swagger-ui.html`.
## Getting started ## Getting started
### Prerequisites ### Prerequisites

View File

@@ -98,6 +98,12 @@
<version>2.3.4</version> <version>2.3.4</version>
</dependency> </dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@@ -0,0 +1,19 @@
package com.imgfloat.app.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI imgfloatOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("Imgfloat API")
.description("OpenAPI documentation for Imgfloat admin and broadcaster APIs.")
.version("v1"));
}
}

View File

@@ -20,7 +20,16 @@ public class SecurityConfig {
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http http
.authorizeHttpRequests(auth -> auth .authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/css/**", "/js/**", "/webjars/**", "/actuator/health").permitAll() .requestMatchers(
"/",
"/css/**",
"/js/**",
"/webjars/**",
"/actuator/health",
"/v3/api-docs/**",
"/swagger-ui.html",
"/swagger-ui/**"
).permitAll()
.requestMatchers("/ws/**").permitAll() .requestMatchers("/ws/**").permitAll()
.anyRequest().authenticated() .anyRequest().authenticated()
) )