基于freemark、swagger自动生成confluence接口文档

该博客介绍了如何利用Freemarker模板和Swagger自动化生成Confluence平台的接口文档。通过代码示例展示了如何从Java类和方法中获取接口信息,包括功能描述、请求方式、URL、参数和返回值,并将其转换为HTML格式,方便在Confluence上展示。
摘要由CSDN通过智能技术生成
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        body, table {
            color: #333;
            font-family: Arial, sans-serif;
            font-size: 14px;
            line-height: 1.42857142857143;
            color: #333;
        }

        strong, b {
            font-weight: bold;
        }

        li {
            display: list-item;
            text-align: -webkit-match-parent;
            list-style-type: disc;
        }

        table {
            display: table;
            border-collapse: separate;
            border-spacing: 2px;
            border-color: grey;
        }

        thead {
            display: table-header-group;
            vertical-align: middle;
            border-color: inherit;
        }

        tr {
            display: table-row;
            vertical-align: inherit;
            border-color: inherit;
        }

        table.tablesorter > thead > tr > th {
            background: #F0F0F0 center right no-repeat;
            padding-right: 15px;
            cursor: pointer;
        }

        .wiki-content .tablesorter-header-inner, table.confluenceTable th.confluenceTh {
            color: #333333;
        }

        .confluenceTable {
            border-collapse: collapse;
        }

        .confluenceTable:first-child {
            margin-top: 0;
        }

        .confluenceTable, .table-wrap {
            margin: 10px 0 0 0;
            overflow-x: auto;
        }

        .confluenceTh, .confluenceTd {
            border: 1px solid #ddd;
            padding: 7px 10px;
            vertical-align: top;
            text-align: left;
        }

    </style>

</head>
<body>
<ul>
    <li>
        <strong>功能描述</strong>
        <br/>
        $funcDescribe
        <br/>
        <br/>
    </li>
    <li>
        <strong>接口信息</strong>
        <br/>
        1,请求方式:$requestMethod
        <br/>
        2,服务地址:$requestUrl
        <br/>
        3,请求参数类型:Json
        <br/>
        4,返回参数类型:Json
        <br/>
        <br/>
    </li>
    <li>
        <p>
            <strong>接口参数</strong>
            <br/>
            $inInfo
        </p>
        $inTable
        <br/>
    </li>

    <li>
        <p>
            <strong>返回值</strong>
            <br/>
            $returnInfo
        </p>
        $returnTable
    </li>

</ul>
</body>
</html>

public class DocGeneratorGA {

    public static void main(String[] args) throws IOException, TemplateException {

        DocGeneratorGA docGeneratorGA = new DocGeneratorGA();
        docGeneratorGA.generate(new LetterCheckController(), "delete");
    }

    private <T> void generate(T t, String methodName) throws IOException, TemplateException {
        // first step:instance freemarker configuration
        Configuration configuration = new Configuration();

        // second step:set configuration directory
        String dir = DocGe
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值