Update swagger files from code, with swag tool

This commit is contained in:
crummy
2024-10-28 13:07:05 +13:00
parent a8494b70bd
commit 26a5a6039b
6 changed files with 96 additions and 252 deletions

View File

@@ -1416,6 +1416,7 @@ func (a *Api) UpdateGroup(c *gin.Context) {
// @Success 204 {string} OK // @Success 204 {string} OK
// @Failure 400 {object} Error // @Failure 400 {object} Error
// @Param data body Reaction true "Reaction" // @Param data body Reaction true "Reaction"
// @Param id path int true "Reaction Identifier"
// @Router /v1/reactions/{number} [post] // @Router /v1/reactions/{number} [post]
func (a *Api) SendReaction(c *gin.Context) { func (a *Api) SendReaction(c *gin.Context) {
var req Reaction var req Reaction
@@ -1464,6 +1465,7 @@ func (a *Api) SendReaction(c *gin.Context) {
// @Success 204 {string} OK // @Success 204 {string} OK
// @Failure 400 {object} Error // @Failure 400 {object} Error
// @Param data body Reaction true "Reaction" // @Param data body Reaction true "Reaction"
// @Param id path int true "Reaction Identifier"
// @Router /v1/reactions/{number} [delete] // @Router /v1/reactions/{number} [delete]
func (a *Api) RemoveReaction(c *gin.Context) { func (a *Api) RemoveReaction(c *gin.Context) {
var req Reaction var req Reaction
@@ -1507,6 +1509,7 @@ func (a *Api) RemoveReaction(c *gin.Context) {
// @Success 204 {string} OK // @Success 204 {string} OK
// @Failure 400 {object} Error // @Failure 400 {object} Error
// @Param data body Receipt true "Receipt" // @Param data body Receipt true "Receipt"
// @Param id path int true "Receipt Identifier"
// @Router /v1/receipts/{number} [post] // @Router /v1/receipts/{number} [post]
func (a *Api) SendReceipt(c *gin.Context) { func (a *Api) SendReceipt(c *gin.Context) {
var req Receipt var req Receipt

13
src/docs/README.md Normal file
View File

@@ -0,0 +1,13 @@
These files are generated from the [swaggo/swag](https://github.com/swaggo/swag) tool.
To regenerate them, run:
```bash
docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest init
```
Or, if you have `swag` installed:
```bash
swag init
```

View File

@@ -1415,6 +1415,13 @@ const docTemplate = `{
"schema": { "schema": {
"$ref": "#/definitions/api.Reaction" "$ref": "#/definitions/api.Reaction"
} }
},
{
"type": "integer",
"description": "Reaction Identifier",
"name": "id",
"in": "path",
"required": true
} }
], ],
"responses": { "responses": {
@@ -1453,6 +1460,13 @@ const docTemplate = `{
"schema": { "schema": {
"$ref": "#/definitions/api.Reaction" "$ref": "#/definitions/api.Reaction"
} }
},
{
"type": "integer",
"description": "Reaction Identifier",
"name": "id",
"in": "path",
"required": true
} }
], ],
"responses": { "responses": {
@@ -1493,6 +1507,13 @@ const docTemplate = `{
"schema": { "schema": {
"$ref": "#/definitions/api.Receipt" "$ref": "#/definitions/api.Receipt"
} }
},
{
"type": "integer",
"description": "Receipt Identifier",
"name": "id",
"in": "path",
"required": true
} }
], ],
"responses": { "responses": {
@@ -2278,69 +2299,7 @@ const docTemplate = `{
} }
}, },
"api.SendMessageV2": { "api.SendMessageV2": {
"type": "object", "type": "object"
"properties": {
"base64_attachments": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
]
},
"edit_timestamp": {
"type": "integer"
},
"mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"message": {
"type": "string"
},
"notify_self": {
"type": "boolean"
},
"number": {
"type": "string"
},
"quote_author": {
"type": "string"
},
"quote_mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"quote_message": {
"type": "string"
},
"quote_timestamp": {
"type": "integer"
},
"recipients": {
"type": "array",
"items": {
"type": "string"
}
},
"sticker": {
"type": "string"
},
"text_mode": {
"type": "string",
"enum": [
"normal",
"styled"
]
}
}
}, },
"api.SetUsernameRequest": { "api.SetUsernameRequest": {
"type": "object", "type": "object",
@@ -2442,6 +2401,9 @@ const docTemplate = `{
"api.UpdateProfileRequest": { "api.UpdateProfileRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"about": {
"type": "string"
},
"base64_avatar": { "base64_avatar": {
"type": "string" "type": "string"
}, },
@@ -2610,20 +2572,6 @@ const docTemplate = `{
"type": "string" "type": "string"
} }
} }
},
"data.MessageMention": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"length": {
"type": "integer"
},
"start": {
"type": "integer"
}
}
} }
}, },
"tags": [ "tags": [
@@ -2681,9 +2629,9 @@ const docTemplate = `{
// SwaggerInfo holds exported Swagger Info so clients can modify it // SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{ var SwaggerInfo = &swag.Spec{
Version: "1.0", Version: "1.0",
Host: "", Host: "localhost:8080",
BasePath: "/", BasePath: "/",
Schemes: []string{}, Schemes: []string{"http"},
Title: "Signal Cli REST API", Title: "Signal Cli REST API",
Description: "This is the Signal Cli REST API documentation.", Description: "This is the Signal Cli REST API documentation.",
InfoInstanceName: "swagger", InfoInstanceName: "swagger",

View File

@@ -1,4 +1,7 @@
{ {
"schemes": [
"http"
],
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "This is the Signal Cli REST API documentation.", "description": "This is the Signal Cli REST API documentation.",
@@ -8,7 +11,6 @@
}, },
"host": "localhost:8080", "host": "localhost:8080",
"basePath": "/", "basePath": "/",
"schemes": ["http"],
"paths": { "paths": {
"/v1/about": { "/v1/about": {
"get": { "get": {
@@ -1402,13 +1404,6 @@
], ],
"summary": "Send a reaction.", "summary": "Send a reaction.",
"parameters": [ "parameters": [
{
"description": "Reaction ID",
"name": "number",
"in": "path",
"required": true,
"type": "number"
},
{ {
"description": "Reaction", "description": "Reaction",
"name": "data", "name": "data",
@@ -1417,6 +1412,13 @@
"schema": { "schema": {
"$ref": "#/definitions/api.Reaction" "$ref": "#/definitions/api.Reaction"
} }
},
{
"type": "integer",
"description": "Reaction Identifier",
"name": "id",
"in": "path",
"required": true
} }
], ],
"responses": { "responses": {
@@ -1447,13 +1449,6 @@
], ],
"summary": "Remove a reaction.", "summary": "Remove a reaction.",
"parameters": [ "parameters": [
{
"description": "Reaction ID",
"name": "number",
"in": "path",
"required": true,
"type": "number"
},
{ {
"description": "Reaction", "description": "Reaction",
"name": "data", "name": "data",
@@ -1462,6 +1457,13 @@
"schema": { "schema": {
"$ref": "#/definitions/api.Reaction" "$ref": "#/definitions/api.Reaction"
} }
},
{
"type": "integer",
"description": "Reaction Identifier",
"name": "id",
"in": "path",
"required": true
} }
], ],
"responses": { "responses": {
@@ -1494,13 +1496,6 @@
], ],
"summary": "Send a receipt.", "summary": "Send a receipt.",
"parameters": [ "parameters": [
{
"description": "Receipt ID",
"name": "number",
"in": "path",
"required": true,
"type": "number"
},
{ {
"description": "Receipt", "description": "Receipt",
"name": "data", "name": "data",
@@ -1509,6 +1504,13 @@
"schema": { "schema": {
"$ref": "#/definitions/api.Receipt" "$ref": "#/definitions/api.Receipt"
} }
},
{
"type": "integer",
"description": "Receipt Identifier",
"name": "id",
"in": "path",
"required": true
} }
], ],
"responses": { "responses": {
@@ -1694,7 +1696,7 @@
} }
} }
}, },
"/v1/search/{number}": { "/v1/search": {
"get": { "get": {
"description": "Check if one or more phone numbers are registered with the Signal Service.", "description": "Check if one or more phone numbers are registered with the Signal Service.",
"consumes": [ "consumes": [
@@ -1712,8 +1714,7 @@
"type": "string", "type": "string",
"description": "Registered Phone Number", "description": "Registered Phone Number",
"name": "number", "name": "number",
"in": "path", "in": "path"
"required": true
}, },
{ {
"type": "array", "type": "array",
@@ -2295,69 +2296,7 @@
} }
}, },
"api.SendMessageV2": { "api.SendMessageV2": {
"type": "object", "type": "object"
"properties": {
"base64_attachments": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
]
},
"edit_timestamp": {
"type": "integer"
},
"mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"message": {
"type": "string"
},
"notify_self": {
"type": "boolean"
},
"number": {
"type": "string"
},
"quote_author": {
"type": "string"
},
"quote_mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"quote_message": {
"type": "string"
},
"quote_timestamp": {
"type": "integer"
},
"recipients": {
"type": "array",
"items": {
"type": "string"
}
},
"sticker": {
"type": "string"
},
"text_mode": {
"type": "string",
"enum": [
"normal",
"styled"
]
}
}
}, },
"api.SetUsernameRequest": { "api.SetUsernameRequest": {
"type": "object", "type": "object",
@@ -2459,6 +2398,9 @@
"api.UpdateProfileRequest": { "api.UpdateProfileRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"about": {
"type": "string"
},
"base64_avatar": { "base64_avatar": {
"type": "string" "type": "string"
}, },
@@ -2627,20 +2569,6 @@
"type": "string" "type": "string"
} }
} }
},
"data.MessageMention": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"length": {
"type": "integer"
},
"start": {
"type": "integer"
}
}
} }
}, },
"tags": [ "tags": [

View File

@@ -1,7 +1,4 @@
host: localhost:8080
basePath: / basePath: /
schemes:
- http
definitions: definitions:
api.AddDeviceRequest: api.AddDeviceRequest:
properties: properties:
@@ -166,48 +163,6 @@ definitions:
type: array type: array
type: object type: object
api.SendMessageV2: api.SendMessageV2:
properties:
base64_attachments:
example:
- <BASE64 ENCODED DATA>
- data:<MIME-TYPE>;base64<comma><BASE64 ENCODED DATA>
- data:<MIME-TYPE>;filename=<FILENAME>;base64<comma><BASE64 ENCODED DATA>
items:
type: string
type: array
edit_timestamp:
type: integer
mentions:
items:
$ref: '#/definitions/data.MessageMention'
type: array
message:
type: string
notify_self:
type: boolean
number:
type: string
quote_author:
type: string
quote_mentions:
items:
$ref: '#/definitions/data.MessageMention'
type: array
quote_message:
type: string
quote_timestamp:
type: integer
recipients:
items:
type: string
type: array
sticker:
type: string
text_mode:
enum:
- normal
- styled
type: string
type: object type: object
api.SetUsernameRequest: api.SetUsernameRequest:
properties: properties:
@@ -274,6 +229,8 @@ definitions:
type: object type: object
api.UpdateProfileRequest: api.UpdateProfileRequest:
properties: properties:
about:
type: string
base64_avatar: base64_avatar:
type: string type: string
name: name:
@@ -384,15 +341,7 @@ definitions:
username_link: username_link:
type: string type: string
type: object type: object
data.MessageMention: host: localhost:8080
properties:
author:
type: string
length:
type: integer
start:
type: integer
type: object
info: info:
contact: {} contact: {}
description: This is the Signal Cli REST API documentation. description: This is the Signal Cli REST API documentation.
@@ -1332,17 +1281,17 @@ paths:
- application/json - application/json
description: Remove a reaction description: Remove a reaction
parameters: parameters:
- description: Reaction ID
name: number
in: path
required: true
type: number
- description: Reaction - description: Reaction
in: body in: body
name: data name: data
required: true required: true
schema: schema:
$ref: '#/definitions/api.Reaction' $ref: '#/definitions/api.Reaction'
- description: Reaction Identifier
in: path
name: id
required: true
type: integer
produces: produces:
- application/json - application/json
responses: responses:
@@ -1362,17 +1311,17 @@ paths:
- application/json - application/json
description: React to a message description: React to a message
parameters: parameters:
- description: Reaction ID
name: number
in: path
required: true
type: number
- description: Reaction - description: Reaction
in: body in: body
name: data name: data
required: true required: true
schema: schema:
$ref: '#/definitions/api.Reaction' $ref: '#/definitions/api.Reaction'
- description: Reaction Identifier
in: path
name: id
required: true
type: integer
produces: produces:
- application/json - application/json
responses: responses:
@@ -1393,17 +1342,17 @@ paths:
- application/json - application/json
description: Send a read or viewed receipt description: Send a read or viewed receipt
parameters: parameters:
- description: Receipt ID
name: number
in: path
required: true
type: number
- description: Receipt - description: Receipt
in: body in: body
name: data name: data
required: true required: true
schema: schema:
$ref: '#/definitions/api.Receipt' $ref: '#/definitions/api.Receipt'
- description: Receipt Identifier
in: path
name: id
required: true
type: integer
produces: produces:
- application/json - application/json
responses: responses:
@@ -1532,7 +1481,7 @@ paths:
summary: Verify a registered phone number. summary: Verify a registered phone number.
tags: tags:
- Devices - Devices
/v1/search/{number}: /v1/search:
get: get:
consumes: consumes:
- application/json - application/json
@@ -1543,7 +1492,6 @@ paths:
in: path in: path
name: number name: number
type: string type: string
required: true
- collectionFormat: multi - collectionFormat: multi
description: Numbers to check description: Numbers to check
in: query in: query
@@ -1775,6 +1723,8 @@ paths:
summary: Send a signal message. summary: Send a signal message.
tags: tags:
- Messages - Messages
schemes:
- http
swagger: "2.0" swagger: "2.0"
tags: tags:
- description: Some general endpoints. - description: Some general endpoints.

View File

@@ -58,6 +58,8 @@ import (
// @tag.name Sticker Packs // @tag.name Sticker Packs
// @tag.description List and Install Sticker Packs // @tag.description List and Install Sticker Packs
// @host localhost:8080
// @schemes http
// @BasePath / // @BasePath /
func main() { func main() {
signalCliConfig := flag.String("signal-cli-config", "/home/.local/share/signal-cli/", "Config directory where signal-cli config is stored") signalCliConfig := flag.String("signal-cli-config", "/home/.local/share/signal-cli/", "Config directory where signal-cli config is stored")