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/WebConfig.java | |
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/WebConfig.java')
-rw-r--r-- | src/main/java/com/juick/config/WebConfig.java | 15 |
1 files changed, 14 insertions, 1 deletions
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 { |