From c62dc45a85b1b52777bcd2b0ea849d7c2a100e9e Mon Sep 17 00:00:00 2001 From: crummy Date: Fri, 25 Oct 2024 10:18:55 +1300 Subject: [PATCH 1/7] Fix linting warnings in swagger files --- src/docs/swagger.json | 26 ++++++++++++++++++++++++-- src/docs/swagger.yaml | 18 +++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 1a8a2ef..8fbf96c 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -1400,6 +1400,13 @@ ], "summary": "Send a reaction.", "parameters": [ + { + "description": "Reaction ID", + "name": "number", + "in": "path", + "required": true, + "type": "number" + }, { "description": "Reaction", "name": "data", @@ -1438,6 +1445,13 @@ ], "summary": "Remove a reaction.", "parameters": [ + { + "description": "Reaction ID", + "name": "number", + "in": "path", + "required": true, + "type": "number" + }, { "description": "Reaction", "name": "data", @@ -1478,6 +1492,13 @@ ], "summary": "Send a receipt.", "parameters": [ + { + "description": "Receipt ID", + "name": "number", + "in": "path", + "required": true, + "type": "number" + }, { "description": "Receipt", "name": "data", @@ -1671,7 +1692,7 @@ } } }, - "/v1/search": { + "/v1/search/{number}": { "get": { "description": "Check if one or more phone numbers are registered with the Signal Service.", "consumes": [ @@ -1689,7 +1710,8 @@ "type": "string", "description": "Registered Phone Number", "name": "number", - "in": "path" + "in": "path", + "required": true }, { "type": "array", diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 18ef93f..af6db85 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -1329,6 +1329,11 @@ paths: - application/json description: Remove a reaction parameters: + - description: Reaction ID + name: number + in: path + required: true + type: number - description: Reaction in: body name: data @@ -1354,6 +1359,11 @@ paths: - application/json description: React to a message parameters: + - description: Reaction ID + name: number + in: path + required: true + type: number - description: Reaction in: body name: data @@ -1380,6 +1390,11 @@ paths: - application/json description: Send a read or viewed receipt parameters: + - description: Receipt ID + name: number + in: path + required: true + type: number - description: Receipt in: body name: data @@ -1514,7 +1529,7 @@ paths: summary: Verify a registered phone number. tags: - Devices - /v1/search: + /v1/search/{number}: get: consumes: - application/json @@ -1525,6 +1540,7 @@ paths: in: path name: number type: string + required: true - collectionFormat: multi description: Numbers to check in: query From e16eed4580563e5781eee70e9833956ac3455bff Mon Sep 17 00:00:00 2001 From: crummy Date: Sat, 26 Oct 2024 13:55:55 +1300 Subject: [PATCH 2/7] Add default host to satisfy liblab --- src/docs/swagger.json | 1 + src/docs/swagger.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 8fbf96c..b27a40c 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -6,6 +6,7 @@ "contact": {}, "version": "1.0" }, + "host": "localhost:8080", "basePath": "/", "paths": { "/v1/about": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index af6db85..4d02f07 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -1,3 +1,4 @@ +host: localhost:8080 basePath: / definitions: api.AddDeviceRequest: From a8494b70bd2136f8ae7c876ada087a51bd9268ac Mon Sep 17 00:00:00 2001 From: crummy Date: Sat, 26 Oct 2024 14:04:19 +1300 Subject: [PATCH 3/7] Add scheme to satisfy liblab --- src/docs/swagger.json | 1 + src/docs/swagger.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/docs/swagger.json b/src/docs/swagger.json index b27a40c..541c74e 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -8,6 +8,7 @@ }, "host": "localhost:8080", "basePath": "/", + "schemes": ["http"], "paths": { "/v1/about": { "get": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 4d02f07..d348bcb 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -1,5 +1,7 @@ host: localhost:8080 basePath: / +schemes: + - http definitions: api.AddDeviceRequest: properties: From 26a5a6039bdb4979b0fc248bb8f94ff9e5607a52 Mon Sep 17 00:00:00 2001 From: crummy Date: Mon, 28 Oct 2024 13:07:05 +1300 Subject: [PATCH 4/7] Update swagger files from code, with swag tool --- src/api/api.go | 3 + src/docs/README.md | 13 +++++ src/docs/docs.go | 106 +++++++++------------------------ src/docs/swagger.json | 132 ++++++++++-------------------------------- src/docs/swagger.yaml | 92 +++++++---------------------- src/main.go | 2 + 6 files changed, 96 insertions(+), 252 deletions(-) create mode 100644 src/docs/README.md diff --git a/src/api/api.go b/src/api/api.go index c155518..642b5ad 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -1416,6 +1416,7 @@ func (a *Api) UpdateGroup(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Reaction true "Reaction" +// @Param id path int true "Reaction Identifier" // @Router /v1/reactions/{number} [post] func (a *Api) SendReaction(c *gin.Context) { var req Reaction @@ -1464,6 +1465,7 @@ func (a *Api) SendReaction(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Reaction true "Reaction" +// @Param id path int true "Reaction Identifier" // @Router /v1/reactions/{number} [delete] func (a *Api) RemoveReaction(c *gin.Context) { var req Reaction @@ -1507,6 +1509,7 @@ func (a *Api) RemoveReaction(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Receipt true "Receipt" +// @Param id path int true "Receipt Identifier" // @Router /v1/receipts/{number} [post] func (a *Api) SendReceipt(c *gin.Context) { var req Receipt diff --git a/src/docs/README.md b/src/docs/README.md new file mode 100644 index 0000000..08b925d --- /dev/null +++ b/src/docs/README.md @@ -0,0 +1,13 @@ +These files are generated from the [swaggo/swag](https://github.com/swaggo/swag) tool. + +To regenerate them, run: + +```bash +docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest init +``` + +Or, if you have `swag` installed: + +```bash +swag init +``` \ No newline at end of file diff --git a/src/docs/docs.go b/src/docs/docs.go index f985e13..dd62453 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -1415,6 +1415,13 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/api.Reaction" } + }, + { + "type": "integer", + "description": "Reaction Identifier", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -1453,6 +1460,13 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/api.Reaction" } + }, + { + "type": "integer", + "description": "Reaction Identifier", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -1493,6 +1507,13 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/api.Receipt" } + }, + { + "type": "integer", + "description": "Receipt Identifier", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -2278,69 +2299,7 @@ const docTemplate = `{ } }, "api.SendMessageV2": { - "type": "object", - "properties": { - "base64_attachments": { - "type": "array", - "items": { - "type": "string" - }, - "example": [ - "\u003cBASE64 ENCODED DATA\u003e", - "data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e", - "data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e" - ] - }, - "edit_timestamp": { - "type": "integer" - }, - "mentions": { - "type": "array", - "items": { - "$ref": "#/definitions/data.MessageMention" - } - }, - "message": { - "type": "string" - }, - "notify_self": { - "type": "boolean" - }, - "number": { - "type": "string" - }, - "quote_author": { - "type": "string" - }, - "quote_mentions": { - "type": "array", - "items": { - "$ref": "#/definitions/data.MessageMention" - } - }, - "quote_message": { - "type": "string" - }, - "quote_timestamp": { - "type": "integer" - }, - "recipients": { - "type": "array", - "items": { - "type": "string" - } - }, - "sticker": { - "type": "string" - }, - "text_mode": { - "type": "string", - "enum": [ - "normal", - "styled" - ] - } - } + "type": "object" }, "api.SetUsernameRequest": { "type": "object", @@ -2442,6 +2401,9 @@ const docTemplate = `{ "api.UpdateProfileRequest": { "type": "object", "properties": { + "about": { + "type": "string" + }, "base64_avatar": { "type": "string" }, @@ -2610,20 +2572,6 @@ const docTemplate = `{ "type": "string" } } - }, - "data.MessageMention": { - "type": "object", - "properties": { - "author": { - "type": "string" - }, - "length": { - "type": "integer" - }, - "start": { - "type": "integer" - } - } } }, "tags": [ @@ -2681,9 +2629,9 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "1.0", - Host: "", + Host: "localhost:8080", BasePath: "/", - Schemes: []string{}, + Schemes: []string{"http"}, Title: "Signal Cli REST API", Description: "This is the Signal Cli REST API documentation.", InfoInstanceName: "swagger", diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 541c74e..bbc1ebc 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -1,4 +1,7 @@ { + "schemes": [ + "http" + ], "swagger": "2.0", "info": { "description": "This is the Signal Cli REST API documentation.", @@ -8,7 +11,6 @@ }, "host": "localhost:8080", "basePath": "/", - "schemes": ["http"], "paths": { "/v1/about": { "get": { @@ -1402,13 +1404,6 @@ ], "summary": "Send a reaction.", "parameters": [ - { - "description": "Reaction ID", - "name": "number", - "in": "path", - "required": true, - "type": "number" - }, { "description": "Reaction", "name": "data", @@ -1417,6 +1412,13 @@ "schema": { "$ref": "#/definitions/api.Reaction" } + }, + { + "type": "integer", + "description": "Reaction Identifier", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -1447,13 +1449,6 @@ ], "summary": "Remove a reaction.", "parameters": [ - { - "description": "Reaction ID", - "name": "number", - "in": "path", - "required": true, - "type": "number" - }, { "description": "Reaction", "name": "data", @@ -1462,6 +1457,13 @@ "schema": { "$ref": "#/definitions/api.Reaction" } + }, + { + "type": "integer", + "description": "Reaction Identifier", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -1494,13 +1496,6 @@ ], "summary": "Send a receipt.", "parameters": [ - { - "description": "Receipt ID", - "name": "number", - "in": "path", - "required": true, - "type": "number" - }, { "description": "Receipt", "name": "data", @@ -1509,6 +1504,13 @@ "schema": { "$ref": "#/definitions/api.Receipt" } + }, + { + "type": "integer", + "description": "Receipt Identifier", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -1694,7 +1696,7 @@ } } }, - "/v1/search/{number}": { + "/v1/search": { "get": { "description": "Check if one or more phone numbers are registered with the Signal Service.", "consumes": [ @@ -1712,8 +1714,7 @@ "type": "string", "description": "Registered Phone Number", "name": "number", - "in": "path", - "required": true + "in": "path" }, { "type": "array", @@ -2295,69 +2296,7 @@ } }, "api.SendMessageV2": { - "type": "object", - "properties": { - "base64_attachments": { - "type": "array", - "items": { - "type": "string" - }, - "example": [ - "\u003cBASE64 ENCODED DATA\u003e", - "data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e", - "data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e" - ] - }, - "edit_timestamp": { - "type": "integer" - }, - "mentions": { - "type": "array", - "items": { - "$ref": "#/definitions/data.MessageMention" - } - }, - "message": { - "type": "string" - }, - "notify_self": { - "type": "boolean" - }, - "number": { - "type": "string" - }, - "quote_author": { - "type": "string" - }, - "quote_mentions": { - "type": "array", - "items": { - "$ref": "#/definitions/data.MessageMention" - } - }, - "quote_message": { - "type": "string" - }, - "quote_timestamp": { - "type": "integer" - }, - "recipients": { - "type": "array", - "items": { - "type": "string" - } - }, - "sticker": { - "type": "string" - }, - "text_mode": { - "type": "string", - "enum": [ - "normal", - "styled" - ] - } - } + "type": "object" }, "api.SetUsernameRequest": { "type": "object", @@ -2459,6 +2398,9 @@ "api.UpdateProfileRequest": { "type": "object", "properties": { + "about": { + "type": "string" + }, "base64_avatar": { "type": "string" }, @@ -2627,20 +2569,6 @@ "type": "string" } } - }, - "data.MessageMention": { - "type": "object", - "properties": { - "author": { - "type": "string" - }, - "length": { - "type": "integer" - }, - "start": { - "type": "integer" - } - } } }, "tags": [ diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index d348bcb..634f5e7 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -1,7 +1,4 @@ -host: localhost:8080 basePath: / -schemes: - - http definitions: api.AddDeviceRequest: properties: @@ -166,48 +163,6 @@ definitions: type: array type: object api.SendMessageV2: - properties: - base64_attachments: - example: - - - - data:;base64 - - data:;filename=;base64 - items: - type: string - type: array - edit_timestamp: - type: integer - mentions: - items: - $ref: '#/definitions/data.MessageMention' - type: array - message: - type: string - notify_self: - type: boolean - number: - type: string - quote_author: - type: string - quote_mentions: - items: - $ref: '#/definitions/data.MessageMention' - type: array - quote_message: - type: string - quote_timestamp: - type: integer - recipients: - items: - type: string - type: array - sticker: - type: string - text_mode: - enum: - - normal - - styled - type: string type: object api.SetUsernameRequest: properties: @@ -274,6 +229,8 @@ definitions: type: object api.UpdateProfileRequest: properties: + about: + type: string base64_avatar: type: string name: @@ -384,15 +341,7 @@ definitions: username_link: type: string type: object - data.MessageMention: - properties: - author: - type: string - length: - type: integer - start: - type: integer - type: object +host: localhost:8080 info: contact: {} description: This is the Signal Cli REST API documentation. @@ -1332,17 +1281,17 @@ paths: - application/json description: Remove a reaction parameters: - - description: Reaction ID - name: number - in: path - required: true - type: number - description: Reaction in: body name: data required: true schema: $ref: '#/definitions/api.Reaction' + - description: Reaction Identifier + in: path + name: id + required: true + type: integer produces: - application/json responses: @@ -1362,17 +1311,17 @@ paths: - application/json description: React to a message parameters: - - description: Reaction ID - name: number - in: path - required: true - type: number - description: Reaction in: body name: data required: true schema: $ref: '#/definitions/api.Reaction' + - description: Reaction Identifier + in: path + name: id + required: true + type: integer produces: - application/json responses: @@ -1393,17 +1342,17 @@ paths: - application/json description: Send a read or viewed receipt parameters: - - description: Receipt ID - name: number - in: path - required: true - type: number - description: Receipt in: body name: data required: true schema: $ref: '#/definitions/api.Receipt' + - description: Receipt Identifier + in: path + name: id + required: true + type: integer produces: - application/json responses: @@ -1532,7 +1481,7 @@ paths: summary: Verify a registered phone number. tags: - Devices - /v1/search/{number}: + /v1/search: get: consumes: - application/json @@ -1543,7 +1492,6 @@ paths: in: path name: number type: string - required: true - collectionFormat: multi description: Numbers to check in: query @@ -1775,6 +1723,8 @@ paths: summary: Send a signal message. tags: - Messages +schemes: +- http swagger: "2.0" tags: - description: Some general endpoints. diff --git a/src/main.go b/src/main.go index 8e51733..37e95ff 100644 --- a/src/main.go +++ b/src/main.go @@ -58,6 +58,8 @@ import ( // @tag.name Sticker Packs // @tag.description List and Install Sticker Packs +// @host localhost:8080 +// @schemes http // @BasePath / func main() { signalCliConfig := flag.String("signal-cli-config", "/home/.local/share/signal-cli/", "Config directory where signal-cli config is stored") From 8ac02d28eb78bf8f975240e2f3433d227091610e Mon Sep 17 00:00:00 2001 From: crummy Date: Mon, 28 Oct 2024 13:37:50 +1300 Subject: [PATCH 5/7] Correct "number" - it's actually the phone number --- src/api/api.go | 6 +++--- src/docs/README.md | 2 +- src/docs/docs.go | 12 ++++++------ src/docs/swagger.json | 12 ++++++------ src/docs/swagger.yaml | 12 ++++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/api/api.go b/src/api/api.go index 642b5ad..bab9956 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -1416,7 +1416,7 @@ func (a *Api) UpdateGroup(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Reaction true "Reaction" -// @Param id path int true "Reaction Identifier" +// @Param id path string true "Phone number" // @Router /v1/reactions/{number} [post] func (a *Api) SendReaction(c *gin.Context) { var req Reaction @@ -1465,7 +1465,7 @@ func (a *Api) SendReaction(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Reaction true "Reaction" -// @Param id path int true "Reaction Identifier" +// @Param id path string true "Phone number" // @Router /v1/reactions/{number} [delete] func (a *Api) RemoveReaction(c *gin.Context) { var req Reaction @@ -1509,7 +1509,7 @@ func (a *Api) RemoveReaction(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Receipt true "Receipt" -// @Param id path int true "Receipt Identifier" +// @Param id path string true "Phone number" // @Router /v1/receipts/{number} [post] func (a *Api) SendReceipt(c *gin.Context) { var req Receipt diff --git a/src/docs/README.md b/src/docs/README.md index 08b925d..eb559cb 100644 --- a/src/docs/README.md +++ b/src/docs/README.md @@ -1,6 +1,6 @@ These files are generated from the [swaggo/swag](https://github.com/swaggo/swag) tool. -To regenerate them, run: +To regenerate them, run in /src: ```bash docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest init diff --git a/src/docs/docs.go b/src/docs/docs.go index dd62453..bee7032 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -1417,8 +1417,8 @@ const docTemplate = `{ } }, { - "type": "integer", - "description": "Reaction Identifier", + "type": "string", + "description": "Phone number", "name": "id", "in": "path", "required": true @@ -1462,8 +1462,8 @@ const docTemplate = `{ } }, { - "type": "integer", - "description": "Reaction Identifier", + "type": "string", + "description": "Phone number", "name": "id", "in": "path", "required": true @@ -1509,8 +1509,8 @@ const docTemplate = `{ } }, { - "type": "integer", - "description": "Receipt Identifier", + "type": "string", + "description": "Phone number", "name": "id", "in": "path", "required": true diff --git a/src/docs/swagger.json b/src/docs/swagger.json index bbc1ebc..f485cdf 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -1414,8 +1414,8 @@ } }, { - "type": "integer", - "description": "Reaction Identifier", + "type": "string", + "description": "Phone number", "name": "id", "in": "path", "required": true @@ -1459,8 +1459,8 @@ } }, { - "type": "integer", - "description": "Reaction Identifier", + "type": "string", + "description": "Phone number", "name": "id", "in": "path", "required": true @@ -1506,8 +1506,8 @@ } }, { - "type": "integer", - "description": "Receipt Identifier", + "type": "string", + "description": "Phone number", "name": "id", "in": "path", "required": true diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 634f5e7..285f723 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -1287,11 +1287,11 @@ paths: required: true schema: $ref: '#/definitions/api.Reaction' - - description: Reaction Identifier + - description: Phone number in: path name: id required: true - type: integer + type: string produces: - application/json responses: @@ -1317,11 +1317,11 @@ paths: required: true schema: $ref: '#/definitions/api.Reaction' - - description: Reaction Identifier + - description: Phone number in: path name: id required: true - type: integer + type: string produces: - application/json responses: @@ -1348,11 +1348,11 @@ paths: required: true schema: $ref: '#/definitions/api.Receipt' - - description: Receipt Identifier + - description: Phone number in: path name: id required: true - type: integer + type: string produces: - application/json responses: From 495003f73a360458f838f990aa1256143cb0005f Mon Sep 17 00:00:00 2001 From: crummy Date: Fri, 1 Nov 2024 21:32:27 +1300 Subject: [PATCH 6/7] Re-add missing lines --- src/docs/swagger.json | 78 ++++++++++++++++++++++++++++++++++++++++++- src/docs/swagger.yaml | 51 +++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 2 deletions(-) diff --git a/src/docs/swagger.json b/src/docs/swagger.json index f485cdf..a251f00 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -2296,7 +2296,69 @@ } }, "api.SendMessageV2": { - "type": "object" + "type": "object", + "properties": { + "base64_attachments": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "\u003cBASE64 ENCODED DATA\u003e", + "data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e", + "data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e" + ] + }, + "edit_timestamp": { + "type": "integer" + }, + "mentions": { + "type": "array", + "items": { + "$ref": "#/definitions/data.MessageMention" + } + }, + "message": { + "type": "string" + }, + "notify_self": { + "type": "boolean" + }, + "number": { + "type": "string" + }, + "quote_author": { + "type": "string" + }, + "quote_mentions": { + "type": "array", + "items": { + "$ref": "#/definitions/data.MessageMention" + } + }, + "quote_message": { + "type": "string" + }, + "quote_timestamp": { + "type": "integer" + }, + "recipients": { + "type": "array", + "items": { + "type": "string" + } + }, + "sticker": { + "type": "string" + }, + "text_mode": { + "type": "string", + "enum": [ + "normal", + "styled" + ] + } + } }, "api.SetUsernameRequest": { "type": "object", @@ -2569,6 +2631,20 @@ "type": "string" } } + }, + "data.MessageMention": { + "type": "object", + "properties": { + "author": { + "type": "string" + }, + "length": { + "type": "integer" + }, + "start": { + "type": "integer" + } + } } }, "tags": [ diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 285f723..ae9d167 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -163,7 +163,48 @@ definitions: type: array type: object api.SendMessageV2: - type: object + properties: + base64_attachments: + example: + - + - data:;base64 + - data:;filename=;base64 + items: + type: string + type: array + edit_timestamp: + type: integer + mentions: + items: + $ref: '#/definitions/data.MessageMention' + type: array + message: + type: string + notify_self: + type: boolean + number: + type: string + quote_author: + type: string + quote_mentions: + items: + $ref: '#/definitions/data.MessageMention' + type: array + quote_message: + type: string + quote_timestamp: + type: integer + recipients: + items: + type: string + type: array + sticker: + type: string + text_mode: + enum: + - normal + - styled + type: string api.SetUsernameRequest: properties: username: @@ -341,6 +382,14 @@ definitions: username_link: type: string type: object + data.MessageMention: + properties: + author: + type: string + length: + type: integer + start: + type: integer host: localhost:8080 info: contact: {} From 3eeaafca4d4cf00dbb8f4d9d517d34a5b4d90ae8 Mon Sep 17 00:00:00 2001 From: crummy Date: Mon, 4 Nov 2024 19:41:14 +1300 Subject: [PATCH 7/7] Correct field name --- src/api/api.go | 12 +++--- src/docs/docs.go | 12 +++--- src/docs/swagger.json | 90 ++++--------------------------------------- src/docs/swagger.yaml | 63 ++++-------------------------- 4 files changed, 26 insertions(+), 151 deletions(-) diff --git a/src/api/api.go b/src/api/api.go index bab9956..a4993ad 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -144,9 +144,9 @@ type CreateGroupResponse struct { } type UpdateProfileRequest struct { - Name string `json:"name"` - Base64Avatar string `json:"base64_avatar"` - About *string `json:"about"` + Name string `json:"name"` + Base64Avatar string `json:"base64_avatar"` + About *string `json:"about"` } type TrustIdentityRequest struct { @@ -1416,7 +1416,7 @@ func (a *Api) UpdateGroup(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Reaction true "Reaction" -// @Param id path string true "Phone number" +// @Param number path string true "Registered phone number" // @Router /v1/reactions/{number} [post] func (a *Api) SendReaction(c *gin.Context) { var req Reaction @@ -1465,7 +1465,7 @@ func (a *Api) SendReaction(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Reaction true "Reaction" -// @Param id path string true "Phone number" +// @Param number path string true "Registered phone number" // @Router /v1/reactions/{number} [delete] func (a *Api) RemoveReaction(c *gin.Context) { var req Reaction @@ -1509,7 +1509,7 @@ func (a *Api) RemoveReaction(c *gin.Context) { // @Success 204 {string} OK // @Failure 400 {object} Error // @Param data body Receipt true "Receipt" -// @Param id path string true "Phone number" +// @Param number path string true "Registered phone number" // @Router /v1/receipts/{number} [post] func (a *Api) SendReceipt(c *gin.Context) { var req Receipt diff --git a/src/docs/docs.go b/src/docs/docs.go index bee7032..b9a8b50 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -1418,8 +1418,8 @@ const docTemplate = `{ }, { "type": "string", - "description": "Phone number", - "name": "id", + "description": "Registered phone number", + "name": "number", "in": "path", "required": true } @@ -1463,8 +1463,8 @@ const docTemplate = `{ }, { "type": "string", - "description": "Phone number", - "name": "id", + "description": "Registered phone number", + "name": "number", "in": "path", "required": true } @@ -1510,8 +1510,8 @@ const docTemplate = `{ }, { "type": "string", - "description": "Phone number", - "name": "id", + "description": "Registered phone number", + "name": "number", "in": "path", "required": true } diff --git a/src/docs/swagger.json b/src/docs/swagger.json index a251f00..5e5497c 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -1415,8 +1415,8 @@ }, { "type": "string", - "description": "Phone number", - "name": "id", + "description": "Registered phone number", + "name": "number", "in": "path", "required": true } @@ -1460,8 +1460,8 @@ }, { "type": "string", - "description": "Phone number", - "name": "id", + "description": "Registered phone number", + "name": "number", "in": "path", "required": true } @@ -1507,8 +1507,8 @@ }, { "type": "string", - "description": "Phone number", - "name": "id", + "description": "Registered phone number", + "name": "number", "in": "path", "required": true } @@ -2296,69 +2296,7 @@ } }, "api.SendMessageV2": { - "type": "object", - "properties": { - "base64_attachments": { - "type": "array", - "items": { - "type": "string" - }, - "example": [ - "\u003cBASE64 ENCODED DATA\u003e", - "data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e", - "data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e" - ] - }, - "edit_timestamp": { - "type": "integer" - }, - "mentions": { - "type": "array", - "items": { - "$ref": "#/definitions/data.MessageMention" - } - }, - "message": { - "type": "string" - }, - "notify_self": { - "type": "boolean" - }, - "number": { - "type": "string" - }, - "quote_author": { - "type": "string" - }, - "quote_mentions": { - "type": "array", - "items": { - "$ref": "#/definitions/data.MessageMention" - } - }, - "quote_message": { - "type": "string" - }, - "quote_timestamp": { - "type": "integer" - }, - "recipients": { - "type": "array", - "items": { - "type": "string" - } - }, - "sticker": { - "type": "string" - }, - "text_mode": { - "type": "string", - "enum": [ - "normal", - "styled" - ] - } - } + "type": "object" }, "api.SetUsernameRequest": { "type": "object", @@ -2631,20 +2569,6 @@ "type": "string" } } - }, - "data.MessageMention": { - "type": "object", - "properties": { - "author": { - "type": "string" - }, - "length": { - "type": "integer" - }, - "start": { - "type": "integer" - } - } } }, "tags": [ diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index ae9d167..00df1b4 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -163,48 +163,7 @@ definitions: type: array type: object api.SendMessageV2: - properties: - base64_attachments: - example: - - - - data:;base64 - - data:;filename=;base64 - items: - type: string - type: array - edit_timestamp: - type: integer - mentions: - items: - $ref: '#/definitions/data.MessageMention' - type: array - message: - type: string - notify_self: - type: boolean - number: - type: string - quote_author: - type: string - quote_mentions: - items: - $ref: '#/definitions/data.MessageMention' - type: array - quote_message: - type: string - quote_timestamp: - type: integer - recipients: - items: - type: string - type: array - sticker: - type: string - text_mode: - enum: - - normal - - styled - type: string + type: object api.SetUsernameRequest: properties: username: @@ -382,14 +341,6 @@ definitions: username_link: type: string type: object - data.MessageMention: - properties: - author: - type: string - length: - type: integer - start: - type: integer host: localhost:8080 info: contact: {} @@ -1336,9 +1287,9 @@ paths: required: true schema: $ref: '#/definitions/api.Reaction' - - description: Phone number + - description: Registered phone number in: path - name: id + name: number required: true type: string produces: @@ -1366,9 +1317,9 @@ paths: required: true schema: $ref: '#/definitions/api.Reaction' - - description: Phone number + - description: Registered phone number in: path - name: id + name: number required: true type: string produces: @@ -1397,9 +1348,9 @@ paths: required: true schema: $ref: '#/definitions/api.Receipt' - - description: Phone number + - description: Registered phone number in: path - name: id + name: number required: true type: string produces: