docs.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
  2. // This file was generated by swaggo/swag
  3. package docs
  4. import (
  5. "bytes"
  6. "encoding/json"
  7. "strings"
  8. "github.com/alecthomas/template"
  9. "github.com/swaggo/swag"
  10. )
  11. var doc = `{
  12. "schemes": {{ marshal .Schemes }},
  13. "swagger": "2.0",
  14. "info": {
  15. "description": "{{.Description}}",
  16. "title": "{{.Title}}",
  17. "termsOfService": "https://github.com/EDDYCJY/go-gin-example",
  18. "contact": {},
  19. "license": {
  20. "name": "MIT",
  21. "url": "https://github.com/EDDYCJY/go-gin-example/blob/master/LICENSE"
  22. },
  23. "version": "{{.Version}}"
  24. },
  25. "host": "{{.Host}}",
  26. "basePath": "{{.BasePath}}",
  27. "paths": {
  28. "/api/v1/getAllVehicles": {
  29. "get": {
  30. "description": "获取所有车辆信息",
  31. "summary": "GetAllVehicles",
  32. "responses": {
  33. "200": {
  34. "description": "{ \"code\": 200, \"data\": {}, \"msg\": \"ok\" }",
  35. "schema": {
  36. "type": "string"
  37. }
  38. }
  39. }
  40. }
  41. },
  42. "/api/v1/index": {
  43. "get": {
  44. "description": "test",
  45. "summary": "Hello World",
  46. "responses": {
  47. "200": {
  48. "description": "{ \"code\": 200, \"data\": {}, \"msg\": \"ok\" }",
  49. "schema": {
  50. "type": "string"
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }`
  58. type swaggerInfo struct {
  59. Version string
  60. Host string
  61. BasePath string
  62. Schemes []string
  63. Title string
  64. Description string
  65. }
  66. // SwaggerInfo holds exported Swagger Info so clients can modify it
  67. var SwaggerInfo = swaggerInfo{
  68. Version: "1.0",
  69. Host: "",
  70. BasePath: "",
  71. Schemes: []string{},
  72. Title: "Golang Gin API",
  73. Description: "An example of gin",
  74. }
  75. type s struct{}
  76. func (s *s) ReadDoc() string {
  77. sInfo := SwaggerInfo
  78. sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
  79. t, err := template.New("swagger_info").Funcs(template.FuncMap{
  80. "marshal": func(v interface{}) string {
  81. a, _ := json.Marshal(v)
  82. return string(a)
  83. },
  84. }).Parse(doc)
  85. if err != nil {
  86. return doc
  87. }
  88. var tpl bytes.Buffer
  89. if err := t.Execute(&tpl, sInfo); err != nil {
  90. return doc
  91. }
  92. return tpl.String()
  93. }
  94. func init() {
  95. swag.Register(swag.Name, &s{})
  96. }