|
- // 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": {
- "/translation/do-translate": {
- "post": {
- "description": "Translate a text",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "tags": [
- "translation"
- ],
- "summary": "Translate",
- "operationId": "do-translate",
- "parameters": [
- {
- "description": "Set up translation",
- "name": "request",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/v1.doTranslateRequest"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/entity.Translation"
- }
- },
- "400": {
- "description": "Bad Request",
- "schema": {
- "$ref": "#/definitions/v1.response"
- }
- },
- "500": {
- "description": "Internal Server Error",
- "schema": {
- "$ref": "#/definitions/v1.response"
- }
- }
- }
- }
- },
- "/translation/history": {
- "get": {
- "description": "Show all translation history",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "tags": [
- "translation"
- ],
- "summary": "Show history",
- "operationId": "history",
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/v1.historyResponse"
- }
- },
- "500": {
- "description": "Internal Server Error",
- "schema": {
- "$ref": "#/definitions/v1.response"
- }
- }
- }
- }
- }
- },
- "definitions": {
- "entity.Translation": {
- "type": "object",
- "properties": {
- "destination": {
- "type": "string",
- "example": "en"
- },
- "original": {
- "type": "string",
- "example": "текст для перевода"
- },
- "source": {
- "type": "string",
- "example": "auto"
- },
- "translation": {
- "type": "string",
- "example": "text for translation"
- }
- }
- },
- "v1.doTranslateRequest": {
- "type": "object",
- "required": [
- "destination",
- "original",
- "source"
- ],
- "properties": {
- "destination": {
- "type": "string",
- "example": "en"
- },
- "original": {
- "type": "string",
- "example": "текст для перевода"
- },
- "source": {
- "type": "string",
- "example": "auto"
- }
- }
- },
- "v1.historyResponse": {
- "type": "object",
- "properties": {
- "history": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/entity.Translation"
- }
- }
- }
- },
- "v1.response": {
- "type": "object",
- "properties": {
- "error": {
- "type": "string",
- "example": "message"
- }
- }
- }
- }
- }`
-
- 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:8080",
- BasePath: "/v1",
- Schemes: []string{},
- Title: "Go Clean Template API",
- Description: "Using a translation service as an example",
- }
-
- 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{})
- }
|