diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-24 22:25:40 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-24 22:25:40 -0400 |
| commit | 0fc3eda77004f41c5f0a804028da2d90b0373ea7 (patch) | |
| tree | edf6d74e6a2b7140350eab1e40d0fbf70e10f87c /cmd/web/docs/docs.go | |
| parent | f4fcd237b2d0eb950fc15a8af1fb0894b6ad6359 (diff) | |
| download | steam-export-0fc3eda77004f41c5f0a804028da2d90b0373ea7.tar.gz steam-export-0fc3eda77004f41c5f0a804028da2d90b0373ea7.tar.xz | |
Another development snapshot. Updated license. Added Swagger documentation--embedded! Note about 'swaggo'
Diffstat (limited to 'cmd/web/docs/docs.go')
| -rw-r--r-- | cmd/web/docs/docs.go | 403 |
1 files changed, 403 insertions, 0 deletions
diff --git a/cmd/web/docs/docs.go b/cmd/web/docs/docs.go new file mode 100644 index 0000000..32e79f7 --- /dev/null +++ b/cmd/web/docs/docs.go @@ -0,0 +1,403 @@ +// 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": { + "name": "Mitchell Riedstra", + "url": "https://riedstra.dev/steam-export", + "email": "steam-export@riedstra.dev" + }, + "license": { + "name": "ISC", + "url": "https://opensource.org/licenses/ISC" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/lib/game/{game}": { + "get": { + "description": "Streams a tarball of the game including the ACF file down\nto the client machine", + "consumes": [ + "application/json" + ], + "produces": [ + "application/tar" + ], + "tags": [ + "all", + "game" + ], + "summary": "Handles downloading of a game", + "parameters": [ + { + "type": "string", + "description": "Name of the videogame", + "name": "game", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "" + } + } + }, + "delete": { + "description": "Handle deletion of a game", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all", + "game" + ], + "summary": "Delete a videogame", + "parameters": [ + { + "type": "string", + "description": "Name of the videogame", + "name": "game", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Game was deleted", + "schema": { + "$ref": "#/definitions/main.respStatus" + } + }, + "400": { + "description": "Bad request, most likely no game supplied", + "schema": { + "$ref": "#/definitions/main.respError" + } + }, + "404": { + "description": "Game not found", + "schema": { + "$ref": "#/definitions/main.respError" + } + }, + "409": { + "description": "Another operation is currently running", + "schema": { + "$ref": "#/definitions/main.respError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/main.respError" + } + } + } + } + }, + "/lib/games": { + "get": { + "description": "Returns a list of all currently installed and available games", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all", + "game" + ], + "summary": "Get available games", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/steam.Game" + } + } + } + } + } + }, + "/lib/install": { + "post": { + "description": "Attemps to install a game from the provided URI\nIt tries to be smart about it, http, https, or a location\non disk are supported.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all", + "game" + ], + "summary": "Installs a game", + "parameters": [ + { + "type": "string", + "description": "URI to fetch from", + "name": "url", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.respStatus" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/main.respError" + } + } + } + } + }, + "/lib/path": { + "post": { + "description": "If no other operatoins are currently running this will change\nthe path in which the current library is pointed. Implies a\nrefresh.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all", + "library" + ], + "summary": "Set library path to new location on disk", + "parameters": [ + { + "type": "string", + "description": "Path on disk to search for a steam library", + "name": "path", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.respStatus" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/main.respError" + } + } + } + } + }, + "/lib/refresh": { + "post": { + "description": "if no other actions are running on the library it will trigger a\nrefre", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all", + "library" + ], + "summary": "Refresh the current steam library", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.respStatus" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/main.respError" + } + } + } + } + }, + "/share-link": { + "get": { + "description": "The URL returned is a best effort guess at what your internal\nnetwork IP is, on Windows this involves automatically using\nthe IP from the interface associated with your default route.\nOn other platforms this involves simply returning the first\nsane looking IP address with no regard for anything else.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all", + "information" + ], + "summary": "Return share link", + "responses": { + "200": { + "description": "URL to currently running server", + "schema": { + "type": "string" + } + } + } + } + }, + "/version": { + "get": { + "description": "Returns the version of the server", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "all" + ], + "summary": "Return the version string", + "responses": { + "200": { + "description": "Version string", + "schema": { + "type": "string" + } + } + } + } + } + }, + "definitions": { + "main.respError": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Descriptive Error message" + } + } + }, + "main.respStatus": { + "type": "object", + "properties": { + "status": { + "type": "string", + "example": "OK" + } + } + }, + "steam.Game": { + "type": "object", + "properties": { + "LibraryPath": { + "type": "string", + "example": "C:\\Program Files (x86)\\Steam\\steamapps" + }, + "Name": { + "type": "string", + "example": "Doom" + }, + "Size": { + "type": "integer", + "example": 12345 + } + } + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + }, + "BasicAuth": { + "type": "basic" + } + } +}` + +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: "1.0", + Host: "localhost:8899", + BasePath: "/api/v1", + Schemes: []string{}, + Title: "Steam Exporter API", + Description: "The steam exporter is designed to make it easy to export steam games across the network.", +} + +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(swag.Name, &s{}) +} |
