diff options
author | Vitaly Takmazov | 2023-01-13 17:38:06 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 18:11:56 +0300 |
commit | 35d25bbc9d261e7b5585d0fd1d398dff3ab4a176 (patch) | |
tree | 68a4d0b0190635615438343f6f6c52cacc213179 /src/main/java/com/juick/config | |
parent | 8b70eded6c9cc3b9cf634356239701fe65779791 (diff) |
Fix OpenAPI generation
* Use HandlerMethodArgumentResolver to pass visitor
* Hide visitor from OpenAPI definitions
* Drop unused AsciiDoc template
Diffstat (limited to 'src/main/java/com/juick/config')
-rw-r--r-- | src/main/java/com/juick/config/OpenAPIConfig.java | 29 | ||||
-rw-r--r-- | src/main/java/com/juick/config/SecurityConfig.java | 1 | ||||
-rw-r--r-- | src/main/java/com/juick/config/WebConfig.java | 15 |
3 files changed, 44 insertions, 1 deletions
diff --git a/src/main/java/com/juick/config/OpenAPIConfig.java b/src/main/java/com/juick/config/OpenAPIConfig.java new file mode 100644 index 00000000..860565b3 --- /dev/null +++ b/src/main/java/com/juick/config/OpenAPIConfig.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2008-2023, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.config; + +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import org.springframework.context.annotation.Configuration; + +@Configuration +@SecurityScheme(name = "basicAuth", + type = SecuritySchemeType.HTTP, + scheme = "basic") +public class OpenAPIConfig { +} diff --git a/src/main/java/com/juick/config/SecurityConfig.java b/src/main/java/com/juick/config/SecurityConfig.java index d8faff7b..cb448cf3 100644 --- a/src/main/java/com/juick/config/SecurityConfig.java +++ b/src/main/java/com/juick/config/SecurityConfig.java @@ -189,6 +189,7 @@ public class SecurityConfig { .authorizeHttpRequests(requests -> requests .requestMatchers(HttpMethod.OPTIONS).permitAll() .requestMatchers("/api/", "/api/messages", "/api/avatar", + "/v3/api-docs", "/api/swagger-ui/**", "/api/messages/discussions", "/api/users", "/api/thread", "/api/tags", diff --git a/src/main/java/com/juick/config/WebConfig.java b/src/main/java/com/juick/config/WebConfig.java index d736b863..136faea9 100644 --- a/src/main/java/com/juick/config/WebConfig.java +++ b/src/main/java/com/juick/config/WebConfig.java @@ -24,14 +24,18 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; +import com.juick.service.UserService; +import com.juick.www.VisitorArgumentResolver; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.http.CacheControl; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.resource.VersionResourceResolver; @@ -45,6 +49,8 @@ public class WebConfig implements WebMvcConfigurer { private String baseDir; @Inject private List<? extends Converter<?, ?>> converters; + @Inject + private UserService userService; @Override public void addFormatters(FormatterRegistry registry) { @@ -52,7 +58,14 @@ public class WebConfig implements WebMvcConfigurer { registry.addConverter(converter); } } - + @Bean + HandlerMethodArgumentResolver visitorArgumentResolver() { + return new VisitorArgumentResolver(userService); + } + @Override + public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { + resolvers.add(visitorArgumentResolver()); + } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { try { |