All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.apidoc.swagger.ReactiveSwaggerAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.apidoc.swagger;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.zodiac.apidoc.swagger.EnableSwaggerFlux;
import org.zodiac.autoconfigure.application.ApplicationInfoProperties;

import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;

import springfox.documentation.spring.web.plugins.Docket;

@EnableSwaggerFlux
@SpringBootConfiguration
@ConditionalOnWebApplication(type = Type.REACTIVE)
//@ImportPropertySource(value = "classpath:/META-INF/config/swagger.yml")
@ConditionalOnClass(value = {org.zodiac.apidoc.swagger.config.SwaggerInfo.class})
public class ReactiveSwaggerAutoConfiguration extends AbstractSwaggerConfiguration implements WebFluxConfigurer {

    public ReactiveSwaggerAutoConfiguration(ApplicationInfoProperties applicationInfoProperties,
        OpenApiExtensionResolver openApiExtensionResolver) {
        super(applicationInfoProperties, openApiExtensionResolver);
    }

    @Bean
    @ConditionalOnMissingBean
    protected Docket api(SwaggerProperties swaggerProperties) {
        return super.api(swaggerProperties);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
//      /*配置knife4j 显示文档 */
//      registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");

      /*配置swagger-ui显示文档*/
      registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
      /** 公共部分内容 */
      registry.addResourceHandler("/webjars/**")
              .addResourceLocations("classpath:/META-INF/resources/webjars/");

//      List docketList = super.apiList(swaggerProperties);
//      if (CollectionUtils.isEmpty(docketList))
//          return;
//      for (springfox.documentation.spring.web.plugins.Docket docket : docketList) {
//          Springs.registerBean(defaultListableBeanFactory, createBeanName(docket.getGroupName()), springfox.documentation.spring.web.plugins.Docket.class);
//      }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy