fix error of while set allInOne option is false.
This commit is contained in:
parent
adc5399b19
commit
0ce056087b
|
@ -48,7 +48,7 @@ public class AdocDocBuilder {
|
|||
*
|
||||
* @param config ApiConfig
|
||||
*/
|
||||
public static void builderApiDoc(ApiConfig config) {
|
||||
public static void buildApiDoc(ApiConfig config) {
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
buildApiDoc(config, javaProjectBuilder);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,8 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
mapper.binding(TemplateVariable.DESC.getVariable(), doc.getDesc());
|
||||
mapper.binding(TemplateVariable.NAME.getVariable(), doc.getName());
|
||||
mapper.binding(TemplateVariable.LIST.getVariable(), doc.getList());
|
||||
mapper.binding(TemplateVariable.REQUEST_EXAMPLE.getVariable(), config.isRequestExample());
|
||||
mapper.binding(TemplateVariable.RESPONSE_EXAMPLE.getVariable(), config.isResponseExample());
|
||||
FileUtil.nioWriteFile(mapper.render(), config.getOutPath() + FILE_SEPARATOR + doc.getName() + fileExtension);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class HtmlApiDocBuilder {
|
|||
List<ApiDocDict> apiDocDictList = builderTemplate.buildDictionary(config, javaProjectBuilder);
|
||||
buildIndex(apiDocList, config);
|
||||
copyCss(config.getOutPath());
|
||||
buildDoc(apiDocList, config.getOutPath());
|
||||
buildDoc(apiDocList, config);
|
||||
buildErrorCodeDoc(config.getErrorCodes(), config.getOutPath());
|
||||
buildDictionary(apiDocDictList, config.getOutPath());
|
||||
}
|
||||
|
@ -149,20 +149,22 @@ public class HtmlApiDocBuilder {
|
|||
* build ever controller api
|
||||
*
|
||||
* @param apiDocList list of api doc
|
||||
* @param outPath output path
|
||||
* @param config ApiConfig
|
||||
*/
|
||||
private static void buildDoc(List<ApiDoc> apiDocList, String outPath) {
|
||||
FileUtil.mkdirs(outPath);
|
||||
private static void buildDoc(List<ApiDoc> apiDocList, ApiConfig config) {
|
||||
FileUtil.mkdirs(config.getOutPath());
|
||||
Template htmlApiDoc;
|
||||
for (ApiDoc doc : apiDocList) {
|
||||
Template apiTemplate = BeetlTemplateUtil.getByName(API_DOC_MD_TPL);
|
||||
apiTemplate.binding(TemplateVariable.REQUEST_EXAMPLE.getVariable(), config.isRequestExample());
|
||||
apiTemplate.binding(TemplateVariable.RESPONSE_EXAMPLE.getVariable(), config.isResponseExample());
|
||||
apiTemplate.binding(TemplateVariable.DESC.getVariable(), doc.getDesc());
|
||||
apiTemplate.binding(TemplateVariable.NAME.getVariable(), doc.getName());
|
||||
apiTemplate.binding(TemplateVariable.LIST.getVariable(), doc.getList());//类名
|
||||
Map<String, Object> templateVariables = new HashMap<>();
|
||||
templateVariables.put(TemplateVariable.TITLE.getVariable(), doc.getDesc());
|
||||
htmlApiDoc = initTemplate(apiTemplate, HTML_API_DOC_TPL, templateVariables);
|
||||
FileUtil.nioWriteFile(htmlApiDoc.render(), outPath + FILE_SEPARATOR + doc.getAlias() + ".html");
|
||||
FileUtil.nioWriteFile(htmlApiDoc.render(), config.getOutPath() + FILE_SEPARATOR + doc.getAlias() + ".html");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,9 @@ import com.power.common.util.FileUtil;
|
|||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.doc.constants.TemplateVariable;
|
||||
import com.power.doc.model.*;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.model.ApiParam;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.power.doc.utils.BeetlTemplateUtil;
|
||||
|
@ -46,6 +48,7 @@ import static com.power.doc.constants.DocGlobalConstants.YAPI_RESULT_TPL;
|
|||
|
||||
/**
|
||||
* generate yapi's yapi json
|
||||
*
|
||||
* @author dai19470 2020/08/20.
|
||||
*/
|
||||
public class YapiJsonBuilder {
|
||||
|
@ -57,7 +60,6 @@ public class YapiJsonBuilder {
|
|||
* @param config 配置文件
|
||||
*/
|
||||
public static void buildYapiCollection(ApiConfig config) {
|
||||
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
|
@ -76,8 +78,8 @@ public class YapiJsonBuilder {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static void yapiJsonCreate(ApiConfig config, ProjectDocConfigBuilder configBuilder) {
|
||||
config.setParamsDataToTree(true);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
List<Map<String, Object>> requestItem = new ArrayList<>();
|
||||
|
@ -198,8 +200,9 @@ public class YapiJsonBuilder {
|
|||
|
||||
/**
|
||||
* 将字段类型转换为yapi的字段类型
|
||||
* @param type
|
||||
* @return
|
||||
*
|
||||
* @param type java type
|
||||
* @return String
|
||||
*/
|
||||
public static String changeType(String type) {
|
||||
switch (type) {
|
||||
|
@ -216,8 +219,9 @@ public class YapiJsonBuilder {
|
|||
|
||||
/**
|
||||
* 单个参数拼接字符串
|
||||
* @param param
|
||||
* @return
|
||||
*
|
||||
* @param param ApiParam
|
||||
* @return String
|
||||
*/
|
||||
public static String getTypeAndPropertiesJson(ApiParam param) {
|
||||
StringBuffer resultJson = new StringBuffer();
|
||||
|
|
Loading…
Reference in New Issue