[mod] TSRPC

This commit is contained in:
2023-08-31 19:28:35 +08:00
parent f7559a5f27
commit e743a53f18
35 changed files with 2494 additions and 476 deletions

164
docs/openapi.json Normal file
View File

@@ -0,0 +1,164 @@
{
"openapi": "3.0.0",
"info": {
"title": "TSRPC Open API",
"version": "1.0.0"
},
"paths": {
"/Send": {
"post": {
"operationId": "Send",
"requestBody": {
"description": "Req<Send>",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PtlSend_ReqSend"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "ApiReturn<ResSend>",
"properties": {
"isSucc": {
"type": "boolean",
"enum": [
true
],
"default": true
},
"res": {
"$ref": "#/components/schemas/PtlSend_ResSend"
}
}
}
}
}
},
"default": {
"description": "Error",
"$ref": "#/components/responses/error"
}
}
}
}
},
"components": {
"schemas": {
"MsgChat_MsgChat": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"time": {
"type": "string",
"format": "date-time"
}
},
"required": [
"content",
"time"
]
},
"PtlSend_ReqSend": {
"type": "object",
"properties": {
"content": {
"type": "string"
}
},
"required": [
"content"
]
},
"PtlSend_ResSend": {
"type": "object",
"properties": {
"time": {
"type": "string",
"format": "date-time"
}
},
"required": [
"time"
]
},
"?bson_ObjectID": {
"type": "string"
},
"?bson_ObjectId": {
"type": "string"
},
"?mongodb_ObjectID": {
"type": "string"
},
"?mongodb_ObjectId": {
"type": "string"
}
},
"responses": {
"error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"type": "object",
"title": "API 错误",
"description": "业务错误ApiError返回 HTTP 状态码 200其它错误返回 HTTP 状态码 500",
"properties": {
"isSucc": {
"type": "boolean",
"enum": [
false
],
"default": false
},
"err": {
"type": "object",
"description": "TsrpcError",
"properties": {
"message": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"ApiError",
"NetworkError",
"ServerError",
"ClientError"
]
},
"code": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
],
"nullable": true
}
},
"required": [
"message",
"type"
]
}
}
}
}
}
}
}
}
}

34
docs/tsapi.md Normal file
View File

@@ -0,0 +1,34 @@
# TSRPC API 接口文档
## 通用说明
- 所有请求方法均为 `POST`
- 所有请求均需加入以下 Header :
- `Content-Type: application/json`
## 目录
- [Send](#/Send)
---
## Send <a id="/Send"></a>
**路径**
- POST `/Send`
**请求**
```ts
interface ReqSend {
content: string
}
```
**响应**
```ts
interface ResSend {
time: /*datetime*/ string
}
```