refactor: swagger导入支持多层级的tag
This commit is contained in:
parent
ec69dba65a
commit
2f5ba3fc5e
|
@ -19,6 +19,24 @@ public abstract class SwaggerAbstractParser extends ApiImportAbstractParser<ApiD
|
|||
}
|
||||
} else {
|
||||
tags.forEach(tag -> {
|
||||
// 涉及到多级目录的结构,如: 一级目录/二级目录
|
||||
if (tag.contains("/")) {
|
||||
String[] tagTree = tag.split("/");
|
||||
ApiModule pModule = parentModule;
|
||||
String prefix = selectModulePath;
|
||||
for (String item : tagTree) {
|
||||
pModule = buildModule(pModule, apiDefinition, item, prefix);
|
||||
prefix += "/" + item;
|
||||
}
|
||||
} else {
|
||||
buildModule(parentModule, apiDefinition, tag, selectModulePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private ApiModule buildModule(ApiModule parentModule, ApiDefinitionWithBLOBs apiDefinition,
|
||||
String tag, String selectModulePath) {
|
||||
ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId);
|
||||
apiDefinition.setModuleId(module.getId());
|
||||
if (StringUtils.isNotBlank(selectModulePath)) {
|
||||
|
@ -26,8 +44,7 @@ public abstract class SwaggerAbstractParser extends ApiImportAbstractParser<ApiD
|
|||
} else {
|
||||
apiDefinition.setModulePath("/" + tag);
|
||||
}
|
||||
});
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue