From 72359f3b01f4278ab59454781f611793e92e1ec0 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Wed, 17 Apr 2019 22:24:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=B3=BB=E7=BB=9F=E6=8E=A5?=
 =?UTF-8?q?=E5=8F=A3=E6=89=AB=E6=8F=8F=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../com/ruoyi/web/core/config/SwaggerConfig.java   | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java
index 9cee0a47..43353914 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java
@@ -3,6 +3,7 @@ package com.ruoyi.web.core.config;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import com.ruoyi.common.config.Global;
+import io.swagger.annotations.ApiOperation;
 import springfox.documentation.builders.ApiInfoBuilder;
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
@@ -28,11 +29,14 @@ public class SwaggerConfig
     public Docket createRestApi()
     {
         return new Docket(DocumentationType.SWAGGER_2)
-                // 详细定制
+                // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
                 .apiInfo(apiInfo())
+                // 设置哪些接口暴露给Swagger展示
                 .select()
-                // 指定当前包路径
-                .apis(RequestHandlerSelectors.basePackage("com.ruoyi.web.controller.tool"))
+                // 扫描所有有注解的api,用这种方式更灵活
+                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
+                // 扫描指定包中的swagger注解
+                //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
                 // 扫描所有 .apis(RequestHandlerSelectors.any())
                 .paths(PathSelectors.any())
                 .build();
@@ -45,9 +49,13 @@ public class SwaggerConfig
     {
         // 用ApiInfoBuilder进行定制
         return new ApiInfoBuilder()
+                // 设置标题
                 .title("标题:若依管理系统_接口文档")
+                // 描述
                 .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
+                // 作者信息
                 .contact(new Contact(Global.getName(), null, null))
+                // 版本
                 .version("版本号:" + Global.getVersion())
                 .build();
     }