From 8ffc6c29c01a13fb01183ee91d0fcc5fc586b431 Mon Sep 17 00:00:00 2001 From: Double Date: Sat, 8 Jan 2022 23:32:48 +0800 Subject: [PATCH] fix: undefined httputil and model (#1099) --- example/celler/controller/accounts.go | 2 + example/celler/docs/docs.go | 69 +++++++++++++++++++++------ 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/example/celler/controller/accounts.go b/example/celler/controller/accounts.go index 0e1d43ead..e52ec81ec 100644 --- a/example/celler/controller/accounts.go +++ b/example/celler/controller/accounts.go @@ -6,6 +6,8 @@ import ( "strconv" "github.com/gin-gonic/gin" + "github.com/swaggo/swag/example/celler/httputil" + "github.com/swaggo/swag/example/celler/model" ) // ShowAccount godoc diff --git a/example/celler/docs/docs.go b/example/celler/docs/docs.go index b7d009325..1914d1d35 100644 --- a/example/celler/docs/docs.go +++ b/example/celler/docs/docs.go @@ -1,6 +1,5 @@ -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag - package docs import ( @@ -16,7 +15,7 @@ var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { - "description": "{{.Description}}", + "description": "{{escape .Description}}", "title": "{{.Title}}", "termsOfService": "http://swagger.io/terms/", "contact": { @@ -801,6 +800,43 @@ var doc = `{ } } }, + "/examples/post": { + "post": { + "description": "post request example", + "consumes": [ + "application/json" + ], + "produces": [ + "text/plain" + ], + "summary": "post request example", + "parameters": [ + { + "description": "Account Info", + "name": "message", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/model.Account" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "500": { + "description": "fail", + "schema": { + "type": "string" + } + } + } + } + }, "/examples/securities": { "get": { "security": [ @@ -968,17 +1004,16 @@ var doc = `{ "authorizationUrl": "https://example.com/oauth/authorize", "tokenUrl": "https://example.com/oauth/token", "scopes": { - "admin": " Grants read and write access to administrative information" + "admin": " Grants read and write access to administrative information" } }, "OAuth2Application": { "type": "oauth2", "flow": "application", - "authorizationUrl": "", "tokenUrl": "https://example.com/oauth/token", "scopes": { - "admin": " Grants read and write access to administrative information", - "write": " Grants write access" + "admin": " Grants read and write access to administrative information", + "write": " Grants write access" } }, "OAuth2Implicit": { @@ -986,19 +1021,18 @@ var doc = `{ "flow": "implicit", "authorizationUrl": "https://example.com/oauth/authorize", "scopes": { - "admin": " Grants read and write access to administrative information", - "write": " Grants write access" + "admin": " Grants read and write access to administrative information", + "write": " Grants write access" } }, "OAuth2Password": { "type": "oauth2", "flow": "password", - "authorizationUrl": "", "tokenUrl": "https://example.com/oauth/token", "scopes": { - "admin": " Grants read and write access to administrative information", - "read": " Grants read access", - "write": " Grants write access" + "admin": " Grants read and write access to administrative information", + "read": " Grants read access", + "write": " Grants write access" } } } @@ -1034,6 +1068,13 @@ func (s *s) ReadDoc() 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 @@ -1048,5 +1089,5 @@ func (s *s) ReadDoc() string { } func init() { - swag.Register(swag.Name, &s{}) + swag.Register("swagger", &s{}) }