본문 바로가기
SpringBoot

spring webflux swagger config

by ByteBridge 2020. 8. 31.
반응형

- spring boot version

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

- swagger maven dependency

    <!-- swagger start -->
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>

    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-oas</artifactId>
      <version>3.0.0</version>
    </dependency>
    <!-- swagger end -->

- swagger config

@Configuration
@EnableOpenApi
public class SwaggerConfig {
  @Bean
  public Docket apiConfig() {
    return new Docket(DocumentationType.SWAGGER_2)
        .groupName("version_1.0")
        .enable(true)
        .select()
        .apis(RequestHandlerSelectors.basePackage("kr.wooriworld.server.api"))
        .paths(PathSelectors.any())
        .build()
        .apiInfo(
            new ApiInfoBuilder()
                .version("version 1")
                .title("API Documents")
                .description("API 문서 입니다.")
                .version("v_1")
                .build());
  }
}

- webfluxconfig

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {

  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/swagger-ui.html**")
        .addResourceLocations("classpath:/META-INF/resources/");

    registry.addResourceHandler("/webjars/**")
        .addResourceLocations("classpath:/META-INF/resources/webjars/");
  }
}
반응형

'SpringBoot' 카테고리의 다른 글

Spring AOP  (0) 2020.12.06
spring factory pattern  (0) 2020.10.19
React Stream create and test  (0) 2020.08.24
Spring boot kafka demo with docker-compose  (0) 2020.07.20
Flux and Mono  (0) 2020.07.14