Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #4988] Fix swagger doc registered appName use contextPath #4989

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Objects;
import java.util.Set;
import javax.annotation.Resource;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
Expand Down Expand Up @@ -123,7 +124,7 @@ private boolean canPull(final UpstreamInstance instance, final TagVO tagVO) {
}

private TagVO saveTagVOAndAcquireLock(final UpstreamInstance instance) {
List<TagVO> tagVOList = tagService.findByQuery(instance.getContextPath(), AdminConstants.TAG_ROOT_PARENT_ID);
List<TagVO> 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());
Expand All @@ -142,7 +143,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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ public void registerApiDocument(final ApiDocRegisterDTO apiDocRegisterDTO) {
tags = apiDocRegisterDTO.getTags();
}
for (String tag : tags) {
List<TagVO> byQuery = tagService.findByQuery(tag);
// tag value is contextPath,so remove first char '/'
String appName = tag.substring(1);
List<TagVO> 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);
Expand All @@ -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());
}
}

Expand Down