fix group error;fix #138 at github
This commit is contained in:
parent
835e25c613
commit
e2608debe4
|
@ -38,6 +38,8 @@ import com.thoughtworks.qdox.model.JavaMethod;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.power.doc.constants.DocTags.DEPRECATED;
|
||||
import static com.power.doc.constants.DocTags.IGNORE;
|
||||
|
@ -119,14 +121,8 @@ public class SpringMVCRequestMappingHandler {
|
|||
for (Map.Entry<String, String> entry : constantsMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
if (url.contains(key)) {
|
||||
url = url.replace(key, value);
|
||||
url = url.replace("+", "");
|
||||
}
|
||||
if (shortUrl.contains(key)) {
|
||||
shortUrl = shortUrl.replace(key, value);
|
||||
shortUrl = shortUrl.replace("+", "");
|
||||
}
|
||||
url = delConstantsUrl(url,key,value);
|
||||
shortUrl = delConstantsUrl(shortUrl,key, value);
|
||||
}
|
||||
String urlSuffix = projectBuilder.getApiConfig().getUrlSuffix();
|
||||
if (StringUtil.isNotEmpty(urlSuffix)) {
|
||||
|
@ -141,4 +137,20 @@ public class SpringMVCRequestMappingHandler {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
public static String delConstantsUrl(String url,String replaceKey,String replaceValue){
|
||||
|
||||
if (url.endsWith(replaceKey)) {
|
||||
url = url.replace(replaceKey, replaceValue);
|
||||
url = url.replace("+", "");
|
||||
}
|
||||
else{
|
||||
String regex = "("+replaceKey+")[/|\\\\].*?";
|
||||
Pattern pattern =Pattern.compile(regex);
|
||||
Matcher m = pattern.matcher(url);
|
||||
if(m.matches()) {
|
||||
url = m.replaceAll(Matcher.quoteReplacement(replaceValue));
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,20 +125,23 @@ public interface IDocBuildTemplate<T> {
|
|||
defaultGroup.getChildrenApiDocs().addAll(apiDocList);
|
||||
return finalApiDocs;
|
||||
}
|
||||
|
||||
Map<String,String> hasInsert = new HashMap<>();
|
||||
groups.forEach(group -> {
|
||||
|
||||
ApiDoc groupApiDoc = ApiDoc.buildGroupApiDoc(group.getName());
|
||||
groupApiDoc.setOrder(order.getAndIncrement());
|
||||
finalApiDocs.add(groupApiDoc);
|
||||
apiDocList.forEach(doc -> {
|
||||
|
||||
if(hasInsert.containsKey(doc.getAlias())){
|
||||
return;
|
||||
}
|
||||
// not match, add default group
|
||||
if (!DocUtil.isMatch(group.getApis(), doc.getPackageName())) {
|
||||
defaultGroup.getChildrenApiDocs().add(doc);
|
||||
doc.setOrder(defaultGroup.getChildrenApiDocs().size());
|
||||
hasInsert.put(doc.getAlias(),null);
|
||||
return;
|
||||
}
|
||||
hasInsert.put(doc.getAlias(),null);
|
||||
groupApiDoc.getChildrenApiDocs().add(doc);
|
||||
doc.setOrder(groupApiDoc.getChildrenApiDocs().size());
|
||||
doc.setGroup(group.getName());
|
||||
|
|
Loading…
Reference in New Issue