917 lines
31 KiB
JSON
917 lines
31 KiB
JSON
{
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"title": "Recommender API",
|
|
"contact": {},
|
|
"version": "1.0"
|
|
},
|
|
"paths": {
|
|
"/api/v1/application/{application_id}/tokens": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "获取应用程序的 Token 列表",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"applications"
|
|
],
|
|
"summary": "获取应用程序的 Token 列表",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"name": "application_id",
|
|
"in": "path"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/entity.ApplicationToken"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "获取应用程序的 Token 列表",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"applications"
|
|
],
|
|
"summary": "获取应用程序的 Token 列表",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"name": "application_id",
|
|
"in": "path"
|
|
},
|
|
{
|
|
"description": "创建应用程序的请求",
|
|
"name": "ApplicationCreateRequest",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/request.ApplicationCreateRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.ApplicationToken"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/applications": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "列出当前用户下的应用程序列表",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"applications"
|
|
],
|
|
"summary": "List Applications",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "创建一个应用程序",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"applications"
|
|
],
|
|
"summary": "创建并保存一个应用程序",
|
|
"parameters": [
|
|
{
|
|
"description": "创建应用程序的请求",
|
|
"name": "ApplicationCreateRequest",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/request.ApplicationCreateRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/applications/v1/categories": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "列出分类",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "列出分类",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/page.PagedResult-entity_Category"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "新建分类",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "新建分类",
|
|
"parameters": [
|
|
{
|
|
"description": "body",
|
|
"name": "CategorySaveRequest",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/request.CategorySaveRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/applications/v1/categories/{category_id}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "获取 Post",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "获取 Post",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"name": "category_id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Category"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "删除分类",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "删除分类",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"name": "category_id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Category"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/applications/v1/info": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "当前的应用程序信息",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "Current Application Info",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/applications/v1/post/{post_id}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "获取 Post",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "获取 Post",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"name": "post_id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Post"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "删除 Post",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "删除 Post",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"name": "post_id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Post"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/applications/v1/posts": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "列出 Posts",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "列出 Posts",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/page.PagedResult-entity_Post"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"ApiKeyAuth": []
|
|
}
|
|
],
|
|
"description": "新建资源",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"application_api"
|
|
],
|
|
"summary": "新建资源",
|
|
"parameters": [
|
|
{
|
|
"description": "body",
|
|
"name": "PostSaveRequest",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/request.PostSaveRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {
|
|
"$ref": "#/definitions/entity.Post"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"$ref": "#/definitions/response.ResponseBody"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"entity.Application": {
|
|
"type": "object",
|
|
"properties": {
|
|
"created_at": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"updated_at": {
|
|
"type": "string"
|
|
},
|
|
"user_id": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"entity.ApplicationToken": {
|
|
"type": "object",
|
|
"properties": {
|
|
"application": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
},
|
|
"application_id": {
|
|
"type": "integer"
|
|
},
|
|
"created_at": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"token": {
|
|
"type": "string"
|
|
},
|
|
"updated_at": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"entity.Category": {
|
|
"type": "object",
|
|
"properties": {
|
|
"application": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
},
|
|
"application_id": {
|
|
"type": "integer"
|
|
},
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"entity.Post": {
|
|
"type": "object",
|
|
"properties": {
|
|
"application": {
|
|
"$ref": "#/definitions/entity.Application"
|
|
},
|
|
"application_id": {
|
|
"type": "integer"
|
|
},
|
|
"category": {
|
|
"$ref": "#/definitions/entity.Category"
|
|
},
|
|
"category_id": {
|
|
"type": "integer"
|
|
},
|
|
"content": {
|
|
"type": "string"
|
|
},
|
|
"created_at": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "integer"
|
|
},
|
|
"processed": {
|
|
"type": "boolean"
|
|
},
|
|
"target_id": {
|
|
"type": "string"
|
|
},
|
|
"title": {
|
|
"type": "string"
|
|
},
|
|
"updated_at": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"page.PagedResult-entity_Category": {
|
|
"type": "object",
|
|
"properties": {
|
|
"count": {
|
|
"type": "integer"
|
|
},
|
|
"data": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/entity.Category"
|
|
}
|
|
},
|
|
"page": {
|
|
"description": "当前页码",
|
|
"type": "integer"
|
|
},
|
|
"page_size": {
|
|
"description": "每页大小",
|
|
"type": "integer"
|
|
},
|
|
"total_count": {
|
|
"description": "数据总条数",
|
|
"type": "integer"
|
|
},
|
|
"total_pages": {
|
|
"description": "总页数",
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"page.PagedResult-entity_Post": {
|
|
"type": "object",
|
|
"properties": {
|
|
"count": {
|
|
"type": "integer"
|
|
},
|
|
"data": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/entity.Post"
|
|
}
|
|
},
|
|
"page": {
|
|
"description": "当前页码",
|
|
"type": "integer"
|
|
},
|
|
"page_size": {
|
|
"description": "每页大小",
|
|
"type": "integer"
|
|
},
|
|
"total_count": {
|
|
"description": "数据总条数",
|
|
"type": "integer"
|
|
},
|
|
"total_pages": {
|
|
"description": "总页数",
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"request.ApplicationCreateRequest": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"request.CategorySaveRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"name"
|
|
],
|
|
"properties": {
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"request.PostSaveRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"category_id",
|
|
"content",
|
|
"target_id",
|
|
"title"
|
|
],
|
|
"properties": {
|
|
"category_id": {
|
|
"type": "integer"
|
|
},
|
|
"content": {
|
|
"type": "string"
|
|
},
|
|
"target_id": {
|
|
"type": "string"
|
|
},
|
|
"title": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"response.ResponseBody": {
|
|
"type": "object",
|
|
"properties": {
|
|
"data": {},
|
|
"error": {
|
|
"type": "string"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
},
|
|
"success": {
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"securityDefinitions": {
|
|
"ApiKeyAuth": {
|
|
"type": "apiKey",
|
|
"name": "Authorization",
|
|
"in": "header"
|
|
}
|
|
}
|
|
} |