Knife4g
use knife4j-front to show the api documents for gin
Usage
- Add comments to your API source code
- Download Swag for Go by using:
- Run
swag init -ot json
in your project directory - Run
go get github.com/hononet639/knife4g
- Add router to your gin project
example:
package main import ( "github.com/gin-gonic/gin" "github.com/hononet639/knife4g" ) func main() { port := "80" engine := gin.Default() engine.GET("/doc/*any", knife4g.Handler(knife4g.Config{RelativePath: "/doc", Port: port})) engine.Run(":"+port) }
- Visit http://localhost:port/doc/front/index
Acknowledgement
Thanks to knife4j