Search in sources :

Example 6 with ApiParamObject

use of com.terran4j.commons.api2doc.domain.ApiParamObject in project commons by terran4j.

the class ApiMetaService method toMethodMeta.

public MethodMeta toMethodMeta(ApiDocObject doc) {
    MethodMeta methodMeta = new MethodMeta();
    methodMeta.setId(doc.getId());
    methodMeta.setComment(doc.getComment().getValue());
    methodMeta.setName(doc.getName());
    methodMeta.setPaths(doc.getPaths());
    methodMeta.setRequestMethods(toRequestMethods(doc.getMethods()));
    List<ApiParamObject> params = doc.getParams();
    if (params != null && params.size() > 0) {
        for (ApiParamObject param : params) {
            ParamMeta paramMeta = toParamMeta(param);
            methodMeta.addParam(paramMeta);
        }
    }
    return methodMeta;
}
Also used : ApiParamObject(com.terran4j.commons.api2doc.domain.ApiParamObject)

Example 7 with ApiParamObject

use of com.terran4j.commons.api2doc.domain.ApiParamObject in project commons by terran4j.

the class ParseApiCommentOnSeeClass method testParseApiCommentOnSeeClass.

@Test
public void testParseApiCommentOnSeeClass() throws Exception {
    log.info("testParseApiCommentOnSeeClass");
    Api2DocCollector collector = new Api2DocCollector();
    ApiFolderObject folder = collector.toApiFolder(new ParseApiCommentOnSeeClass.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("neo", params.get(1).getSample().toString());
    ApiResultObject user = doc.getResults().get(0);
    ApiResultObject userId = user.getChildren().get(0);
    Assert.assertEquals("id", userId.getId());
    Assert.assertEquals("用户id", userId.getComment().getValue());
    Assert.assertEquals("123", userId.getSample().getValue());
    ApiResultObject userName = user.getChildren().get(1);
    Assert.assertEquals("name", userName.getId());
    Assert.assertEquals("用户名称", userName.getComment().getValue());
    Assert.assertEquals("neo", userName.getSample().getValue());
}
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) ApiResultObject(com.terran4j.commons.api2doc.domain.ApiResultObject) Test(org.junit.Test)

Aggregations

ApiParamObject (com.terran4j.commons.api2doc.domain.ApiParamObject)7 Api2DocCollector (com.terran4j.commons.api2doc.impl.Api2DocCollector)4 Test (org.junit.Test)4 ApiDocObject (com.terran4j.commons.api2doc.domain.ApiDocObject)3 ApiFolderObject (com.terran4j.commons.api2doc.domain.ApiFolderObject)3 ApiResultObject (com.terran4j.commons.api2doc.domain.ApiResultObject)2 ValueSource (com.terran4j.commons.util.value.ValueSource)2 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)2 KeyedList (com.terran4j.commons.util.value.KeyedList)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1