Search in sources :

Example 1 with ApiDocObject

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;
}
Also used : ArrayList(java.util.ArrayList) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject) MenuData(com.terran4j.commons.api2doc.controller.MenuData)

Example 2 with ApiDocObject

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);
}
Also used : ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject)

Example 3 with ApiDocObject

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;
}
Also used : ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject)

Example 4 with ApiDocObject

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());
}
Also used : Api2DocCollector(com.terran4j.commons.api2doc.impl.Api2DocCollector) ApiParamObject(com.terran4j.commons.api2doc.domain.ApiParamObject) ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject) Test(org.junit.Test)

Example 5 with ApiDocObject

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);
}
Also used : ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject) Test(org.junit.Test)

Aggregations

ApiDocObject (com.terran4j.commons.api2doc.domain.ApiDocObject)11 Test (org.junit.Test)7 ApiFolderObject (com.terran4j.commons.api2doc.domain.ApiFolderObject)6 Api2DocCollector (com.terran4j.commons.api2doc.impl.Api2DocCollector)4 ApiParamObject (com.terran4j.commons.api2doc.domain.ApiParamObject)3 ApiResultObject (com.terran4j.commons.api2doc.domain.ApiResultObject)2 MenuData (com.terran4j.commons.api2doc.controller.MenuData)1 ArrayList (java.util.ArrayList)1