mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
improved API documentation + error handling
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -183,6 +183,12 @@ var doc = `{
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,12 @@
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user