Search in sources :

Example 6 with Json2JavaElement

use of entity.Json2JavaElement in project CodeUtils by boredream.

the class SwaggerDocGenerator method parseJsonParams.

private static ArrayList<RequestParam> parseJsonParams(Element jsonElement) {
    ArrayList<RequestParam> requestParams = new ArrayList<RequestParam>();
    String jsonStr = jsonElement.getElementsByClass("json").text();
    if (!jsonStr.isEmpty()) {
        List<Json2JavaElement> jsonBeanTree = JsonUtils.getJsonBeanTree(jsonStr);
        for (Json2JavaElement j2je : jsonBeanTree) {
            String paramName = j2je.getName();
            // 此类格式post参数没有描述
            String paramDes = "";
            Class<?> type = j2je.getType();
            String pType = type == null ? "String" : j2je.getType().getSimpleName();
            requestParams.add(new RequestParam(paramName, pType, paramDes, new ArrayList<String>()));
        }
    }
    return requestParams;
}
Also used : RequestParam(entity.RequestParam) ArrayList(java.util.ArrayList) Json2JavaElement(entity.Json2JavaElement)

Aggregations

Json2JavaElement (entity.Json2JavaElement)6 ArrayList (java.util.ArrayList)3 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 RequestParam (entity.RequestParam)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 ArrayType (entity.ArrayType)1 RequestInfo (entity.RequestInfo)1 File (java.io.File)1 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1