{"repo":"swaggo/gin-swagger","free":true,"listed":false,"github":"https://github.com/swaggo/gin-swagger","clone":"git clone https://github.com/swaggo/gin-swagger.git","description":"gin middleware to automatically generate RESTful API documentation with Swagger 2.0.","language":"Go","stars":4234,"topics":["golang","gin","middleware","swagger","gin-swagger","gin-middleware"],"license":"MIT","category":"dev-tools","readme_excerpt":"gin-swagger gin middleware to automatically generate RESTful API documentation with Swagger 2.0. Usage Start using it 1. Add comments to your API source code, See Declarative Comments Format. 2. Download Swag for Go by using: Starting in Go 1.17, installing executables with go get is deprecated. go install may be used instead: 3. Run the Swag at your Go project root path(for instance /root/go-project-name ), Swag will parse comments and generate required files( docs folder and docs/doc.go ) at /root/go-project-name/docs . 4. Download gin-swagger by using: Import following in your code: Canonical example: Now assume you have implemented a simple api as following: So how to use gin-swagger on api above? Just follow the following guide. 1. Add Comments for apis and main function with gin-swagger rules like following: 2. Use swag init command to generate a docs, docs generated will be stored at docs/ . 3. import the docs like this: I assume your project named github.com/go-project-name/docs . 4. build your application and after that, go to http://localhost:8080/swagger/index.html ,you to see your Swagger UI. 5. The full code and folder relatives here: Demo project tree, swag init is run at relative . Project with Nested Directory Inorder generate swagger docs for projects with nested directories run the following command -o will set the auto generated file to the specified path Multiple APIs This feature was introduced in swag v1.7.9 Configuration You can configure Swagger using ","default_branch":null,"files":null,"tree":[],"storefront":"/r/swaggo","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/swaggo/gin-swagger/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}