当前位置: 首页 > 工具软件 > SmartWeb > 使用案例 >

smart生成web项目服务端接口文档

龙骏
2023-12-01


前言:官方代码地址:https://gitee.com/smart-doc-team/smart-doc

1、pom文件中plugins中添加如下代码:

    <plugin>
                <groupId>com.github.shalousun</groupId>
                <artifactId>smart-doc-maven-plugin</artifactId>
                <version>1.2.4</version>
                <configuration>
                    <configFile>./src/main/resources/smart-doc.json</configFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>html</goal>
                            <goal>postman</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

2、resources资源文件目录中创建文件smart-doc.json

{
  "projectName": "项目名称",
  "serverUrl": "服务器IP+端口号",
  "isStrict": false,
  "allInOne": true,
  "coverOld": true,
  "style": "xt256",
  "inlineEnum": true,
  "displayActualType": true,
  "language": "CHINESE",
  "outPath": "文档生成存放地址目录(./src/main/resources/static/docs)",
  "errorCodeDictionaries": [
    {
      "title": "系统错误码",
      "enumClassName": "响应信息类",
      "codeField": "code",
      "descField": "errorMsg"
    }
  ]
}

3、通过mvn命令生成文档

//生成html
mvn -Dfile.encoding=UTF-8 smart-doc:html
 类似资料: