From b45aab70a7efbf9b259c65e14ce077039a2d2525 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sat, 7 Oct 2023 11:29:41 +0200 Subject: [PATCH] improved REST API documentation --- src/api/api.go | 4 ++-- src/docs/docs.go | 41 +++++++++++++++++++++++++++++++++++++++-- src/docs/swagger.json | 41 +++++++++++++++++++++++++++++++++++++++-- src/docs/swagger.yaml | 27 ++++++++++++++++++++++++++- 4 files changed, 106 insertions(+), 7 deletions(-) diff --git a/src/api/api.go b/src/api/api.go index ceb8666..2d8194f 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -109,7 +109,7 @@ type SendMessageV2 struct { QuoteAuthor *string `json:"quote_author"` QuoteMessage *string `json:"quote_message"` QuoteMentions []client.MessageMention `json:"quote_mentions"` - TextMode *string `json:"text_mode"` + TextMode *string `json:"text_mode" enums:"normal,styled"` } type TypingIndicatorRequest struct { @@ -341,7 +341,7 @@ func (a *Api) Send(c *gin.Context) { // @Summary Send a signal message. // @Tags Messages -// @Description Send a signal message +// @Description Send a signal message. Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~. // @Accept json // @Produce json // @Success 201 {object} SendMessageResponse diff --git a/src/docs/docs.go b/src/docs/docs.go index 890e42c..0bc3b04 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -333,6 +333,39 @@ var doc = `{ } } }, + "/v1/contacts{number}/sync": { + "post": { + "description": "Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Contacts" + ], + "summary": "Send a synchronization message with the local contacts list to all linked devices.", + "parameters": [ + { + "type": "string", + "description": "Registered Phone Number", + "name": "number", + "in": "path", + "required": true + } + ], + "responses": { + "204": {}, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.Error" + } + } + } + } + }, "/v1/devices/{number}": { "post": { "description": "Links another device to this device. Only works, if this is the master device.", @@ -1566,7 +1599,7 @@ var doc = `{ }, "/v2/send": { "post": { - "description": "Send a signal message", + "description": "Send a signal message. Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.", "consumes": [ "application/json" ], @@ -1839,7 +1872,11 @@ var doc = `{ "type": "string" }, "text_mode": { - "type": "string" + "type": "string", + "enum": [ + "normal", + "styled" + ] } } }, diff --git a/src/docs/swagger.json b/src/docs/swagger.json index c6d3e34..ef70d4c 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -317,6 +317,39 @@ } } }, + "/v1/contacts{number}/sync": { + "post": { + "description": "Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Contacts" + ], + "summary": "Send a synchronization message with the local contacts list to all linked devices.", + "parameters": [ + { + "type": "string", + "description": "Registered Phone Number", + "name": "number", + "in": "path", + "required": true + } + ], + "responses": { + "204": {}, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.Error" + } + } + } + } + }, "/v1/devices/{number}": { "post": { "description": "Links another device to this device. Only works, if this is the master device.", @@ -1550,7 +1583,7 @@ }, "/v2/send": { "post": { - "description": "Send a signal message", + "description": "Send a signal message. Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.", "consumes": [ "application/json" ], @@ -1823,7 +1856,11 @@ "type": "string" }, "text_mode": { - "type": "string" + "type": "string", + "enum": [ + "normal", + "styled" + ] } } }, diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index a17bb8f..d91dd86 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -154,6 +154,9 @@ definitions: sticker: type: string text_mode: + enum: + - normal + - styled type: string type: object api.TrustIdentityRequest: @@ -497,6 +500,28 @@ paths: summary: Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added. tags: - Contacts + /v1/contacts{number}/sync: + post: + consumes: + - application/json + description: Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device. + parameters: + - description: Registered Phone Number + in: path + name: number + required: true + type: string + produces: + - application/json + responses: + "204": {} + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.Error' + summary: Send a synchronization message with the local contacts list to all linked devices. + tags: + - Contacts /v1/devices/{number}: post: consumes: @@ -1317,7 +1342,7 @@ paths: post: consumes: - application/json - description: Send a signal message + description: 'Send a signal message. Set the text_mode to ''styled'' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.' parameters: - description: Input Data in: body