use of com.terran4j.commons.api2doc.domain.ApiDocObject in project commons by terran4j.
the class DocMenuBuilder method getMenuGroup.
public MenuData getMenuGroup(ApiFolderObject folder) {
String folderId = folder.getId();
String folderName = folder.getName();
MenuData menuGroup = new MenuData();
menuGroup.setId(folderId);
menuGroup.setIndex(folderId);
menuGroup.setName(folderName);
menuGroup.setFolder(true);
menuGroup.setOrder(folder.getOrder());
List<MenuData> children = new ArrayList<>();
Map<String, String> mds = folder.getMds();
if (mds != null && mds.size() > 0) {
for (String md : mds.values()) {
MenuData menu = getMenu(md, folderId);
children.add(menu);
}
}
List<ApiDocObject> docs = folder.getDocs();
if (docs != null) {
for (ApiDocObject doc : docs) {
MenuData menu = getMenu(doc, folderId);
children.add(menu);
}
}
Collections.sort(children);
menuGroup.setChildren(children);
return menuGroup;
}
use of com.terran4j.commons.api2doc.domain.ApiDocObject in project commons by terran4j.
the class DocPageBuilder method doc2HtmlPage.
public String doc2HtmlPage(String folderId, String docId) throws Exception {
ApiFolderObject folder = apiDocService.getFolder(folderId);
if (folder == null) {
if (log.isWarnEnabled()) {
log.warn("ApiFolder NOT Found: {}", folderId);
}
return null;
}
ApiDocObject doc = folder.getDoc(docId);
if (doc == null) {
if (log.isWarnEnabled()) {
log.warn("ApiDoc NOT Found: {}", folderId);
}
return null;
}
String md = doc2Md(folder, doc);
String title = doc.getName();
return md2HtmlPage(md, title);
}
use of com.terran4j.commons.api2doc.domain.ApiDocObject in project commons by terran4j.
the class ApiMetaService method toClassMeta.
public ClassMeta toClassMeta(ApiFolderObject folder) {
ClassMeta classMeta = new ClassMeta();
classMeta.setId(folder.getId());
classMeta.setName(folder.getName());
classMeta.setComment(folder.getComment().getValue());
List<ApiDocObject> docs = folder.getDocs();
if (docs != null && docs.size() > 0) {
for (ApiDocObject doc : docs) {
MethodMeta methodMeta = toMethodMeta(doc);
classMeta.addMethod(methodMeta);
}
}
return classMeta;
}
use of com.terran4j.commons.api2doc.domain.ApiDocObject in project commons by terran4j.
the class ApiCommentUtilsTest method testSee.
@Test
public void testSee() throws Exception {
Api2DocCollector collector = new Api2DocCollector();
ApiFolderObject folder = collector.toApiFolder(new MyController(), "myController");
ApiDocObject doc = folder.getDoc("updateUser");
List<ApiParamObject> params = doc.getParams();
Assert.assertEquals("用户id", params.get(0).getComment().toString());
Assert.assertEquals("123", params.get(0).getSample().toString());
Assert.assertEquals("用户名", params.get(1).getComment().toString());
Assert.assertEquals("terran4j", params.get(1).getSample().toString());
}
use of com.terran4j.commons.api2doc.domain.ApiDocObject in project commons by terran4j.
the class CurlBuilderTest method testToCurlWithGet.
@Test
public void testToCurlWithGet() throws Exception {
ApiDocObject doc = loadDoc("withGet");
String curl = CurlBuilder.toCurl(doc, serverURL);
Assert.assertEquals("curl \\\n" + " \"http://localhost:8080/api/v1/curl/getting?k1=%E9%94%AE1&k2=%E9%94%AE2\"", curl);
}
Aggregations