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
|
// @Description test
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {string} string "Image"
|
// @Success 200 {string} string "Image"
|
||||||
|
// @Failure 400 {object} Error
|
||||||
// @Router /v1/qrcodelink [get]
|
// @Router /v1/qrcodelink [get]
|
||||||
func (a *Api) GetQrCodeLink(c *gin.Context) {
|
func (a *Api) GetQrCodeLink(c *gin.Context) {
|
||||||
deviceName := c.Query("device_name")
|
deviceName := c.Query("device_name")
|
||||||
@@ -622,20 +623,25 @@ func (a *Api) GetQrCodeLink(c *gin.Context) {
|
|||||||
|
|
||||||
tsdeviceLink, err := runSignalCli(false, command)
|
tsdeviceLink, err := runSignalCli(false, command)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
q, err := qrcode.New(string(tsdeviceLink), qrcode.Medium)
|
q, err := qrcode.New(string(tsdeviceLink), qrcode.Medium)
|
||||||
if err != nil {
|
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
|
q.DisableBorder = false
|
||||||
var png []byte
|
var png []byte
|
||||||
png, err = q.PNG(256)
|
png, err = q.PNG(256)
|
||||||
if err != nil {
|
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)
|
c.Data(200, "image/png", png)
|
||||||
|
|||||||
@@ -183,6 +183,12 @@ var doc = `{
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.Error"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,12 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.Error"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ paths:
|
|||||||
description: Image
|
description: Image
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/api.Error'
|
||||||
summary: Link device and generate QR code.
|
summary: Link device and generate QR code.
|
||||||
tags:
|
tags:
|
||||||
- Devices
|
- Devices
|
||||||
|
|||||||
Reference in New Issue
Block a user