fix working example/basic/api function (#123)
This commit is contained in:
+62
-31
@@ -1,18 +1,23 @@
|
||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||
// This file was generated by swaggo/swag at
|
||||
// 2017-06-25 01:25:37.872454531 +0800 CST
|
||||
// This file was generated by swaggo/swag
|
||||
|
||||
package docs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/template"
|
||||
"github.com/swaggo/swag"
|
||||
)
|
||||
|
||||
var doc = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "This is a sample server Petstore server.",
|
||||
"title": "Swagger Example API",
|
||||
"description": "{{.Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "API Support",
|
||||
@@ -23,10 +28,10 @@ var doc = `{
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "1.0"
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "petstore.swagger.io",
|
||||
"basePath": "/v2",
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/testapi/get-string-by-int/{some_id}": {
|
||||
"get": {
|
||||
@@ -40,13 +45,11 @@ var doc = `{
|
||||
"summary": "Add a new pet to the store",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Some ID",
|
||||
"name": "some_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "int"
|
||||
}
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -59,14 +62,12 @@ var doc = `{
|
||||
"400": {
|
||||
"description": "We need ID!!",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/web.APIError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Can not find ID",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/web.APIError"
|
||||
}
|
||||
}
|
||||
@@ -84,31 +85,25 @@ var doc = `{
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Some ID",
|
||||
"name": "some_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Offset",
|
||||
"name": "offset",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "int"
|
||||
}
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Offset",
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "int"
|
||||
}
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -121,14 +116,12 @@ var doc = `{
|
||||
"400": {
|
||||
"description": "We need ID!!",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/web.APIError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Can not find ID",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/web.APIError"
|
||||
}
|
||||
}
|
||||
@@ -140,10 +133,10 @@ var doc = `{
|
||||
"web.APIError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ErrorCode": {
|
||||
"type": "int"
|
||||
"errorCode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ErrorMessage": {
|
||||
"errorMessage": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -151,11 +144,49 @@ var doc = `{
|
||||
}
|
||||
}`
|
||||
|
||||
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.",
|
||||
}
|
||||
|
||||
type s struct{}
|
||||
|
||||
func (s *s) ReadDoc() string {
|
||||
return doc
|
||||
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()
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(swag.Name, &s{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user