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

cn.structure.starter.web.restful.configuration.Swagger2 Maven / Gradle / Ivy

package cn.structure.starter.web.restful.configuration;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.annotation.Resource;

/**
 * 

* swagger 2 的配置类 *

* * @author chuck * @version 1.0.1 * @since 2021-01-03 */ @Configuration @EnableSwagger2 public class Swagger2 { @Resource private Environment env; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title(env.getProperty("swagger.title")) .description(env.getProperty("swagger.description")) .version(env.getProperty("swagger.api.version")) .build(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy