From 8346f9072af57d2dae8943767d1ecc609604b571 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 16 Mar 2025 00:22:39 +0100 Subject: [PATCH] fixed error in swagger documentation * set pin request needs to be a POST request * added payload to swagger documentation --- src/api/api.go | 3 ++- src/docs/docs.go | 19 ++++++++++++++++++- src/docs/swagger.json | 19 ++++++++++++++++++- src/docs/swagger.yaml | 13 ++++++++++++- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/api/api.go b/src/api/api.go index 5e78449..779c3fc 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -2178,7 +2178,8 @@ func (a *Api) ListContacts(c *gin.Context) { // @Success 201 // @Failure 400 {object} Error // @Param number path string true "Registered Phone Number" -// @Router /v1/accounts/{number}/pin [get] +// @Param data body SetPinRequest true "Request" +// @Router /v1/accounts/{number}/pin [post] func (a *Api) SetPin(c *gin.Context) { number, err := url.PathUnescape(c.Param("number")) if err != nil { diff --git a/src/docs/docs.go b/src/docs/docs.go index 6ad2272..3297423 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -65,7 +65,7 @@ const docTemplate = `{ } }, "/v1/accounts/{number}/pin": { - "get": { + "post": { "description": "Sets a new Signal Pin", "produces": [ "application/json" @@ -81,6 +81,15 @@ const docTemplate = `{ "name": "number", "in": "path", "required": true + }, + { + "description": "Request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.SetPinRequest" + } } ], "responses": { @@ -2426,6 +2435,14 @@ const docTemplate = `{ } } }, + "api.SetPinRequest": { + "type": "object", + "properties": { + "pin": { + "type": "string" + } + } + }, "api.SetUsernameRequest": { "type": "object", "properties": { diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 7288e73..f88883c 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -62,7 +62,7 @@ } }, "/v1/accounts/{number}/pin": { - "get": { + "post": { "description": "Sets a new Signal Pin", "produces": [ "application/json" @@ -78,6 +78,15 @@ "name": "number", "in": "path", "required": true + }, + { + "description": "Request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.SetPinRequest" + } } ], "responses": { @@ -2423,6 +2432,14 @@ } } }, + "api.SetPinRequest": { + "type": "object", + "properties": { + "pin": { + "type": "string" + } + } + }, "api.SetUsernameRequest": { "type": "object", "properties": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 288200b..b6ecf1d 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -206,6 +206,11 @@ definitions: - styled type: string type: object + api.SetPinRequest: + properties: + pin: + type: string + type: object api.SetUsernameRequest: properties: username: @@ -456,7 +461,7 @@ paths: summary: Remove Pin tags: - Accounts - get: + post: description: Sets a new Signal Pin parameters: - description: Registered Phone Number @@ -464,6 +469,12 @@ paths: name: number required: true type: string + - description: Request + in: body + name: data + required: true + schema: + $ref: '#/definitions/api.SetPinRequest' produces: - application/json responses: