Originally swagger can generate documents, but it cannot export markdown files. This document generator is used to generate markdown files.
Code warehouse address: https://gitee.com/luoye_lj/restful-doc
The tool is divided into three parts as a whole, namely, package scanning to establish data structure, document template, and document generation based on document template and data structure. The data structure is divided into restful structure: interface group, interface, request data, response data. The interface group corresponds to a controller file, and the interface corresponds to the method in the controller
How to use
- Pull code from the warehouse
- Execute maven's install command to install
- Add dependencies to the project
<dependency>
<groupId>com.luoye.restful</groupId>
<artifactId>RestfulDoc</artifactId>
<version>1.0.0</version>
</dependency>
- Write the generated code
package com.luoye;
import com.luoye.restful.DocBuilder;
import com.luoye.restful.PackageScanner;
import com.luoye.restful.model.ApiGroup;
import java.util.List;
public class Test {
public static void main(String[] args) {
PackageScanner packageScanner=new PackageScanner();
packageScanner.setScanPackage("com.luoye.test");
List<ApiGroup> apiGroupList =packageScanner.scan();
DocBuilder docBuilder=new DocBuilder("测试api文档","api test doc",apiGroupList);
docBuilder.build();
}
}
ps
You can create a new template directory, copy the original template into it for modification, and then specify the template directory path in the generated code