Przeglądaj źródła

生成api文档模板

lichunlei 7 miesięcy temu
rodzic
commit
7201ca3b62
1 zmienionych plików z 120 dodań i 0 usunięć
  1. 120 0
      Template/ApiDoc/doc.json

+ 120 - 0
Template/ApiDoc/doc.json

@@ -0,0 +1,120 @@
+{
+  "openapi": "3.1.0",
+  "info": {
+    "title": "<<ym:serviceName>>",
+    "description": "<<ym:serviceName>>的API文档",
+    "version": "1.0.0"
+  },
+  "tags": [
+    <<ym-loop:apiGroup removeEnd=",">>
+    {
+      "name": "<<groupName>>"
+    },<</ym-loop:apiGroup>>
+  ],
+  "paths": {
+    <<ym-loop:apiInfo removeEnd=",">>
+    "/<<apiVersionNo>>/<<serviceName>>/<<groupName>>/<<methodName>>": {
+      "<<ym-if:<<apiKind>><3>>get<</ym-if>><<ym-if:<<apiKind>>=3>>post<</ym-if>><<ym-if:<<apiKind>>=4>>put<</ym-if>><<ym-if:<<apiKind>>=5>>delete<</ym-if>>": {
+        "summary": "<<apiName>>",
+        "x-apifox-folder": "<<groupName>>",
+        "x-apifox-status": "released",
+        "deprecated": false,
+        "description": "<div><div class=\"tips\"><strong>注意事项</strong><br><p><<apiDetail>></p><br></div><div class=\"apicontent apicontent2\"><strong>返回报文示例:</strong><br><pre>{<br> status: \"1\",<br>msg: \"\",<br> data: [{<br> }]<br>}<br></pre></div><div class=\"apicontent apicontent2\"><strong>axios调用示例</strong><br><pre>const params = {\n};\nRequest({\n    url: this.UrlList.<<serviceName>>.<<groupName>><<methodName>>.url,\n    method: this.UrlList.<<serviceName>>.<<groupName>><<methodName>>.method,\n    params,\n})\n.then((res) => {\n    if (res.status == 1) {\n        // 返回参数正确逻辑\n    } else {\n        PublicFn.tips(res.msg);\n    }\n})\n.catch((e) => {\n    console.log(e);\n});\n<br></pre></div></div></div>",
+        "tags": [
+          "<<groupName>>"
+        ],
+        "parameters": [
+          <<ym-loop:apiParam removeEnd=",">>
+          {
+            "name": "<<fieldName>>",
+            "in": "query",
+            "description": "<<fieldTitle>>",
+            "required": false,
+            "example": "",
+            "schema": {
+              "type": "<<fieldType>>"
+            }
+          },<</ym-loop:apiParam>>
+        ],
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "properties": {
+                  <<ym-loop:apiParam removeEnd=",">>
+                  <<ym-if:<<reqParam>>==true>>"<<fieldName>>": {
+                    "type": "<<fieldType>>",
+                    "title": "<<fieldTitle>>"
+                  },<</ym-if>><</ym-loop:apiParam>>
+                },
+                "x-apifox-orders": [
+                  <<ym-loop:apiParam removeEnd=",">>
+                  <<ym-if:<<reqParam>>==true>>"<<fieldName>>",<</ym-if>><</ym-loop:apiParam>>
+                ],
+                "required": [
+                  <<ym-loop:apiParam removeEnd=",">>
+                  <<ym-if:<<checkAttribute>>.Contains("required") and <<reqParam>>==true>>"<<fieldName>>",<</ym-if>><</ym-loop:apiParam>>
+                ],
+                "x-apifox-ignore-properties": []
+              },
+              "example": ""
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "请求成功返回的数据",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "title": "返回报文",
+                  "required": [
+                    "status",
+                    "msg",
+                    "data"
+                  ],
+                  "properties": {
+                    "status": {
+                      "type": "integer",
+                      "description": "状态(1成功,否则失败)"
+                    },
+                    "msg": {
+                      "type": "string",
+                      "description": "描述(status为1不显示描述信息,status不为1显示错误信息)"
+                    },
+                    "data": {
+                      "type": "array",
+                      "items": {
+                        "type": "object",
+                        "properties": {
+                          <<ym-loop:apiParam removeEnd=",">>
+                          <<ym-if:<<resParam>>==true>>"<<fieldName>>": {
+                            "type": "<<fieldType>>",
+                            "description": "<<fieldTitle>>"
+                          },<</ym-if>><</ym-loop:apiParam>>
+                        },
+                        "x-apifox-orders": [
+                          <<ym-loop:apiParam removeEnd=",">>
+                          <<ym-if:<<resParam>>==true>>"<<fieldName>>",<</ym-if>><</ym-loop:apiParam>>
+                        ],
+                        "x-apifox-ignore-properties": []
+                      }
+                    }
+                  },
+                  "x-apifox-orders": [
+                    "status",
+                    "msg",
+                    "data"
+                  ],
+                  "x-apifox-ignore-properties": []
+                }
+              }
+            }
+          }
+        }
+      }
+    },<</ym-loop:apiInfo>>
+  }
+}