diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java index dec7c930e639..53a894335213 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java @@ -19,6 +19,7 @@ import com.google.common.collect.Interner; import com.google.common.collect.Interners; + import okhttp3.Response; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -136,7 +137,7 @@ private boolean canPull(final UpstreamInstance instance, final TagVO tagVO) { } private TagVO saveTagVOAndAcquireLock(final UpstreamInstance instance) { - List tagVOList = tagService.findByQuery(instance.getContextPath(), AdminConstants.TAG_ROOT_PARENT_ID); + List tagVOList = tagService.findByQuery(instance.getClusterName(), AdminConstants.TAG_ROOT_PARENT_ID); if (CollectionUtils.isNotEmpty(tagVOList)) { TagVO tagVO = tagVOList.get(0); TagDO.TagExt tagExt = convertTagExt(tagVO.getExt()); @@ -155,7 +156,7 @@ private TagVO saveTagVOAndAcquireLock(final UpstreamInstance instance) { private TagVO createRootTagAndAcquireLock(final UpstreamInstance instance) { TagDTO tagDTO = new TagDTO(); tagDTO.setTagDesc(instance.getClusterName()); - tagDTO.setName(instance.getContextPath()); + tagDTO.setName(instance.getClusterName()); tagDTO.setParentTagId(AdminConstants.TAG_ROOT_PARENT_ID); TagDO.TagExt tagExt = new TagDO.TagExt(); tagExt.setDocLock(this.generateDocLock()); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/RegisterApiDocServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/RegisterApiDocServiceImpl.java index 051f2f4dd5dd..7346d27f866c 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/RegisterApiDocServiceImpl.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/RegisterApiDocServiceImpl.java @@ -60,14 +60,16 @@ public void registerApiDocument(final ApiDocRegisterDTO apiDocRegisterDTO) { tags = apiDocRegisterDTO.getTags(); } for (String tag : tags) { - List byQuery = tagService.findByQuery(tag); + // tag value is contextPath,so remove first char '/' + String appName = tag.substring(1); + List byQuery = tagService.findByQuery(appName); if (CollectionUtils.isNotEmpty(byQuery)) { tagsIds.addAll(byQuery.stream().map(TagVO::getId).collect(Collectors.toList())); } else { TagDTO tagDTO = new TagDTO(); String id = UUIDUtils.getInstance().generateShortUuid(); - tagDTO.setTagDesc(tag); - tagDTO.setName(tag); + tagDTO.setTagDesc(appName); + tagDTO.setName(appName); tagDTO.setId(id); tagService.createRootTag(tagDTO, null); tagsIds.add(id); @@ -76,8 +78,7 @@ public void registerApiDocument(final ApiDocRegisterDTO apiDocRegisterDTO) { apiDTO.setTagIds(tagsIds); apiService.createOrUpdate(apiDTO); } else if (apiDocRegisterDTO.getEventType().equals(EventType.OFFLINE)) { - String contextPath = apiDocRegisterDTO.getContextPath(); - apiService.offlineByContextPath(contextPath); + apiService.offlineByContextPath(apiDocRegisterDTO.getContextPath()); } }