This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f35cb0343 refactor(admin): remove obsolete API document viewer 
backend (#7592) (#7603)
5f35cb0343 is described below

commit 5f35cb0343b8c835067e255755f58c6a6114c597
Author: redyyang <[email protected]>
AuthorDate: Sat Oct 17 20:47:53 2026 +0800

    refactor(admin): remove obsolete API document viewer backend (#7592) (#7603)
    
    Co-authored-by: redyyang <[email protected]>
---
 .../shenyu/admin/controller/ApiDocController.java  | 110 ------------
 .../org/apache/shenyu/admin/model/vo/DocVO.java    | 186 ---------------------
 .../shenyu/admin/model/vo/MenuDocItemVO.java       |  86 ----------
 .../apache/shenyu/admin/model/vo/MenuModuleVO.java |  66 --------
 .../shenyu/admin/model/vo/MenuProjectVO.java       |  67 --------
 .../shenyu/admin/service/manager/DocManager.java   |   8 -
 .../admin/service/manager/impl/DocManagerImpl.java |  17 --
 .../{index.f5d66cf1.js => index.ff04fd53.js}       |   2 +-
 shenyu-admin/src/main/resources/static/index.html  |   2 +-
 .../admin/controller/ApiDocControllerTest.java     |  73 --------
 .../service/impl/SwaggerImportServiceImplTest.java |   7 -
 .../service/manager/impl/DocManagerImplTest.java   |  44 +++++
 12 files changed, 46 insertions(+), 622 deletions(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java
deleted file mode 100755
index 03690c5882..0000000000
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.controller;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.shenyu.admin.aspect.annotation.RestApi;
-import org.apache.shenyu.admin.model.bean.DocInfo;
-import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
-import org.apache.shenyu.admin.model.vo.DocVO;
-import org.apache.shenyu.admin.model.vo.MenuDocItemVO;
-import org.apache.shenyu.admin.model.vo.MenuModuleVO;
-import org.apache.shenyu.admin.model.vo.MenuProjectVO;
-import org.apache.shenyu.admin.model.vo.ShenyuDictVO;
-import org.apache.shenyu.admin.service.ShenyuDictService;
-import org.apache.shenyu.admin.service.manager.DocManager;
-import org.apache.shenyu.common.constant.AdminConstants;
-import org.springframework.web.bind.annotation.GetMapping;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-/**
- * Api Documet Controller.
- */
-@RestApi("/apidoc")
-public class ApiDocController {
-
-    private final DocManager docManager;
-
-    private final ShenyuDictService shenyuDictService;
-
-    public ApiDocController(final DocManager docManager,
-                            final ShenyuDictService shenyuDictService) {
-        this.docManager = docManager;
-        this.shenyuDictService = shenyuDictService;
-    }
-
-    /**
-     * Menu list of documents.
-     *
-     * @return ShenyuAdminResult
-     */
-    @GetMapping("/getDocMenus")
-    public ShenyuAdminResult getAllDoc() {
-        Collection<DocInfo> docInfos = docManager.listAll();
-        List<MenuProjectVO> menuProjectList = docInfos.stream()
-            .map(getMenuAndDocInfo())
-            .collect(Collectors.toList());
-        DocVO docVO = new DocVO();
-        docVO.setMenuProjects(menuProjectList);
-        List<ShenyuDictVO> dictVOList = 
shenyuDictService.list(AdminConstants.DICT_TYPE_API_DOC_ENV);
-        List<DocVO.EnvConfig> envConfigs = dictVOList.stream()
-            .filter(ShenyuDictVO::getEnabled)
-            .map(dictVO -> {
-                DocVO.EnvConfig envConfig = new DocVO.EnvConfig();
-                envConfig.setEnvLabel(dictVO.getDictName());
-                envConfig.setAddressUrl(dictVO.getDictValue());
-                envConfig.setEnvDesc(dictVO.getDesc());
-                return envConfig;
-            })
-            .collect(Collectors.toList());
-        docVO.setEnvProps(envConfigs);
-        if (CollectionUtils.isNotEmpty(envConfigs)) {
-            docVO.setGatewayUrl(envConfigs.get(0).getAddressUrl());
-        }
-        return ShenyuAdminResult.success(docVO);
-    }
-
-    private Function<DocInfo, MenuProjectVO> getMenuAndDocInfo() {
-        return docInfo -> {
-            MenuProjectVO menuProjectVO = new MenuProjectVO();
-            menuProjectVO.setLabel(docInfo.getTitle());
-            List<MenuModuleVO> menuProjectList = docInfo.getDocModuleList()
-                .stream()
-                .map(docModule -> {
-                    MenuModuleVO menuModuleVO = new MenuModuleVO();
-                    menuModuleVO.setLabel(docModule.getModule());
-                    List<MenuDocItemVO> docItems = 
docModule.getDocItems().stream()
-                        .map(docItem -> {
-                            MenuDocItemVO menuDocItemVO = new MenuDocItemVO();
-                            menuDocItemVO.setLabel(docItem.getSummary());
-                            menuDocItemVO.setName(docItem.getName());
-                            return menuDocItemVO;
-                        }).collect(Collectors.toList());
-                    menuModuleVO.setChildren(docItems);
-                    return menuModuleVO;
-                }).collect(Collectors.toList());
-            menuProjectVO.setChildren(menuProjectList);
-            return menuProjectVO;
-        };
-    }
-
-}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DocVO.java 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DocVO.java
deleted file mode 100755
index e0b4fcb5dd..0000000000
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DocVO.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.model.vo;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * DocVO.
- */
-public class DocVO {
-
-    private String cookie;
-
-    private String appKey;
-
-    private String gatewayUrl;
-
-    private List<EnvConfig> envProps;
-
-    private Collection<MenuProjectVO> menuProjects;
-
-    /**
-     * getGatewayUrl.
-     *
-     * @return String
-     */
-    public String getGatewayUrl() {
-        return gatewayUrl;
-    }
-
-    /**
-     * setGatewayUrl.
-     *
-     * @param gatewayUrl gatewayUrl
-     */
-    public void setGatewayUrl(final String gatewayUrl) {
-        this.gatewayUrl = gatewayUrl;
-    }
-
-
-    /**
-     * getEnvProps.
-     * @return List
-     */
-    public List<EnvConfig> getEnvProps() {
-        return envProps;
-    }
-
-    /**
-     * setEnvProps.
-     * @param envProps envProps
-     */
-    public void setEnvProps(final List<EnvConfig> envProps) {
-        this.envProps = envProps;
-    }
-
-    /**
-     * getCookie.
-     *
-     * @return String
-     */
-    public String getCookie() {
-        return cookie;
-    }
-
-    /**
-     * setCookie.
-     *
-     * @param cookie cookie
-     */
-    public void setCookie(final String cookie) {
-        this.cookie = cookie;
-    }
-
-    /**
-     * getAppKey.
-     *
-     * @return String
-     */
-    public String getAppKey() {
-        return appKey;
-    }
-
-    /**
-     * setAppKey.
-     *
-     * @param appKey appKey
-     */
-    public void setAppKey(final String appKey) {
-        this.appKey = appKey;
-    }
-
-    /**
-     * getMenuProjects.
-     *
-     * @return Collection
-     */
-    public Collection<MenuProjectVO> getMenuProjects() {
-        return menuProjects;
-    }
-
-    /**
-     * setMenuProjects.
-     *
-     * @param menuProjects menuProjects
-     */
-    public void setMenuProjects(final Collection<MenuProjectVO> menuProjects) {
-        this.menuProjects = menuProjects;
-    }
-
-    /**
-     * environment config.
-     */
-    public static class EnvConfig {
-
-        private String envLabel;
-
-        private String envDesc;
-
-        private String addressUrl;
-
-        /**
-         * getEnvLabel.
-         * @return String
-         */
-        public String getEnvLabel() {
-            return envLabel;
-        }
-
-        /**
-         * setEnvLabel.
-         * @param envLabel envLabel
-         */
-        public void setEnvLabel(final String envLabel) {
-            this.envLabel = envLabel;
-        }
-
-        /**
-         * get environment description.
-         * @return String
-         */
-        public String getEnvDesc() {
-            return envDesc;
-        }
-
-        /**
-         * set environment description.
-         * @param envDesc envDesc
-         */
-        public void setEnvDesc(final String envDesc) {
-            this.envDesc = envDesc;
-        }
-
-        /**
-         * getAddressUrl.
-         * @return String
-         */
-        public String getAddressUrl() {
-            return addressUrl;
-        }
-
-        /**
-         * setAddressUrl.
-         * @param addressUrl addressUrl
-         */
-        public void setAddressUrl(final String addressUrl) {
-            this.addressUrl = addressUrl;
-        }
-    }
-}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuDocItemVO.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuDocItemVO.java
deleted file mode 100644
index 0c28edeb7a..0000000000
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuDocItemVO.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.model.vo;
-
-
-/**
- * MenuDocItemVO.
- */
-public class MenuDocItemVO {
-
-    private String id;
-
-    private String label;
-
-    private String name;
-
-    /**
-     * getId.
-     *
-     * @return String
-     */
-    public String getId() {
-        return id;
-    }
-
-    /**
-     * setId.
-     *
-     * @param id id
-     */
-    public void setId(final String id) {
-        this.id = id;
-    }
-
-    /**
-     * getLabel.
-     *
-     * @return String
-     */
-    public String getLabel() {
-        return label;
-    }
-
-    /**
-     * setLabel.
-     *
-     * @param label label
-     */
-    public void setLabel(final String label) {
-        this.label = label;
-    }
-
-    /**
-     * getName.
-     *
-     * @return String
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * setName.
-     *
-     * @param name name
-     */
-    public void setName(final String name) {
-        this.name = name;
-    }
-
-}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuModuleVO.java 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuModuleVO.java
deleted file mode 100644
index c280b7f5bb..0000000000
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuModuleVO.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.model.vo;
-
-import java.util.List;
-
-/**
- * MenuModuleVO.
- */
-public class MenuModuleVO {
-
-    private String label;
-
-    private List<MenuDocItemVO> children;
-
-    /**
-     * getLabel.
-     *
-     * @return String
-     */
-    public String getLabel() {
-        return label;
-    }
-
-    /**
-     * setLabel.
-     *
-     * @param label label
-     */
-    public void setLabel(final String label) {
-        this.label = label;
-    }
-
-    /**
-     * getChildren.
-     *
-     * @return List
-     */
-    public List<MenuDocItemVO> getChildren() {
-        return children;
-    }
-
-    /**
-     * setChildren.
-     *
-     * @param children children
-     */
-    public void setChildren(final List<MenuDocItemVO> children) {
-        this.children = children;
-    }
-}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuProjectVO.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuProjectVO.java
deleted file mode 100644
index 376479230f..0000000000
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/MenuProjectVO.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.model.vo;
-
-import java.util.List;
-
-/**
- * MenuProjectVO.
- *
- */
-public class MenuProjectVO {
-
-    private String label;
-
-    private List<MenuModuleVO> children;
-
-    /**
-     * setLabel.
-     *
-     * @return String
-     */
-    public String getLabel() {
-        return label;
-    }
-
-    /**
-     * setLabel.
-     *
-     * @param label label
-     */
-    public void setLabel(final String label) {
-        this.label = label;
-    }
-
-    /**
-     * getChildren.
-     *
-     * @return List
-     */
-    public List<MenuModuleVO> getChildren() {
-        return children;
-    }
-
-    /**
-     * setChildren.
-     *
-     * @param children children
-     */
-    public void setChildren(final List<MenuModuleVO> children) {
-        this.children = children;
-    }
-}
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/DocManager.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/DocManager.java
index dadbee7256..19eeef1008 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/DocManager.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/DocManager.java
@@ -17,7 +17,6 @@
 
 package org.apache.shenyu.admin.service.manager;
 
-import java.util.Collection;
 import java.util.function.Consumer;
 import org.apache.shenyu.admin.model.bean.DocInfo;
 import org.apache.shenyu.admin.model.bean.UpstreamInstance;
@@ -36,11 +35,4 @@ public interface DocManager {
      * @param callback callback
      */
     void addDocInfo(UpstreamInstance instance, String docJson, String oldMd5, 
Consumer<DocInfo> callback);
-
-    /**
-     * listAll.
-     *
-     * @return Collection
-     */
-    Collection<DocInfo> listAll();
 }
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImpl.java
index 0e5353eb90..6d9f6fc261 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImpl.java
@@ -20,9 +20,7 @@ package org.apache.shenyu.admin.service.manager.impl;
 import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -65,11 +63,6 @@ public class DocManagerImpl implements DocManager {
      */
     private static final String HTTP = "http://";;
 
-    /**
-     * key:title, value:docInfo.
-     */
-    private static final Map<String, DocInfo> DOC_DEFINITION_MAP = new 
HashMap<>();
-
     private static final DocParser SWAGGER_DOC_PARSER = new SwaggerDocParser();
 
     @Resource
@@ -171,14 +164,4 @@ public class DocManagerImpl implements DocManager {
         ext.setProtocol(HTTP);
         return GsonUtils.getInstance().toJson(ext);
     }
-
-    /**
-     * get DocInfo.
-     *
-     * @return Collection
-     */
-    @Override
-    public Collection<DocInfo> listAll() {
-        return DOC_DEFINITION_MAP.values();
-    }
 }
diff --git a/shenyu-admin/src/main/resources/static/index.f5d66cf1.js 
b/shenyu-admin/src/main/resources/static/index.ff04fd53.js
similarity index 60%
rename from shenyu-admin/src/main/resources/static/index.f5d66cf1.js
rename to shenyu-admin/src/main/resources/static/index.ff04fd53.js
index 973de13101..4a4f06a024 100644
--- a/shenyu-admin/src/main/resources/static/index.f5d66cf1.js
+++ b/shenyu-admin/src/main/resources/static/index.ff04fd53.js
@@ -1 +1 @@
-!function(e){function t(r){if(n[r])return n[r].exports;var 
o=n[r]={i:r,l:!1,exports:{}};return 
e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var 
n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var
 n=e&&e.__esModule?function(){return e.default}:function(){return e};return 
t.d(n,"a",n),n},t.o=function(e,t){return 
Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="lVK7")}({"+0it":function(e,t,n){"us
 [...]
\ No newline at end of file
+!function(e){function t(r){if(n[r])return n[r].exports;var 
o=n[r]={i:r,l:!1,exports:{}};return 
e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var 
n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var
 n=e&&e.__esModule?function(){return e.default}:function(){return e};return 
t.d(n,"a",n),n},t.o=function(e,t){return 
Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="lVK7")}({"+0it":function(e,t,n){"us
 [...]
\ No newline at end of file
diff --git a/shenyu-admin/src/main/resources/static/index.html 
b/shenyu-admin/src/main/resources/static/index.html
index b7305ed156..e52d4462db 100644
--- a/shenyu-admin/src/main/resources/static/index.html
+++ b/shenyu-admin/src/main/resources/static/index.html
@@ -29,6 +29,6 @@
 <body>
   <div id="httpPath" style="display: none" th:text="${domain}"></div>
   <div id="root"></div>
-<script type="text/javascript" src="index.f5d66cf1.js"></script></body>
+<script type="text/javascript" src="index.ff04fd53.js"></script></body>
 
 </html>
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiDocControllerTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiDocControllerTest.java
deleted file mode 100644
index 2fedf58a1f..0000000000
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiDocControllerTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.controller;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.shenyu.admin.model.vo.ShenyuDictVO;
-import org.apache.shenyu.admin.service.ShenyuDictService;
-import org.apache.shenyu.admin.service.manager.DocManager;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.mockito.junit.jupiter.MockitoSettings;
-import org.mockito.quality.Strictness;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.BDDMockito.given;
-import static 
org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-/**
- * Test cases for ApiDocControllerTest.
- */
-@ExtendWith(MockitoExtension.class)
-@MockitoSettings(strictness = Strictness.LENIENT)
-public class ApiDocControllerTest {
-
-    private MockMvc mockMvc;
-
-    @InjectMocks
-    private ApiDocController apiDocController;
-
-    @Mock
-    private ShenyuDictService shenyuDictService;
-
-    @Mock
-    private DocManager docManager;
-
-    @BeforeEach
-    public void setUp() {
-        this.mockMvc = MockMvcBuilders.standaloneSetup(apiDocController)
-                .build();
-    }
-
-    @Test
-    public void testGetAllDoc() throws Exception {
-        List<ShenyuDictVO> shenyuDictVOS = new ArrayList<>();
-        given(this.shenyuDictService.list(any())).willReturn(shenyuDictVOS);
-        this.mockMvc.perform(MockMvcRequestBuilders.get("/apidoc/getDocMenus"))
-                .andExpect(status().isOk())
-                .andReturn();
-    }
-}
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImplTest.java
index ca53ba3d1e..313a87ad2a 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImplTest.java
@@ -48,8 +48,6 @@ import java.io.IOException;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Map;
 import java.util.function.Consumer;
 
@@ -216,11 +214,6 @@ public class SwaggerImportServiceImplTest {
             this.docJson = docJson;
         }
 
-        @Override
-        public Collection<DocInfo> listAll() {
-            return Collections.emptyList();
-        }
-
         private String getDocJson() {
             return docJson;
         }
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java
index 60dfdd7dfc..d8b28c3d49 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java
@@ -17,19 +17,33 @@
 
 package org.apache.shenyu.admin.service.manager.impl;
 
+import org.apache.shenyu.admin.model.bean.DocItem;
 import org.apache.shenyu.admin.model.bean.UpstreamInstance;
 import org.apache.shenyu.admin.service.manager.RegisterApiDocService;
+import org.apache.shenyu.common.enums.ApiHttpMethodEnum;
+import org.apache.shenyu.common.enums.ApiSourceEnum;
+import org.apache.shenyu.common.enums.ApiStateEnum;
+import org.apache.shenyu.common.enums.RpcTypeEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO;
+import org.apache.shenyu.register.common.enums.EventType;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
+import org.springframework.util.DigestUtils;
 
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+
 /**
  * test cases for DocManagerImpl.
  */
@@ -46,13 +60,43 @@ public class DocManagerImplTest {
     public void testAddDocInfo() {
         UpstreamInstance instance = new UpstreamInstance();
         instance.setContextPath("/testClusterName");
+        instance.setIp("127.0.0.1");
+        instance.setPort(8190);
         AtomicBoolean atomicBoolean = new AtomicBoolean(false);
         docManager.addDocInfo(instance, SwaggerDocParserTest.DOC_INFO_JSON, 
"", docInfo -> {
             Assertions.assertEquals(docInfo.getTitle(), 
"shenyu-examples-http-swagger3 API");
             Assertions.assertEquals(docInfo.getClusterName(), 
"testClusterName");
+            
Assertions.assertEquals(DigestUtils.md5DigestAsHex(SwaggerDocParserTest.DOC_INFO_JSON.getBytes(StandardCharsets.UTF_8)),
 docInfo.getDocMd5());
             atomicBoolean.set(true);
         });
 
         Assertions.assertTrue(atomicBoolean.get());
+
+        ArgumentCaptor<ApiDocRegisterDTO> captor = 
ArgumentCaptor.forClass(ApiDocRegisterDTO.class);
+        verify(registerApiDocService).registerApiDocument(captor.capture());
+        ApiDocRegisterDTO document = captor.getValue();
+        Assertions.assertEquals("/testClusterName", document.getContextPath());
+        Assertions.assertEquals(ApiHttpMethodEnum.GET.getValue(), 
document.getHttpMethod());
+        Assertions.assertEquals(ApiSourceEnum.SWAGGER.getValue(), 
document.getApiSource());
+        Assertions.assertEquals(ApiStateEnum.UNPUBLISHED.getState(), 
document.getState());
+        Assertions.assertEquals(RpcTypeEnum.HTTP.getName(), 
document.getRpcType());
+        Assertions.assertEquals(EventType.REGISTER, document.getEventType());
+        DocItem docItem = 
GsonUtils.getInstance().fromJson(document.getDocument(), DocItem.class);
+        Assertions.assertEquals("Get path variable", docItem.getSummary());
+        Assertions.assertEquals(docItem.getName(), document.getApiPath());
+        ApiDocRegisterDTO.ApiExt ext = 
GsonUtils.getInstance().fromJson(document.getExt(), 
ApiDocRegisterDTO.ApiExt.class);
+        Assertions.assertEquals("127.0.0.1", ext.getHost());
+        Assertions.assertEquals(8190, ext.getPort());
+        Assertions.assertEquals("testClusterName", ext.getServiceName());
+    }
+
+    @Test
+    public void testUnchangedDocIsNotRegisteredAgain() {
+        UpstreamInstance instance = new UpstreamInstance();
+        instance.setContextPath("/testClusterName");
+        String md5 = 
DigestUtils.md5DigestAsHex(SwaggerDocParserTest.DOC_INFO_JSON.getBytes(StandardCharsets.UTF_8));
+        docManager.addDocInfo(instance, SwaggerDocParserTest.DOC_INFO_JSON, 
md5, docInfo -> Assertions.fail("Unchanged document should be skipped"));
+
+        verifyNoInteractions(registerApiDocService);
     }
 }

Reply via email to