1091 lines
34 KiB
Go
1091 lines
34 KiB
Go
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
|
// This file was generated by swaggo/swag
|
|
package docs
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"strings"
|
|
"text/template"
|
|
|
|
"github.com/swaggo/swag"
|
|
)
|
|
|
|
var doc = `{
|
|
"schemes": {{ marshal .Schemes }},
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"description": "{{escape .Description}}",
|
|
"title": "{{.Title}}",
|
|
"contact": {},
|
|
"version": "{{.Version}}"
|
|
},
|
|
"host": "{{.Host}}",
|
|
"basePath": "{{.BasePath}}",
|
|
"paths": {
|
|
"/api/v1/token": {
|
|
"post": {
|
|
"description": "Returns a new session token for API access",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Create session token",
|
|
"parameters": [
|
|
{
|
|
"description": "Client type",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/server.TokenRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/server.TokenResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Internal Server Error",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"description": "Deletes the current session token",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Invalidate session token",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Bearer token",
|
|
"name": "Authorization",
|
|
"in": "header",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Unauthorized",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Internal Server Error",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/token/cleanup": {
|
|
"post": {
|
|
"description": "Removes all expired session tokens from the database",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Cleanup expired sessions",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Bearer token",
|
|
"name": "Authorization",
|
|
"in": "header",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Unauthorized",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Internal Server Error",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/character": {
|
|
"get": {
|
|
"description": "Returns the image for a specific character",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"image/png"
|
|
],
|
|
"tags": [
|
|
"characters"
|
|
],
|
|
"summary": "Get character image",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Character name",
|
|
"name": "name",
|
|
"in": "query",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/characters": {
|
|
"get": {
|
|
"description": "Returns a list of all available characters",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"characters"
|
|
],
|
|
"summary": "Get list of characters",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/download": {
|
|
"get": {
|
|
"description": "Checks for the latest version of the application",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"download"
|
|
],
|
|
"summary": "Check for latest version",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/download/linux": {
|
|
"get": {
|
|
"description": "Redirects to download the latest Linux version",
|
|
"produces": [
|
|
"application/octet-stream"
|
|
],
|
|
"tags": [
|
|
"download"
|
|
],
|
|
"summary": "Download latest Linux version",
|
|
"responses": {
|
|
"302": {
|
|
"description": "Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/download/list": {
|
|
"get": {
|
|
"description": "Lists all assets available for the latest version",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"download"
|
|
],
|
|
"summary": "List assets of latest version",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/download/windows": {
|
|
"get": {
|
|
"description": "Redirects to download the latest Windows version",
|
|
"produces": [
|
|
"application/octet-stream"
|
|
],
|
|
"tags": [
|
|
"download"
|
|
],
|
|
"summary": "Download latest Windows version",
|
|
"responses": {
|
|
"302": {
|
|
"description": "Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/health": {
|
|
"get": {
|
|
"description": "Returns the health status of the server",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"health"
|
|
],
|
|
"summary": "Check server health",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music": {
|
|
"get": {
|
|
"description": "Returns a specific song by name",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get a specific song",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Song name",
|
|
"name": "song",
|
|
"in": "query",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "song can't be empty",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/addPlayed": {
|
|
"get": {
|
|
"description": "Adds the latest song to the played list",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Add latest to played",
|
|
"responses": {
|
|
"204": {
|
|
"description": ""
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/addQue": {
|
|
"get": {
|
|
"description": "Adds the latest song to the queue",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Add latest to queue",
|
|
"responses": {
|
|
"204": {
|
|
"description": ""
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/all/order": {
|
|
"get": {
|
|
"description": "Returns a list of all games in order",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get all games",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/all/random": {
|
|
"get": {
|
|
"description": "Returns a list of all games in random order",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get all games random",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/info": {
|
|
"get": {
|
|
"description": "Returns information about the current song",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get current song info",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/list": {
|
|
"get": {
|
|
"description": "Returns a list of played songs",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get played songs list",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/next": {
|
|
"get": {
|
|
"description": "Returns the next song in the queue",
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get next song",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/played": {
|
|
"put": {
|
|
"description": "Marks a song as played by its ID",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Mark song as played",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"description": "Song ID",
|
|
"name": "song",
|
|
"in": "query",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"204": {
|
|
"description": ""
|
|
},
|
|
"400": {
|
|
"description": "Bad Request",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/previous": {
|
|
"get": {
|
|
"description": "Returns the previous song in the queue",
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get previous song",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/rand": {
|
|
"get": {
|
|
"description": "Returns a random song",
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get random song",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/rand/classic": {
|
|
"get": {
|
|
"description": "Returns a random song from the classic selection",
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get random classic song",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/rand/low": {
|
|
"get": {
|
|
"description": "Returns a random song with low chance selection",
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get random song with low chance",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/reset": {
|
|
"get": {
|
|
"description": "Resets the music state",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Reset music state",
|
|
"responses": {
|
|
"204": {
|
|
"description": ""
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/music/soundTest": {
|
|
"get": {
|
|
"description": "Returns the sound check song",
|
|
"produces": [
|
|
"audio/mpeg"
|
|
],
|
|
"tags": [
|
|
"music"
|
|
],
|
|
"summary": "Get sound check song",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "file"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/sync": {
|
|
"get": {
|
|
"description": "Starts syncing games with only new changes",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"sync"
|
|
],
|
|
"summary": "Sync games with only changes",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Start syncing games",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/sync/full": {
|
|
"get": {
|
|
"description": "Starts a full sync of all games",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"sync"
|
|
],
|
|
"summary": "Sync all games fully",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Start syncing games full",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/sync/progress": {
|
|
"get": {
|
|
"description": "Returns the current sync progress or result",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"sync"
|
|
],
|
|
"summary": "Get sync progress",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/sync/reset": {
|
|
"get": {
|
|
"description": "Resets the games database by deleting all games and songs",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"sync"
|
|
],
|
|
"summary": "Reset games database",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Games and songs are deleted from the database",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"423": {
|
|
"description": "Syncing is in progress",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/version": {
|
|
"get": {
|
|
"description": "get latest version info",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"version"
|
|
],
|
|
"summary": "Getting the latest version of the backend",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/backend.VersionData"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/version/history": {
|
|
"get": {
|
|
"description": "get version history",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"version"
|
|
],
|
|
"summary": "Getting the version history of the backend",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/backend.VersionData"
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Not Found",
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"backend.VersionData": {
|
|
"type": "object",
|
|
"properties": {
|
|
"changelog": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"example": [
|
|
"[\"Initial release\"",
|
|
"\"Bug fixes\"]"
|
|
]
|
|
},
|
|
"version": {
|
|
"type": "string",
|
|
"example": "1.0.0"
|
|
}
|
|
}
|
|
},
|
|
"server.TokenRequest": {
|
|
"type": "object",
|
|
"properties": {
|
|
"client_type": {
|
|
"description": "Optional: \"web\", \"mobile\", \"api\"",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"server.TokenResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"client_type": {
|
|
"type": "string"
|
|
},
|
|
"expires_at": {
|
|
"type": "string"
|
|
},
|
|
"token": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
|
|
type swaggerInfo struct {
|
|
Version string
|
|
Host string
|
|
BasePath string
|
|
Schemes []string
|
|
Title string
|
|
Description string
|
|
}
|
|
|
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
|
var SwaggerInfo = swaggerInfo{
|
|
Version: "",
|
|
Host: "",
|
|
BasePath: "",
|
|
Schemes: []string{},
|
|
Title: "",
|
|
Description: "",
|
|
}
|
|
|
|
type s struct{}
|
|
|
|
func (s *s) ReadDoc() string {
|
|
sInfo := SwaggerInfo
|
|
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
|
|
|
|
t, err := template.New("swagger_info").Funcs(template.FuncMap{
|
|
"marshal": func(v interface{}) string {
|
|
a, _ := json.Marshal(v)
|
|
return string(a)
|
|
},
|
|
"escape": func(v interface{}) string {
|
|
// escape tabs
|
|
str := strings.Replace(v.(string), "\t", "\\t", -1)
|
|
// replace " with \", and if that results in \\", replace that with \\\"
|
|
str = strings.Replace(str, "\"", "\\\"", -1)
|
|
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
|
|
},
|
|
}).Parse(doc)
|
|
if err != nil {
|
|
return doc
|
|
}
|
|
|
|
var tpl bytes.Buffer
|
|
if err := t.Execute(&tpl, sInfo); err != nil {
|
|
return doc
|
|
}
|
|
|
|
return tpl.String()
|
|
}
|
|
|
|
func init() {
|
|
swag.Register("swagger", &s{})
|
|
}
|