com.fastchar.openapi.rapidoc.FastRAPIDocHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastchar-openapi Show documentation
Show all versions of fastchar-openapi Show documentation
FastChar-OpenAPI is build openapi3.0 doc tool package.
The newest version!
package com.fastchar.openapi.rapidoc;
import com.fastchar.core.FastChar;
import com.fastchar.core.FastResource;
import com.fastchar.openapi.core.FastOpenAPIHelper;
import com.fastchar.utils.FastFileUtils;
import com.fastchar.utils.FastStringUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FastRAPIDocHelper {
/**
* 构建 rapi-doc 在线文档界面
* @param docTitle 文档标题
* @param openapiUrl 文档地址
* @return 网页内容
*/
public static String buildHtml(String projectHost,String openapiUrl,String docTitle,String primaryColor,String logo) {
FastResource resource = FastChar.getResources().getResource("web/html/rapi-doc-temp.html");
if (resource != null) {
try {
List strings = FastFileUtils.readLines(resource.getInputStream(), StandardCharsets.UTF_8);
String htmlContent = FastStringUtils.join(strings, "\n");
Map holder = new HashMap<>();
holder.put("http", projectHost);
holder.put("title", docTitle);
holder.put("openapiUrl", openapiUrl);
holder.put("color", primaryColor);
holder.put("logo", logo);
return FastOpenAPIHelper.replacePlaceholder(holder, htmlContent);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return "";
}
}