build api docs

This commit is contained in:
nikk gitanes
2024-02-03 11:20:25 +03:00
parent efb17ee48d
commit cf3af55fb2
4 changed files with 27 additions and 21 deletions

View File

@@ -54,6 +54,12 @@ echo "Build web"
export NODE_OPTIONS=--openssl-legacy-provider export NODE_OPTIONS=--openssl-legacy-provider
$GOBIN run gen_web.go $GOBIN run gen_web.go
#### Update api docs
echo "Build docs"
$GOBIN install github.com/swaggo/swag/cmd/swag@latest
cd "${ROOT}/server" || exit 1
swag init -g web/server.go
#### Build server #### Build server
echo "Build server" echo "Build server"
cd "${ROOT}/server" || exit 1 cd "${ROOT}/server" || exit 1

View File

@@ -62,7 +62,7 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"description": "Test file size", "description": "Test file size (in MB)",
"name": "size", "name": "size",
"in": "path", "in": "path",
"required": true "required": true
@@ -98,7 +98,7 @@ const docTemplate = `{
} }
} }
}, },
"/ffp": { "/ffp/{hash}/{id}": {
"get": { "get": {
"description": "Gather informations using ffprobe.", "description": "Gather informations using ffprobe.",
"produces": [ "produces": [
@@ -113,14 +113,14 @@ const docTemplate = `{
"type": "string", "type": "string",
"description": "Torrent hash", "description": "Torrent hash",
"name": "hash", "name": "hash",
"in": "query", "in": "path",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "File index in torrent", "description": "File index in torrent",
"name": "id", "name": "id",
"in": "query", "in": "path",
"required": true "required": true
} }
], ],
@@ -217,7 +217,7 @@ const docTemplate = `{
} }
} }
}, },
"/play": { "/play/{hash}/{id}": {
"get": { "get": {
"description": "Play given torrent referenced by hash.", "description": "Play given torrent referenced by hash.",
"produces": [ "produces": [
@@ -232,14 +232,14 @@ const docTemplate = `{
"type": "string", "type": "string",
"description": "Torrent hash", "description": "Torrent hash",
"name": "hash", "name": "hash",
"in": "query", "in": "path",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "File index in torrent", "description": "File index in torrent",
"name": "id", "name": "id",
"in": "query", "in": "path",
"required": true "required": true
}, },
{ {

View File

@@ -55,7 +55,7 @@
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"description": "Test file size", "description": "Test file size (in MB)",
"name": "size", "name": "size",
"in": "path", "in": "path",
"required": true "required": true
@@ -91,7 +91,7 @@
} }
} }
}, },
"/ffp": { "/ffp/{hash}/{id}": {
"get": { "get": {
"description": "Gather informations using ffprobe.", "description": "Gather informations using ffprobe.",
"produces": [ "produces": [
@@ -106,14 +106,14 @@
"type": "string", "type": "string",
"description": "Torrent hash", "description": "Torrent hash",
"name": "hash", "name": "hash",
"in": "query", "in": "path",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "File index in torrent", "description": "File index in torrent",
"name": "id", "name": "id",
"in": "query", "in": "path",
"required": true "required": true
} }
], ],
@@ -210,7 +210,7 @@
} }
} }
}, },
"/play": { "/play/{hash}/{id}": {
"get": { "get": {
"description": "Play given torrent referenced by hash.", "description": "Play given torrent referenced by hash.",
"produces": [ "produces": [
@@ -225,14 +225,14 @@
"type": "string", "type": "string",
"description": "Torrent hash", "description": "Torrent hash",
"name": "hash", "name": "hash",
"in": "query", "in": "path",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "File index in torrent", "description": "File index in torrent",
"name": "id", "name": "id",
"in": "query", "in": "path",
"required": true "required": true
}, },
{ {

View File

@@ -332,7 +332,7 @@ paths:
get: get:
description: Download the test file of given size (for speed testing purpose). description: Download the test file of given size (for speed testing purpose).
parameters: parameters:
- description: Test file size - description: Test file size (in MB)
in: path in: path
name: size name: size
required: true required: true
@@ -360,17 +360,17 @@ paths:
summary: Tests server status summary: Tests server status
tags: tags:
- API - API
/ffp: /ffp/{hash}/{id}:
get: get:
description: Gather informations using ffprobe. description: Gather informations using ffprobe.
parameters: parameters:
- description: Torrent hash - description: Torrent hash
in: query in: path
name: hash name: hash
required: true required: true
type: string type: string
- description: File index in torrent - description: File index in torrent
in: query in: path
name: id name: id
required: true required: true
type: string type: string
@@ -438,17 +438,17 @@ paths:
summary: Get MSX IMDB informations summary: Get MSX IMDB informations
tags: tags:
- MSX - MSX
/play: /play/{hash}/{id}:
get: get:
description: Play given torrent referenced by hash. description: Play given torrent referenced by hash.
parameters: parameters:
- description: Torrent hash - description: Torrent hash
in: query in: path
name: hash name: hash
required: true required: true
type: string type: string
- description: File index in torrent - description: File index in torrent
in: query in: path
name: id name: id
required: true required: true
type: string type: string