|
@@ -0,0 +1,35 @@
|
|
|
+package sloths.demo.config;
|
|
|
+
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+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;
|
|
|
+
|
|
|
+
|
|
|
+@Configuration
|
|
|
+@EnableSwagger2
|
|
|
+public class SwaggerConfig {
|
|
|
+
|
|
|
+ public Docket createRestApi(){
|
|
|
+ return new Docket(DocumentationType.SWAGGER_2)
|
|
|
+ .apiInfo(apiInfo()) // 用于生成API信息
|
|
|
+ .select() // select()函数返回一个ApiSelectorBuilder实例,用来控制接口被swagger做成文档
|
|
|
+ .apis(RequestHandlerSelectors.basePackage("sloths.demo.controller")) //指定扫那个包
|
|
|
+ .paths(PathSelectors.any())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ //定义主界面api信息
|
|
|
+ private ApiInfo apiInfo() {
|
|
|
+ return new ApiInfoBuilder()
|
|
|
+ .title("外卖小程序sloths")
|
|
|
+ .description("外卖小程序sloths-SwaggerAPI管理")
|
|
|
+ .termsOfServiceUrl("")
|
|
|
+ .version("1.0")
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+}
|