From ee8c2650c3e50e95f75574e6d31334a67207db90 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 22 Apr 2023 09:47:52 +0800 Subject: [PATCH] Remove useless "/api/login/oauth/code" API and update Swagger --- controllers/token.go | 34 ---- routers/router.go | 1 - swagger/swagger.json | 442 ++++++++++++++++++++++++++++++++++++------- swagger/swagger.yml | 294 +++++++++++++++++++++++----- 4 files changed, 625 insertions(+), 146 deletions(-) diff --git a/controllers/token.go b/controllers/token.go index 78767f2f..610472cc 100644 --- a/controllers/token.go +++ b/controllers/token.go @@ -124,40 +124,6 @@ func (c *ApiController) DeleteToken() { c.ServeJSON() } -// GetOAuthCode -// @Title GetOAuthCode -// @Tag Token API -// @Description get OAuth code -// @Param user_id query string true "The id ( owner/name ) of user" -// @Param client_id query string true "OAuth client id" -// @Param response_type query string true "OAuth response type" -// @Param redirect_uri query string true "OAuth redirect URI" -// @Param scope query string true "OAuth scope" -// @Param state query string true "OAuth state" -// @Success 200 {object} object.TokenWrapper The Response object -// @router /login/oauth/code [post] -func (c *ApiController) GetOAuthCode() { - userId := c.Input().Get("user_id") - clientId := c.Input().Get("client_id") - responseType := c.Input().Get("response_type") - redirectUri := c.Input().Get("redirect_uri") - scope := c.Input().Get("scope") - state := c.Input().Get("state") - nonce := c.Input().Get("nonce") - - challengeMethod := c.Input().Get("code_challenge_method") - codeChallenge := c.Input().Get("code_challenge") - - if challengeMethod != "S256" && challengeMethod != "null" && challengeMethod != "" { - c.ResponseError(c.T("auth:Challenge method should be S256")) - return - } - host := c.Ctx.Request.Host - - c.Data["json"] = object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state, nonce, codeChallenge, host, c.GetAcceptLanguage()) - c.ServeJSON() -} - // GetOAuthToken // @Title GetOAuthToken // @Tag Token API diff --git a/routers/router.go b/routers/router.go index e279d1da..c66fad41 100644 --- a/routers/router.go +++ b/routers/router.go @@ -155,7 +155,6 @@ func initAPI() { beego.Router("/api/update-token", &controllers.ApiController{}, "POST:UpdateToken") beego.Router("/api/add-token", &controllers.ApiController{}, "POST:AddToken") beego.Router("/api/delete-token", &controllers.ApiController{}, "POST:DeleteToken") - beego.Router("/api/login/oauth/code", &controllers.ApiController{}, "POST:GetOAuthCode") beego.Router("/api/login/oauth/access_token", &controllers.ApiController{}, "POST:GetOAuthToken") beego.Router("/api/login/oauth/refresh_token", &controllers.ApiController{}, "POST:RefreshToken") beego.Router("/api/login/oauth/introspect", &controllers.ApiController{}, "POST:IntrospectToken") diff --git a/swagger/swagger.json b/swagger/swagger.json index fad042a3..772b3b65 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -99,6 +99,34 @@ } } }, + "/api/add-chat": { + "post": { + "tags": [ + "Chat API" + ], + "description": "add chat", + "operationId": "ApiController.AddChat", + "parameters": [ + { + "in": "body", + "name": "body", + "description": "The details of the chat", + "required": true, + "schema": { + "$ref": "#/definitions/object.Chat" + } + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/controllers.Response" + } + } + } + } + }, "/api/add-ldap": { "post": { "tags": [ @@ -107,6 +135,34 @@ "operationId": "ApiController.AddLdap" } }, + "/api/add-message": { + "post": { + "tags": [ + "Message API" + ], + "description": "add message", + "operationId": "ApiController.AddMessage", + "parameters": [ + { + "in": "body", + "name": "body", + "description": "The details of the message", + "required": true, + "schema": { + "$ref": "#/definitions/object.Message" + } + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/controllers.Response" + } + } + } + } + }, "/api/add-model": { "post": { "tags": [ @@ -595,6 +651,14 @@ } } }, + "/api/api/verify-code": { + "post": { + "tags": [ + "Account API" + ], + "operationId": "ApiController.VerifyCode" + } + }, "/api/api/webhook": { "post": { "tags": [ @@ -700,6 +764,34 @@ } } }, + "/api/delete-chat": { + "post": { + "tags": [ + "Chat API" + ], + "description": "delete chat", + "operationId": "ApiController.DeleteChat", + "parameters": [ + { + "in": "body", + "name": "body", + "description": "The details of the chat", + "required": true, + "schema": { + "$ref": "#/definitions/object.Chat" + } + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/controllers.Response" + } + } + } + } + }, "/api/delete-ldap": { "post": { "tags": [ @@ -708,6 +800,34 @@ "operationId": "ApiController.DeleteLdap" } }, + "/api/delete-message": { + "post": { + "tags": [ + "Message API" + ], + "description": "delete message", + "operationId": "ApiController.DeleteMessage", + "parameters": [ + { + "in": "body", + "name": "body", + "description": "The details of the message", + "required": true, + "schema": { + "$ref": "#/definitions/object.Message" + } + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/controllers.Response" + } + } + } + } + }, "/api/delete-model": { "post": { "tags": [ @@ -1234,6 +1354,61 @@ } } }, + "/api/get-chat": { + "get": { + "tags": [ + "Chat API" + ], + "description": "get chat", + "operationId": "ApiController.GetChat", + "parameters": [ + { + "in": "query", + "name": "id", + "description": "The id ( owner/name ) of the chat", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/object.Chat" + } + } + } + } + }, + "/api/get-chats": { + "get": { + "tags": [ + "Chat API" + ], + "description": "get chats", + "operationId": "ApiController.GetChats", + "parameters": [ + { + "in": "query", + "name": "owner", + "description": "The owner of chats", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/object.Chat" + } + } + } + } + } + }, "/api/get-default-application": { "get": { "tags": [ @@ -1357,6 +1532,61 @@ "operationId": "ApiController.GetLdaps" } }, + "/api/get-message": { + "get": { + "tags": [ + "Message API" + ], + "description": "get message", + "operationId": "ApiController.GetMessage", + "parameters": [ + { + "in": "query", + "name": "id", + "description": "The id ( owner/name ) of the message", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/object.Message" + } + } + } + } + }, + "/api/get-messages": { + "get": { + "tags": [ + "Message API" + ], + "description": "get messages", + "operationId": "ApiController.GetMessages", + "parameters": [ + { + "in": "query", + "name": "owner", + "description": "The owner of messages", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/object.Message" + } + } + } + } + } + }, "/api/get-model": { "get": { "tags": [ @@ -2587,67 +2817,6 @@ } } }, - "/api/login/oauth/code": { - "post": { - "tags": [ - "Token API" - ], - "description": "get OAuth code", - "operationId": "ApiController.GetOAuthCode", - "parameters": [ - { - "in": "query", - "name": "id", - "description": "The id ( owner/name ) of user", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "client_id", - "description": "OAuth client id", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "response_type", - "description": "OAuth response type", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "redirect_uri", - "description": "OAuth redirect URI", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "scope", - "description": "OAuth scope", - "required": true, - "type": "string" - }, - { - "in": "query", - "name": "state", - "description": "OAuth state", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "The Response object", - "schema": { - "$ref": "#/definitions/object.TokenWrapper" - } - } - } - } - }, "/api/login/oauth/introspect": { "post": { "description": "The introspection endpoint is an OAuth 2.0 endpoint that takes a", @@ -3056,6 +3225,41 @@ } } }, + "/api/update-chat": { + "post": { + "tags": [ + "Chat API" + ], + "description": "update chat", + "operationId": "ApiController.UpdateChat", + "parameters": [ + { + "in": "query", + "name": "id", + "description": "The id ( owner/name ) of the chat", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "The details of the chat", + "required": true, + "schema": { + "$ref": "#/definitions/object.Chat" + } + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/controllers.Response" + } + } + } + } + }, "/api/update-ldap": { "post": { "tags": [ @@ -3064,6 +3268,41 @@ "operationId": "ApiController.UpdateLdap" } }, + "/api/update-message": { + "post": { + "tags": [ + "Message API" + ], + "description": "update message", + "operationId": "ApiController.UpdateMessage", + "parameters": [ + { + "in": "query", + "name": "id", + "description": "The id ( owner/name ) of the message", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "The details of the message", + "required": true, + "schema": { + "$ref": "#/definitions/object.Message" + } + } + ], + "responses": { + "200": { + "description": "The Response object", + "schema": { + "$ref": "#/definitions/controllers.Response" + } + } + } + } + }, "/api/update-model": { "post": { "tags": [ @@ -3644,11 +3883,11 @@ } }, "definitions": { - "2306.0xc0003a4480.false": { + "2306.0xc0004a1410.false": { "title": "false", "type": "object" }, - "2340.0xc0003a44b0.false": { + "2340.0xc0004a1440.false": { "title": "false", "type": "object" }, @@ -3782,10 +4021,10 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/2306.0xc0003a4480.false" + "$ref": "#/definitions/2306.0xc0004a1410.false" }, "data2": { - "$ref": "#/definitions/2340.0xc0003a44b0.false" + "$ref": "#/definitions/2340.0xc0004a1440.false" }, "msg": { "type": "string" @@ -4047,6 +4286,52 @@ } } }, + "object.Chat": { + "title": "Chat", + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "createdTime": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "messageCount": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "organization": { + "type": "string" + }, + "owner": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updatedTime": { + "type": "string" + }, + "user1": { + "type": "string" + }, + "user2": { + "type": "string" + }, + "users": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "object.Header": { "title": "Header", "type": "object", @@ -4125,6 +4410,33 @@ } } }, + "object.Message": { + "title": "Message", + "type": "object", + "properties": { + "author": { + "type": "string" + }, + "chat": { + "type": "string" + }, + "createdTime": { + "type": "string" + }, + "name": { + "type": "string" + }, + "organization": { + "type": "string" + }, + "owner": { + "type": "string" + }, + "text": { + "type": "string" + } + } + }, "object.Model": { "title": "Model", "type": "object", diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 1c4a5088..06e1d5b9 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -64,11 +64,47 @@ paths: description: The Response object schema: $ref: '#/definitions/controllers.Response' + /api/add-chat: + post: + tags: + - Chat API + description: add chat + operationId: ApiController.AddChat + parameters: + - in: body + name: body + description: The details of the chat + required: true + schema: + $ref: '#/definitions/object.Chat' + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/controllers.Response' /api/add-ldap: post: tags: - Account API operationId: ApiController.AddLdap + /api/add-message: + post: + tags: + - Message API + description: add message + operationId: ApiController.AddMessage + parameters: + - in: body + name: body + description: The details of the message + required: true + schema: + $ref: '#/definitions/object.Message' + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/controllers.Response' /api/add-model: post: tags: @@ -385,6 +421,11 @@ paths: description: object schema: $ref: '#/definitions/Response' + /api/api/verify-code: + post: + tags: + - Account API + operationId: ApiController.VerifyCode /api/api/webhook: post: tags: @@ -453,11 +494,47 @@ paths: description: The Response object schema: $ref: '#/definitions/controllers.Response' + /api/delete-chat: + post: + tags: + - Chat API + description: delete chat + operationId: ApiController.DeleteChat + parameters: + - in: body + name: body + description: The details of the chat + required: true + schema: + $ref: '#/definitions/object.Chat' + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/controllers.Response' /api/delete-ldap: post: tags: - Account API operationId: ApiController.DeleteLdap + /api/delete-message: + post: + tags: + - Message API + description: delete message + operationId: ApiController.DeleteMessage + parameters: + - in: body + name: body + description: The details of the message + required: true + schema: + $ref: '#/definitions/object.Message' + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/controllers.Response' /api/delete-model: post: tags: @@ -800,6 +877,42 @@ paths: type: array items: $ref: '#/definitions/object.Cert' + /api/get-chat: + get: + tags: + - Chat API + description: get chat + operationId: ApiController.GetChat + parameters: + - in: query + name: id + description: The id ( owner/name ) of the chat + required: true + type: string + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/object.Chat' + /api/get-chats: + get: + tags: + - Chat API + description: get chats + operationId: ApiController.GetChats + parameters: + - in: query + name: owner + description: The owner of chats + required: true + type: string + responses: + "200": + description: The Response object + schema: + type: array + items: + $ref: '#/definitions/object.Chat' /api/get-default-application: get: tags: @@ -880,6 +993,42 @@ paths: tags: - Account API operationId: ApiController.GetLdaps + /api/get-message: + get: + tags: + - Message API + description: get message + operationId: ApiController.GetMessage + parameters: + - in: query + name: id + description: The id ( owner/name ) of the message + required: true + type: string + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/object.Message' + /api/get-messages: + get: + tags: + - Message API + description: get messages + operationId: ApiController.GetMessages + parameters: + - in: query + name: owner + description: The owner of messages + required: true + type: string + responses: + "200": + description: The Response object + schema: + type: array + items: + $ref: '#/definitions/object.Message' /api/get-model: get: tags: @@ -1690,48 +1839,6 @@ paths: description: The Response object schema: $ref: '#/definitions/object.TokenError' - /api/login/oauth/code: - post: - tags: - - Token API - description: get OAuth code - operationId: ApiController.GetOAuthCode - parameters: - - in: query - name: id - description: The id ( owner/name ) of user - required: true - type: string - - in: query - name: client_id - description: OAuth client id - required: true - type: string - - in: query - name: response_type - description: OAuth response type - required: true - type: string - - in: query - name: redirect_uri - description: OAuth redirect URI - required: true - type: string - - in: query - name: scope - description: OAuth scope - required: true - type: string - - in: query - name: state - description: OAuth state - required: true - type: string - responses: - "200": - description: The Response object - schema: - $ref: '#/definitions/object.TokenWrapper' /api/login/oauth/introspect: post: description: The introspection endpoint is an OAuth 2.0 endpoint that takes a @@ -2001,11 +2108,57 @@ paths: description: The Response object schema: $ref: '#/definitions/controllers.Response' + /api/update-chat: + post: + tags: + - Chat API + description: update chat + operationId: ApiController.UpdateChat + parameters: + - in: query + name: id + description: The id ( owner/name ) of the chat + required: true + type: string + - in: body + name: body + description: The details of the chat + required: true + schema: + $ref: '#/definitions/object.Chat' + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/controllers.Response' /api/update-ldap: post: tags: - Account API operationId: ApiController.UpdateLdap + /api/update-message: + post: + tags: + - Message API + description: update message + operationId: ApiController.UpdateMessage + parameters: + - in: query + name: id + description: The id ( owner/name ) of the message + required: true + type: string + - in: body + name: body + description: The details of the message + required: true + schema: + $ref: '#/definitions/object.Message' + responses: + "200": + description: The Response object + schema: + $ref: '#/definitions/controllers.Response' /api/update-model: post: tags: @@ -2385,10 +2538,10 @@ paths: schema: $ref: '#/definitions/Response' definitions: - 2306.0xc0003a4480.false: + 2306.0xc0004a1410.false: title: "false" type: object - 2340.0xc0003a44b0.false: + 2340.0xc0004a1440.false: title: "false" type: object LaravelResponse: @@ -2480,9 +2633,9 @@ definitions: type: object properties: data: - $ref: '#/definitions/2306.0xc0003a4480.false' + $ref: '#/definitions/2306.0xc0004a1410.false' data2: - $ref: '#/definitions/2340.0xc0003a44b0.false' + $ref: '#/definitions/2340.0xc0004a1440.false' msg: type: string name: @@ -2657,6 +2810,37 @@ definitions: type: string type: type: string + object.Chat: + title: Chat + type: object + properties: + category: + type: string + createdTime: + type: string + displayName: + type: string + messageCount: + type: integer + format: int64 + name: + type: string + organization: + type: string + owner: + type: string + type: + type: string + updatedTime: + type: string + user1: + type: string + user2: + type: string + users: + type: array + items: + type: string object.Header: title: Header type: object @@ -2710,6 +2894,24 @@ definitions: type: string username: type: string + object.Message: + title: Message + type: object + properties: + author: + type: string + chat: + type: string + createdTime: + type: string + name: + type: string + organization: + type: string + owner: + type: string + text: + type: string object.Model: title: Model type: object