diff --git a/src/api/api.go b/src/api/api.go index f0b2569..038b1af 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -609,6 +609,7 @@ func (a *Api) DeleteGroup(c *gin.Context) { // @Description test // @Produce json // @Success 200 {string} string "Image" +// @Failure 400 {object} Error // @Router /v1/qrcodelink [get] func (a *Api) GetQrCodeLink(c *gin.Context) { deviceName := c.Query("device_name") @@ -622,20 +623,25 @@ func (a *Api) GetQrCodeLink(c *gin.Context) { tsdeviceLink, err := runSignalCli(false, command) if err != nil { - c.JSON(400, gin.H{"error": err.Error()}) + log.Error("Couldn't create QR code: ", err.Error()) + c.JSON(400, Error{Msg: "Couldn't create QR code: " + err.Error()}) return } q, err := qrcode.New(string(tsdeviceLink), qrcode.Medium) if err != nil { - c.JSON(400, gin.H{"error": err.Error()}) + log.Error("Couldn't create QR code: ", err.Error()) + c.JSON(400, Error{Msg: "Couldn't create QR code: " + err.Error()}) + return } q.DisableBorder = false var png []byte png, err = q.PNG(256) if err != nil { - c.JSON(400, gin.H{"error": err.Error()}) + log.Error("Couldn't create QR code: ", err.Error()) + c.JSON(400, Error{Msg: "Couldn't create QR code: " + err.Error()}) + return } c.Data(200, "image/png", png) diff --git a/src/docs/docs.go b/src/docs/docs.go index cb80f03..d4d99fe 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -183,6 +183,12 @@ var doc = `{ "schema": { "type": "string" } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.Error" + } } } } diff --git a/src/docs/swagger.json b/src/docs/swagger.json index f8254d3..b019467 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -168,6 +168,12 @@ "schema": { "type": "string" } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.Error" + } } } } diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index d8c6827..25b9474 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -183,6 +183,10 @@ paths: description: Image schema: type: string + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.Error' summary: Link device and generate QR code. tags: - Devices