gin-swagger/example/basic/docs/docs.go

193 lines
5.3 KiB
Go
Raw Normal View History

2017-06-25 09:09:47 +00:00
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
2017-06-25 09:09:47 +00:00
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
2017-08-04 03:18:14 +00:00
"github.com/swaggo/swag"
2017-06-25 09:09:47 +00:00
)
var doc = `{
"schemes": {{ marshal .Schemes }},
2017-06-25 09:09:47 +00:00
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
2017-06-25 09:09:47 +00:00
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "{{.Version}}"
2017-06-25 09:09:47 +00:00
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
2017-06-25 09:09:47 +00:00
"paths": {
"/testapi/get-string-by-int/{some_id}": {
"get": {
"description": "get string by ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Add a new pet to the store",
"parameters": [
{
"type": "integer",
2017-06-25 09:09:47 +00:00
"description": "Some ID",
"name": "some_id",
"in": "path",
"required": true
2017-06-25 09:09:47 +00:00
}
],
"responses": {
"200": {
"description": "ok",
"schema": {
"type": "string"
}
},
"400": {
"description": "We need ID!!",
"schema": {
"$ref": "#/definitions/web.APIError"
}
},
"404": {
"description": "Can not find ID",
"schema": {
"$ref": "#/definitions/web.APIError"
}
}
}
}
},
"/testapi/get-struct-array-by-string/{some_id}": {
"get": {
"description": "get struct array by ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"type": "string",
2017-06-25 09:09:47 +00:00
"description": "Some ID",
"name": "some_id",
"in": "path",
"required": true
2017-06-25 09:09:47 +00:00
},
{
"type": "integer",
2017-06-25 09:09:47 +00:00
"description": "Offset",
"name": "offset",
"in": "query",
"required": true
2017-06-25 09:09:47 +00:00
},
{
"type": "integer",
2017-06-25 09:09:47 +00:00
"description": "Offset",
"name": "limit",
"in": "query",
"required": true
2017-06-25 09:09:47 +00:00
}
],
"responses": {
"200": {
"description": "ok",
"schema": {
"type": "string"
}
},
"400": {
"description": "We need ID!!",
"schema": {
"$ref": "#/definitions/web.APIError"
}
},
"404": {
"description": "Can not find ID",
"schema": {
"$ref": "#/definitions/web.APIError"
}
}
}
}
}
},
"definitions": {
"web.APIError": {
"type": "object",
"properties": {
"errorCode": {
"type": "integer"
2017-06-25 09:09:47 +00:00
},
"errorMessage": {
2017-06-25 09:09:47 +00:00
"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: "1.0",
Host: "petstore.swagger.io:8080",
BasePath: "/v2",
Schemes: []string{},
Title: "Swagger Example API",
Description: "This is a sample server Petstore server.",
}
2017-06-25 09:09:47 +00:00
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)
},
}).Parse(doc)
if err != nil {
return doc
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}
return tpl.String()
2017-06-25 09:09:47 +00:00
}
2017-06-25 09:09:47 +00:00
func init() {
2017-08-04 03:18:14 +00:00
swag.Register(swag.Name, &s{})
2017-06-25 09:09:47 +00:00
}