Detailed explanation of how springboot automatically generates API documents



When doing a project, if the project is separated from the front and back, the back end must interface with the front end or the mobile end. Then the problem comes. Should the interface be written to them? Generally, it will be written in Excel or word, and the advanced ones will be manually entered on the API management platform. A project has tens of thousands of interfaces. God, what a workload, Interface maintenance is more painful. In order to solve such problems, we can usejapi This project is used to complete the automatic generation of restful documents. It is completely generated based on comments. More detailed configurations can be viewed 。


Clone project down

git clone

Compile package

cd japi/java
gradle install -xtest

Run japi background management

cd japi/java
gradle bootRun

Run the japi document interface

cd japi/node
node app.js

Generate restful documents

Maven project


Gradle project

compile group: 'com.dounine.japi', name: 'client', version: '1.0'

Edit the resources / configuration file
japi.description=this is project description.
japi.createTime=2017-02-23 10:44:44

Write an action

 *Get user list
 *@ param user user information
 * @return class User
 * @version v2
@GetMapping(value = "v2/list")
public Result hots(@Validated({User.UserDEL.class}) User user) throws RuntimeException {

    return null;

Write an API generation class

    public void testCreate(){
        JapiClient.setPrefixPath("/home/lake/github/test-japi/java/");// Project path prefix
        JapiClient.setpostfixPath("/src/main/java");// Project path suffix

        JapiClient.setProjectJavaPath("client");// Main project site
        JapiClient.setActionReletivePath("com/dounine/test-japi/action");// The path relative to the action package of the main project
        //JapiClient.setIncludeProjectJavaPath(new String[]{"api"});// Other package paths associated with the main project
        JapiClient.setIncludePackages(new String[]{"com.dounine.test-japi"});// Associated packages for accurate and fast search
        JapiClient.saveHistory(true);// Keep local historical version
        JapiClient.setFlushServer(false);// Force synchronization of all local and server versions (the previous historical version of the server will be deleted first)

        IProject project = ProjectImpl.init();
        JapiClientStorage japiClientStorage = JapiClientStorage.getInstance();
        japiClientStorage.autoSaveToDisk();// Automatically use to local disk = = > user directory /. Japi client/
        new JapiClientTransfer().autoTransfer(japiClientStorage);// Transfer files to the master server

Finally, visit the browser http://localhost:7777

You can see the restful document login

Log in with your own account and you can see all the items

Enter the project to see the restful interface in detail

Usage scenario

Japi is most suitable for distributed multi module projects such as spring cloud. It has built-in powerful regular expressions, which will make code comments more standardized. Unlike swigger, which uses intrusive annotations to generate documents, japi is completely generated based on standard annotations and supports strong jsr303 or custom annotations.

Open source spirit

Welcome interested students to join the japi project team to transform it better.


This is the end of this article on how springboot automatically generates API documents. For more information on how springboot automatically generates API documents, please search for previous articles on developeppaer or continue to browse the following articles. I hope you will support developeppaer in the future!

Recommended Today

Detailed steps for installing Perl and Komodo IDE for windows

Perl official website: document: address: The installation package of Perl Windows version is divided into activestate Perl and strawberry Perl. For the difference between the two, see: Note: the download speed of activestate Perl is slow. You may need KX to surf the Internet I have uploaded all the versions of […]