diff --git a/Makefile b/Makefile index f78299612..2731f56d8 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,6 @@ clean: deps: $(GOGET) github.com/swaggo/cli $(GOGET) github.com/ghodss/yaml - $(GOGET) github.com/gin-gonic/gin $(GOGET) github.com/KyleBanks/depth $(GOGET) github.com/go-openapi/jsonreference $(GOGET) github.com/go-openapi/spec diff --git a/example/basic/api/api.go b/example/basic/api/api.go index 3709ff5d3..52be29cd5 100644 --- a/example/basic/api/api.go +++ b/example/basic/api/api.go @@ -1,7 +1,9 @@ package api import ( - "github.com/gin-gonic/gin" + "encoding/json" + "net/http" + "github.com/swaggo/swag/example/basic/web" ) @@ -17,9 +19,9 @@ import ( // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-string-by-int/{some_id} [get] -func GetStringByInt(c *gin.Context) { +func GetStringByInt(w http.ResponseWriter, r *http.Request) { var pet web.Pet - if err := c.ShouldBindJSON(&pet); err != nil { + if err := json.NewDecoder(r.Body).Decode(&pet); err != nil { // write your code return } @@ -39,7 +41,7 @@ func GetStringByInt(c *gin.Context) { // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-struct-array-by-string/{some_id} [get] -func GetStructArrayByString(c *gin.Context) { +func GetStructArrayByString(w http.ResponseWriter, r *http.Request) { // write your code } @@ -54,7 +56,7 @@ func GetStructArrayByString(c *gin.Context) { // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /file/upload [post] -func Upload(ctx *gin.Context) { +func Upload(w http.ResponseWriter, r *http.Request) { // write your code } diff --git a/example/basic/main.go b/example/basic/main.go index a93ea32c3..9f22eb586 100644 --- a/example/basic/main.go +++ b/example/basic/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/example/basic/api" ) @@ -20,10 +21,8 @@ import ( // @host petstore.swagger.io // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/get-string-by-int/:some_id", api.GetStringByInt) - r.GET("//testapi/get-struct-array-by-string/:some_id", api.GetStructArrayByString) - r.POST("/testapi/upload", api.Upload) - r.Run() - + http.HandleFunc("/testapi/get-string-by-int/", api.GetStringByInt) + http.HandleFunc("//testapi/get-struct-array-by-string/", api.GetStructArrayByString) + http.HandleFunc("/testapi/upload", api.Upload) + http.ListenAndServe(":8080", nil) } diff --git a/go.mod b/go.mod index 8900d7d9b..22ce23e35 100644 --- a/go.mod +++ b/go.mod @@ -4,26 +4,13 @@ require ( github.com/KyleBanks/depth v1.2.1 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/ghodss/yaml v1.0.0 - github.com/gin-gonic/gin v1.6.3 github.com/go-openapi/spec v0.19.14 - github.com/go-playground/validator/v10 v10.4.1 // indirect github.com/gofrs/uuid v3.3.0+incompatible - github.com/shopspring/decimal v1.2.0 - github.com/golang/protobuf v1.4.3 // indirect - github.com/json-iterator/go v1.1.10 // indirect - github.com/mailru/easyjson v0.7.6 // indirect - github.com/shopspring/decimal v1.2.0 github.com/stretchr/testify v1.6.1 - github.com/swaggo/cli v1.22.2 // indirect - github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 - github.com/swaggo/gin-swagger v1.3.0 - github.com/urfave/cli/v2 v2.2.0 - golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect - golang.org/x/net v0.0.0-20201027133719-8eef5233e2a1 // indirect - golang.org/x/sys v0.0.0-20201028094953-708e7fb298ac // indirect + github.com/urfave/cli/v2 v2.3.0 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect golang.org/x/text v0.3.4 // indirect - golang.org/x/tools v0.0.0-20201118030313-598b068a9102 - google.golang.org/protobuf v1.25.0 // indirect + golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e ) go 1.13 diff --git a/go.sum b/go.sum index 382a18349..8389e0d00 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,12 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= @@ -19,116 +14,27 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/gzip v0.0.1 h1:ezvKOL6jH+jlzdHNE4h9h8q8uMpDQjyl0NN0Jd7jozc= -github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= -github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= -github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= -github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= -github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.4 h1:3Vw+rh13uq2JFNxgnMTGE1rnoieU9FmyE1gvnyylsYg= github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= -github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= -github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.11 h1:ogU5q8dtp3MMPn59a9VRrPKVxvJHEs5P7yNMR5sNnis= -github.com/go-openapi/spec v0.19.11/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28= github.com/go-openapi/spec v0.19.14 h1:r4fbYFo6N4ZelmSX8G6p+cv/hZRXzcuqQIADGT1iNKM= github.com/go-openapi/spec v0.19.14/go.mod h1:gwrgJS15eCUgjLpMjBJmbZezCsw88LmgeEip0M63doA= -github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= -github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.11 h1:RFTu/dlFySpyVvJDfp/7674JY4SDglYWKztbiIGFpmc= github.com/go-openapi/swag v0.19.11/go.mod h1:Uc0gKkdR+ojzsEpjh39QChyu92vPgIr72POcgHMAgSY= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= @@ -138,142 +44,47 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/swaggo/cli v1.22.2 h1:HcOuWl50wxecZWnAA3eIrf2XcOki3XeRK7HljCzP9Vg= github.com/swaggo/cli v1.22.2/go.mod h1:mod7cSpILRjdhkgSKDd1HJFDMN4hopy6uH5pkXELHkM= -github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM= -github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= -github.com/swaggo/gin-swagger v1.3.0 h1:eOmp7r57oUgZPw2dJOjcGNMse9cvXcI4tTqBcnZtPsI= -github.com/swaggo/gin-swagger v1.3.0/go.mod h1:oy1BRA6WvgtCp848lhxce7BnWH4C8Bxa0m5SkWx+cS0= -github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.1.13 h1:nB3O5kBSQGjEQAcfe1aLUYuxmXdFKmYgBZhY32rQb6Q= -github.com/ugorji/go v1.1.13/go.mod h1:jxau1n+/wyTGLQoCkjok9r5zFa/FxT6eI5HiHKQszjc= -github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.1.13 h1:013LbFhocBoIqgHeIHKlV4JWYhqogATYWZhIcH0WHn4= -github.com/ugorji/go/codec v1.1.13/go.mod h1:oNVt3Dq+FO91WNQ/9JnHKQP2QJxTzoN7wCBFCq1OeuU= -github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= -github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190611141213-3f473d35a33a h1:+KkCgOMgnKSgenxTBoiwkMqTiouMIy/3o8RLdmSbGoY= -golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201027133719-8eef5233e2a1 h1:IEhJ99VWSYpHIxjlbu3DQyHegGPnQYAv0IaCX9KHyG0= -golang.org/x/net v0.0.0-20201027133719-8eef5233e2a1/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae h1:xiXzMMEQdQcric9hXtr1QU98MHunKK7OTtsoU6bYWs4= -golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201028094953-708e7fb298ac h1:bplbaOojU0hnrC9nvWJ5Nvp/gPIWKFMiGBFI9Cpp16I= -golang.org/x/sys v0.0.0-20201028094953-708e7fb298ac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0= -golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb h1:KVWk3RW1AZlxWum4tYqegLgwJHb5oouozcGM8HfNQaw= -golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201118030313-598b068a9102 h1:kr6Ik/EJgxdTSLX+rSiDounHdHWMBu9Ks/ghr2hWNpo= -golang.org/x/tools v0.0.0-20201118030313-598b068a9102/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201119132711-4783bc9bebf0 h1:26vapYZ9m+DJd68m3DCFP/swNNErXAU7tOMFG7NyUuM= +golang.org/x/tools v0.0.0-20201119132711-4783bc9bebf0/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e h1:t96dS3DO8DGjawSLJL/HIdz8CycAd2v07XxqB3UPTi0= +golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/parser.go b/parser.go index 2327c4afc..4ca9bbfb3 100644 --- a/parser.go +++ b/parser.go @@ -1393,49 +1393,34 @@ func (parser *Parser) checkOperationIDUniqueness() error { operationsIds[operationID] = currentPath return nil } - - for path, itm := range parser.swagger.Paths.Paths { + getOperationID := func(itm spec.PathItem) (string, string) { if itm.Get != nil { - currentPath := fmt.Sprintf("%s %s", "GET", path) - if err := saveOperationID(itm.Get.ID, currentPath); err != nil { - return err - } + return "GET", itm.Get.ID } if itm.Put != nil { - currentPath := fmt.Sprintf("%s %s", "PUT", path) - if err := saveOperationID(itm.Put.ID, currentPath); err != nil { - return err - } + return "PUT", itm.Put.ID } if itm.Post != nil { - currentPath := fmt.Sprintf("%s %s", "POST", path) - if err := saveOperationID(itm.Post.ID, currentPath); err != nil { - return err - } + return "POST", itm.Post.ID } if itm.Delete != nil { - currentPath := fmt.Sprintf("%s %s", "DELETE", path) - if err := saveOperationID(itm.Delete.ID, currentPath); err != nil { - return err - } + return "DELETE", itm.Delete.ID } if itm.Options != nil { - currentPath := fmt.Sprintf("%s %s", "OPTIONS", path) - if err := saveOperationID(itm.Options.ID, currentPath); err != nil { - return err - } + return "OPTIONS", itm.Options.ID } if itm.Head != nil { - currentPath := fmt.Sprintf("%s %s", "HEAD", path) - if err := saveOperationID(itm.Head.ID, currentPath); err != nil { - return err - } + return "HEAD", itm.Head.ID } if itm.Patch != nil { - currentPath := fmt.Sprintf("%s %s", "PATCH", path) - if err := saveOperationID(itm.Patch.ID, currentPath); err != nil { - return err - } + return "PATCH", itm.Patch.ID + } + return "", "" + } + for path, itm := range parser.swagger.Paths.Paths { + method, id := getOperationID(itm) + if err := saveOperationID(id, fmt.Sprintf("%s %s", method, path)); err != nil { + return err } } return nil diff --git a/parser_test.go b/parser_test.go index 9b03ca531..6ab188d55 100644 --- a/parser_test.go +++ b/parser_test.go @@ -1563,6 +1563,15 @@ func TestParseDuplicated(t *testing.T) { assert.Errorf(t, err, "duplicated @id declarations successfully found") } +func TestParseDuplicatedOtherMethods(t *testing.T) { + searchDir := "testdata/duplicated2" + mainAPIFile := "main.go" + p := New() + p.ParseDependency = true + err := p.ParseAPI(searchDir, mainAPIFile, defaultParseDepth) + assert.Errorf(t, err, "duplicated @id declarations successfully found") +} + func TestParseConflictSchemaName(t *testing.T) { searchDir := "testdata/conflict_name" mainAPIFile := "main.go" diff --git a/testdata/alias_import/api/api.go b/testdata/alias_import/api/api.go index 0e24583f3..a01a3ddd5 100644 --- a/testdata/alias_import/api/api.go +++ b/testdata/alias_import/api/api.go @@ -1,10 +1,11 @@ package api import ( - "github.com/gin-gonic/gin" + "log" + "net/http" + "github.com/swaggo/swag/testdata/alias_import/data" "github.com/swaggo/swag/testdata/alias_type/types" - "log" ) // @Summary Get application @@ -14,7 +15,7 @@ import ( // @Produce json // @Success 200 {object} data.ApplicationResponse "ok" // @Router /testapi/application [get] -func GetApplication(c *gin.Context) { +func GetApplication(w http.ResponseWriter, r *http.Request) { var foo = data.ApplicationResponse{ Application: types.Application{ Name: "name", diff --git a/testdata/alias_import/main.go b/testdata/alias_import/main.go index bc8768d94..bf1b5c93b 100644 --- a/testdata/alias_import/main.go +++ b/testdata/alias_import/main.go @@ -1,7 +1,8 @@ package alias_import import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/alias_import/api" ) @@ -20,7 +21,6 @@ import ( // @host petstore.swagger.io // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/application", api.GetApplication) - r.Run() + http.HandleFunc("/testapi/application", api.GetApplication) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/alias_type/api/api.go b/testdata/alias_type/api/api.go index 1d6199436..3c9638e06 100644 --- a/testdata/alias_type/api/api.go +++ b/testdata/alias_type/api/api.go @@ -1,10 +1,11 @@ package api import ( - "github.com/gin-gonic/gin" - "github.com/swaggo/swag/testdata/alias_type/data" "log" + "net/http" "time" + + "github.com/swaggo/swag/testdata/alias_type/data" ) /*// @Summary Get time as string @@ -14,7 +15,7 @@ import ( // @Produce json // @Success 200 {object} data.StringAlias "ok" // @Router /testapi/time-as-string [get] -func GetTimeAsStringAlias(c *gin.Context) { +func GetTimeAsStringAlias(w http.ResponseWriter, r *http.Request) { var foo data.StringAlias = "test" log.Println(foo) //write your code @@ -27,7 +28,7 @@ func GetTimeAsStringAlias(c *gin.Context) { // @Produce json // @Success 200 {object} data.DateOnly "ok" // @Router /testapi/time-as-time [get] -func GetTimeAsTimeAlias(c *gin.Context) { +func GetTimeAsTimeAlias(w http.ResponseWriter, r *http.Request) { var foo = data.DateOnly(time.Now()) log.Println(foo) //write your code @@ -40,7 +41,7 @@ func GetTimeAsTimeAlias(c *gin.Context) { // @Produce json // @Success 200 {object} data.TimeContainer "ok" // @Router /testapi/time-as-time-container [get] -func GetTimeAsTimeContainer(c *gin.Context) { +func GetTimeAsTimeContainer(w http.ResponseWriter, r *http.Request) { now := time.Now() var foo = data.TimeContainer{ Name: "test", diff --git a/testdata/alias_type/main.go b/testdata/alias_type/main.go index 94affaf99..f136fbb95 100644 --- a/testdata/alias_type/main.go +++ b/testdata/alias_type/main.go @@ -1,7 +1,8 @@ package alias_type import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/alias_type/api" ) @@ -20,7 +21,6 @@ import ( // @host petstore.swagger.io // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/time-as-time-container", api.GetTimeAsTimeContainer) - r.Run() + http.HandleFunc("/testapi/time-as-time-container", api.GetTimeAsTimeContainer) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/composition/api/api.go b/testdata/composition/api/api.go index f5c43c334..bd3c62487 100644 --- a/testdata/composition/api/api.go +++ b/testdata/composition/api/api.go @@ -1,7 +1,8 @@ package api import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/composition/common" ) @@ -52,7 +53,7 @@ type MapValue struct { // @Produce json // @Success 200 {object} api.Foo // @Router /testapi/get-foo [get] -func GetFoo(c *gin.Context) { +func GetFoo(w http.ResponseWriter, r *http.Request) { //write your code var _ = Foo{} } @@ -63,7 +64,7 @@ func GetFoo(c *gin.Context) { // @Produce json // @Success 200 {object} api.Bar // @Router /testapi/get-bar [get] -func GetBar(c *gin.Context) { +func GetBar(w http.ResponseWriter, r *http.Request) { //write your code var _ = Bar{} } @@ -74,7 +75,7 @@ func GetBar(c *gin.Context) { // @Produce json // @Success 200 {object} api.FooBar // @Router /testapi/get-foobar [get] -func GetFooBar(c *gin.Context) { +func GetFooBar(w http.ResponseWriter, r *http.Request) { //write your code var _ = FooBar{} } @@ -85,7 +86,7 @@ func GetFooBar(c *gin.Context) { // @Produce json // @Success 200 {object} api.FooBarPointer // @Router /testapi/get-foobar-pointer [get] -func GetFooBarPointer(c *gin.Context) { +func GetFooBarPointer(w http.ResponseWriter, r *http.Request) { //write your code var _ = FooBarPointer{} } @@ -96,7 +97,7 @@ func GetFooBarPointer(c *gin.Context) { // @Produce json // @Success 200 {object} api.BarMap // @Router /testapi/get-barmap [get] -func GetBarMap(c *gin.Context) { +func GetBarMap(w http.ResponseWriter, r *http.Request) { //write your code var _ = BarMap{} } @@ -107,7 +108,7 @@ func GetBarMap(c *gin.Context) { // @Produce json // @Success 200 {object} api.FooBarMap // @Router /testapi/get-foobarmap [get] -func GetFooBarMap(c *gin.Context) { +func GetFooBarMap(w http.ResponseWriter, r *http.Request) { //write your code var _ = FooBarMap{} } diff --git a/testdata/composition/main.go b/testdata/composition/main.go index 23e08ee00..e0dc20d64 100644 --- a/testdata/composition/main.go +++ b/testdata/composition/main.go @@ -1,7 +1,8 @@ package composition import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/composition/api" ) @@ -14,11 +15,10 @@ import ( // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/get-foo", api.GetFoo) - r.GET("/testapi/get-bar", api.GetBar) - r.GET("/testapi/get-foobar", api.GetFooBar) - r.GET("/testapi/get-foobar-pointer", api.GetFooBarPointer) - r.GET("/testapi/get-barmap", api.GetBarMap) - r.Run() + http.handleFunc("/testapi/get-foo", api.GetFoo) + http.handleFunc("/testapi/get-bar", api.GetBar) + http.handleFunc("/testapi/get-foobar", api.GetFooBar) + http.handleFunc("/testapi/get-foobar-pointer", api.GetFooBarPointer) + http.handleFunc("/testapi/get-barmap", api.GetBarMap) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/duplicated/api/api.go b/testdata/duplicated/api/api.go index a840fd806..829a43048 100644 --- a/testdata/duplicated/api/api.go +++ b/testdata/duplicated/api/api.go @@ -1,17 +1,15 @@ package api -import ( - "github.com/gin-gonic/gin" -) +import "net/http" // @Description get Foo // @ID get-foo // @Success 200 {string} string // @Router /testapi/get-foo [get] -func GetFoo(c *gin.Context) {} +func GetFoo(w http.ResponseWriter, r *http.Request) {} // @Description post Bar // @ID get-foo // @Success 200 {string} string // @Router /testapi/post-bar [post] -func PostBar(c *gin.Context) {} +func PostBar(w http.ResponseWriter, r *http.Request) {} diff --git a/testdata/duplicated/main.go b/testdata/duplicated/main.go index 75bada3ea..d1e16664f 100644 --- a/testdata/duplicated/main.go +++ b/testdata/duplicated/main.go @@ -1,7 +1,7 @@ package composition import ( - "github.com/gin-gonic/gin" + "net/http" "github.com/swaggo/swag/testdata/duplicated/api" ) @@ -15,8 +15,7 @@ import ( // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/get-foo", api.GetFoo) - r.POST("/testapi/post-bar", api.PostBar) - r.Run() + http.HandleFunc("/testapi/get-foo", api.GetFoo) + http.HandleFunc("/testapi/post-bar", api.PostBar) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/duplicated2/api/api.go b/testdata/duplicated2/api/api.go new file mode 100644 index 000000000..ef1fcc29c --- /dev/null +++ b/testdata/duplicated2/api/api.go @@ -0,0 +1,33 @@ +package api + +import "net/http" + +// @Description put Foo +// @ID put-foo +// @Success 200 {string} string +// @Router /testapi/put-foo [put] +func PutFoo(w http.ResponseWriter, r *http.Request) {} + +// @Description head Foo +// @ID head-foo +// @Success 200 {string} string +// @Router /testapi/head-foo [head] +func HeadFoo(w http.ResponseWriter, r *http.Request) {} + +// @Description options Foo +// @ID options-foo +// @Success 200 {string} string +// @Router /testapi/options-foo [options] +func OptionsFoo(w http.ResponseWriter, r *http.Request) {} + +// @Description patch Foo +// @ID patch-foo +// @Success 200 {string} string +// @Router /testapi/patch-foo [patch] +func PatchFoo(w http.ResponseWriter, r *http.Request) {} + +// @Description delete Foo +// @ID put-foo +// @Success 200 {string} string +// @Router /testapi/delete-foo [delete] +func DeleteFoo(w http.ResponseWriter, r *http.Request) {} diff --git a/testdata/duplicated2/main.go b/testdata/duplicated2/main.go new file mode 100644 index 000000000..90988f76d --- /dev/null +++ b/testdata/duplicated2/main.go @@ -0,0 +1,24 @@ +package composition + +import ( + "net/http" + + "github.com/swaggo/swag/testdata/duplicated2/api" +) + +// @title Swagger Example API +// @version 1.0 +// @description This is a sample server +// @termsOfService http://swagger.io/terms/ + +// @host petstore.swagger.io +// @BasePath /v2 + +func main() { + http.HandleFunc("/testapi/put-foo", api.PutFoo) + http.HandleFunc("/testapi/head-foo", api.HeadFoo) + http.HandleFunc("/testapi/options-foo", api.OptionsFoo) + http.HandleFunc("/testapi/patch-foo", api.PatchFoo) + http.HandleFunc("/testapi/delete-foo", api.DeleteFoo) + http.ListenAndServe(":8080", nil) +} diff --git a/testdata/json_field_string/main.go b/testdata/json_field_string/main.go index 599545224..564503a2a 100755 --- a/testdata/json_field_string/main.go +++ b/testdata/json_field_string/main.go @@ -1,9 +1,9 @@ package main import ( + "encoding/json" + "fmt" "net/http" - - "github.com/gin-gonic/gin" ) type MyStruct struct { @@ -23,12 +23,13 @@ type MyStruct struct { // @Success 200 {object} MyStruct // @Failure 500 // @Router /do-something [post] -func DoSomething(c *gin.Context) { +func DoSomething(w http.ResponseWriter, r *http.Request) { objectFromJSON := new(MyStruct) - if err := c.BindJSON(&objectFromJSON); err != nil { - c.AbortWithError(http.StatusInternalServerError, err) + if err := json.NewDecoder(r.Body).Decode(&objectFromJSON); err != nil { + w.WriteHeader(http.StatusInternalServerError) + fmt.Print(err.Error()) } - c.JSON(http.StatusOK, objectFromJSON) + json.NewEncoder(w).Encode(ojbectFromJSON) } // @title Swagger Example API @@ -37,7 +38,6 @@ func DoSomething(c *gin.Context) { // @host localhost:4000 // @basePath / func main() { - r := gin.New() - r.POST("/do-something", DoSomething) - r.Run() + http.HandleFund("/do-something", DoSomething) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/nested/api/api.go b/testdata/nested/api/api.go index e7869da85..0dec600ac 100644 --- a/testdata/nested/api/api.go +++ b/testdata/nested/api/api.go @@ -1,7 +1,8 @@ package api import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/nested2" ) @@ -23,7 +24,7 @@ type Bar struct { // @Produce json // @Success 200 {object} api.Foo // @Router /testapi/get-foo [get] -func GetFoo(c *gin.Context) { +func GetFoo(w http.ResponseWriter, r *http.Request) { //write your code var _ = Foo{} } diff --git a/testdata/nested/main.go b/testdata/nested/main.go index 1649b9bbb..6e63913b3 100644 --- a/testdata/nested/main.go +++ b/testdata/nested/main.go @@ -1,7 +1,8 @@ package composition import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/nested/api" ) @@ -14,7 +15,6 @@ import ( // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/get-foo", api.GetFoo) - r.Run() + http.HandleFunc("/testapi/get-foo", api.GetFoo) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/nested2/inner/data.go b/testdata/nested2/inner/data.go new file mode 100644 index 000000000..8a7eab5c4 --- /dev/null +++ b/testdata/nested2/inner/data.go @@ -0,0 +1 @@ +package inner diff --git a/testdata/non_exported_json_fields/main.go b/testdata/non_exported_json_fields/main.go index 9d59f7a81..b02dcc56c 100644 --- a/testdata/non_exported_json_fields/main.go +++ b/testdata/non_exported_json_fields/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" ) type MyStruct struct { @@ -28,7 +28,7 @@ type MyStruct struct { // @Produce json // @Success 200 {object} MyStruct // @Router /so-something [get] -func DoSomething(c *gin.Context) { +func DoSomething(w http.ResponseWriter, r *http.Request) { //write your code } @@ -38,7 +38,6 @@ func DoSomething(c *gin.Context) { // @host localhost:4000 // @basePath /api func main() { - r := gin.New() - r.GET("/do-something", DoSomething) - r.Run() + http.HandleFunc("/do-something", DoSomething) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/pare_outside_dependencies/cmd/main.go b/testdata/pare_outside_dependencies/cmd/main.go index a93ea32c3..9f22eb586 100644 --- a/testdata/pare_outside_dependencies/cmd/main.go +++ b/testdata/pare_outside_dependencies/cmd/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/example/basic/api" ) @@ -20,10 +21,8 @@ import ( // @host petstore.swagger.io // @BasePath /v2 func main() { - r := gin.New() - r.GET("/testapi/get-string-by-int/:some_id", api.GetStringByInt) - r.GET("//testapi/get-struct-array-by-string/:some_id", api.GetStructArrayByString) - r.POST("/testapi/upload", api.Upload) - r.Run() - + http.HandleFunc("/testapi/get-string-by-int/", api.GetStringByInt) + http.HandleFunc("//testapi/get-struct-array-by-string/", api.GetStructArrayByString) + http.HandleFunc("/testapi/upload", api.Upload) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/simple/api/api.go b/testdata/simple/api/api.go index 2f02b73e4..bde8f703b 100644 --- a/testdata/simple/api/api.go +++ b/testdata/simple/api/api.go @@ -1,7 +1,8 @@ package api import ( - "github.com/gin-gonic/gin" + "net/http" + _ "github.com/swaggo/swag/testdata/simple/web" ) @@ -16,7 +17,7 @@ import ( // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-string-by-int/{some_id} [get] -func GetStringByInt(c *gin.Context) { +func GetStringByInt(w http.ResponseWriter, r *http.Request) { //write your code } @@ -39,7 +40,7 @@ func GetStringByInt(c *gin.Context) { // @Security OAuth2AccessCode[read] // @Security OAuth2Password[admin] // @Router /testapi/get-struct-array-by-string/{some_id} [get] -func GetStructArrayByString(c *gin.Context) { +func GetStructArrayByString(w http.ResponseWriter, r *http.Request) { //write your code } @@ -54,7 +55,7 @@ func GetStructArrayByString(c *gin.Context) { // @Failure 401 {array} string // @Failure 404 {object} web.APIError "Can not find ID" // @Router /file/upload [post] -func Upload(ctx *gin.Context) { +func Upload(w http.ResponseWriter, r *http.Request) { //write your code } diff --git a/testdata/simple/main.go b/testdata/simple/main.go index d68402270..824a017c5 100644 --- a/testdata/simple/main.go +++ b/testdata/simple/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/simple/api" ) @@ -47,9 +48,8 @@ import ( // @authorizationurl https://example.com/oauth/authorize // @scope.admin Grants read and write access to administrative information func main() { - r := gin.New() - r.GET("/testapi/get-string-by-int/:some_id", api.GetStringByInt) - r.GET("/testapi/get-struct-array-by-string/:some_id", api.GetStructArrayByString) - r.POST("/testapi/upload", api.Upload) - r.Run() + http.HandleFunc("/testapi/get-string-by-int/", api.GetStringByInt) + http.HandleFunc("/testapi/get-struct-array-by-string/", api.GetStructArrayByString) + http.HandleFunc("/testapi/upload", api.Upload) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/simple2/api/api.go b/testdata/simple2/api/api.go index ec08a0184..f65c534c1 100644 --- a/testdata/simple2/api/api.go +++ b/testdata/simple2/api/api.go @@ -1,7 +1,7 @@ package api import ( - "github.com/gin-gonic/gin" + "net/http" ) // @Summary Add a new pet to the store @@ -15,7 +15,7 @@ import ( // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-string-by-int/{some_id} [get] -func GetStringByInt(c *gin.Context) { +func GetStringByInt(w http.ResponseWriter, r *http.Request) { //write your code } @@ -38,7 +38,7 @@ func GetStringByInt(c *gin.Context) { // @Security OAuth2AccessCode[read] // @Security OAuth2Password[admin] // @Router /testapi/get-struct-array-by-string/{some_id} [get] -func GetStructArrayByString(c *gin.Context) { +func GetStructArrayByString(w http.ResponseWriter, r *http.Request) { //write your code } @@ -52,7 +52,7 @@ func GetStructArrayByString(c *gin.Context) { // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /file/upload [post] -func Upload(ctx *gin.Context) { +func Upload(w http.ResponseWriter, r *http.Request) { //write your code } diff --git a/testdata/simple2/main.go b/testdata/simple2/main.go index e506504a9..5858e02eb 100644 --- a/testdata/simple2/main.go +++ b/testdata/simple2/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/simple2/api" ) @@ -47,9 +48,8 @@ import ( // @authorizationurl https://example.com/oauth/authorize // @scope.admin Grants read and write access to administrative information func main() { - r := gin.New() - r.GET("/testapi/get-string-by-int/:some_id", api.GetStringByInt) - r.GET("//testapi/get-struct-array-by-string/:some_id", api.GetStructArrayByString) - r.POST("/testapi/upload", api.Upload) - r.Run() + http.HandleFunc("/testapi/get-string-by-int/", api.GetStringByInt) + http.HandleFunc("//testapi/get-struct-array-by-string/", api.GetStructArrayByString) + http.HandleFunc("/testapi/upload", api.Upload) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/simple3/api/api.go b/testdata/simple3/api/api.go index ec08a0184..10db26060 100644 --- a/testdata/simple3/api/api.go +++ b/testdata/simple3/api/api.go @@ -1,8 +1,6 @@ package api -import ( - "github.com/gin-gonic/gin" -) +import "net/http" // @Summary Add a new pet to the store // @Description get string by ID @@ -15,7 +13,7 @@ import ( // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /testapi/get-string-by-int/{some_id} [get] -func GetStringByInt(c *gin.Context) { +func GetStringByInt(w http.ResponseWriter, r *http.Request) { //write your code } @@ -38,7 +36,7 @@ func GetStringByInt(c *gin.Context) { // @Security OAuth2AccessCode[read] // @Security OAuth2Password[admin] // @Router /testapi/get-struct-array-by-string/{some_id} [get] -func GetStructArrayByString(c *gin.Context) { +func GetStructArrayByString(w http.ResponseWriter, r *http.Request) { //write your code } @@ -52,7 +50,7 @@ func GetStructArrayByString(c *gin.Context) { // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /file/upload [post] -func Upload(ctx *gin.Context) { +func Upload(w http.ResponseWriter, r *http.Request) { //write your code } diff --git a/testdata/simple3/main.go b/testdata/simple3/main.go index 38f8ef4a9..307cff1dd 100644 --- a/testdata/simple3/main.go +++ b/testdata/simple3/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/simple3/api" ) @@ -47,9 +48,8 @@ import ( // @authorizationurl https://example.com/oauth/authorize // @scope.admin Grants read and write access to administrative information func main() { - r := gin.New() - r.GET("/testapi/get-string-by-int/:some_id", api.GetStringByInt) - r.GET("//testapi/get-struct-array-by-string/:some_id", api.GetStructArrayByString) - r.POST("/testapi/upload", api.Upload) - r.Run() + http.HandleFunc("/testapi/get-string-by-int/", api.GetStringByInt) + http.HandleFunc("//testapi/get-struct-array-by-string/", api.GetStructArrayByString) + http.HandleFunc("/testapi/upload", api.Upload) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/simple_cgo/api/api.go b/testdata/simple_cgo/api/api.go index 9de5c6ca8..d81ae1990 100644 --- a/testdata/simple_cgo/api/api.go +++ b/testdata/simple_cgo/api/api.go @@ -1,8 +1,6 @@ package api -import ( - "github.com/gin-gonic/gin" -) +import "net/http" // @Summary Add a new pet to the store // @Description get string by ID @@ -15,5 +13,5 @@ import ( // @Failure 400 {object} string "We need ID!!" // @Failure 404 {object} string "Can not find ID" // @Router /testapi/get-string-by-int/{some_id} [get] -func GetStringByInt(c *gin.Context) { +func GetStringByInt(w http.ResponseWriter, r *http.Request) { } diff --git a/testdata/simple_cgo/main.go b/testdata/simple_cgo/main.go index 3368deb68..971ae70ed 100644 --- a/testdata/simple_cgo/main.go +++ b/testdata/simple_cgo/main.go @@ -10,7 +10,8 @@ void Hello(){ import "C" import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/simple_cgo/api" ) @@ -58,7 +59,6 @@ import ( func main() { C.Hello() - r := gin.New() - r.GET("/testapi/get-string-by-int/:some_id", api.GetStringByInt) - r.Run() + http.HandleFunc("/testapi/get-string-by-int/", api.GetStringByInt) + http.ListenAndServe(":8080", nil) } diff --git a/testdata/struct_comment/api/api.go b/testdata/struct_comment/api/api.go index 539f90923..f96433d2d 100644 --- a/testdata/struct_comment/api/api.go +++ b/testdata/struct_comment/api/api.go @@ -1,8 +1,6 @@ package api -import ( - "github.com/gin-gonic/gin" -) +import "net/http" // @Summary Add a new pet to the store // @Description get string by ID @@ -13,6 +11,6 @@ import ( // @Failure 400 {object} web.APIError "We need ID!!" // @Failure 404 {object} web.APIError "Can not find ID" // @Router /posts/{post_id} [get] -func GetPost(c *gin.Context) { +func GetPost(w http.ResponseWriter, r *http.Request) { //write your code } diff --git a/testdata/struct_comment/main.go b/testdata/struct_comment/main.go index 7fa1a2771..6994817b5 100644 --- a/testdata/struct_comment/main.go +++ b/testdata/struct_comment/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/gin-gonic/gin" + "net/http" + "github.com/swaggo/swag/testdata/struct_comment/api" ) @@ -11,7 +12,6 @@ import ( // @host localhost:4000 // @basePath /api func main() { - r := gin.New() - r.GET("/posts/:post_id", api.GetPost) - r.Run() + http.HandleFunc("/posts/", api.GetPost) + http.ListenAndServe(":8080", nil) }