Parcourir la source

接口文档推送配置

谭斌 il y a 2 ans
Parent
commit
b98036b21e

+ 8 - 0
sys-start/pom.xml

@@ -39,6 +39,14 @@
             <artifactId>elasticsearch</artifactId>
             <version>7.14.0</version>
         </dependency>
+
+        <!-- torna swagger 插件 -->
+        <dependency>
+            <groupId>cn.torna</groupId>
+            <artifactId>swagger-plugin</artifactId>
+            <version>1.2.18</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 39 - 0
sys-start/src/main/java/com/xy/PushDoc.java

@@ -0,0 +1,39 @@
+package com.xy;
+
+import cn.torna.swaggerplugin.SwaggerPlugin;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+
+/**
+ * 指定测试环境启动运行,git push会重新启动并推送文档
+ */
+@Profile("uat")
+@Slf4j
+@Component
+public class PushDoc implements ApplicationRunner {
+
+    /**
+     * swagger文档推送到torna接口管理平台
+     */
+    @SneakyThrows
+    @Override
+    public void run(ApplicationArguments args) {
+        log.info("开始执行:swagger接口文档数据---->Torna");
+        SwaggerPlugin.pushDoc();
+        log.info("执行完成:swagger接口文档数据---->Torna");
+
+    }
+
+    /**
+     * 主动推送
+     *
+     * @param args
+     */
+    public static void main(String[] args) {
+        SwaggerPlugin.pushDoc();
+    }
+}

+ 18 - 0
sys-start/src/main/resources/torna.json

@@ -0,0 +1,18 @@
+{
+  // 开启推送
+  "enable": true,
+  // 扫描package,多个用;隔开
+  "basePackage": "com.xy.*",
+  // 推送URL,IP端口对应Torna服务器
+  "url": "http://119.96.213.127:9010/api",
+  // 模块token
+  "token": "18282cd598ea4d54ab488b4001d9a161",
+  // 调试环境,格式:环境名称,调试路径,多个用"|"隔开
+  "debugEnv": "test,http://119.96.194.20:9050/",
+  // 推送人
+  "author": "xy",
+  // 打开调试:true/false
+  "debug": true,
+  // 是否替换文档,true:替换,false:不替换(追加)。默认:true
+  "isReplace": true
+}