Update README.md
This commit is contained in:
@@ -10,28 +10,21 @@ gin middleware to automatically generate RESTful API documentation with Swagger
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Start using it
|
### Start using it
|
||||||
1. Add comments to your API source code, [see Declarative Comments Format](#declarative-comments-format)
|
1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swag-gonic/swag#declarative-comments-format).
|
||||||
2. Download Swag for Go by using:
|
2. Download [Swag](https://github.com/swag-gonic/swag) for Go by using:
|
||||||
```sh
|
```sh
|
||||||
$ go get -u github.com/swag-gonic/swag
|
$ go get -u github.com/swag-gonic/swag
|
||||||
```
|
```
|
||||||
3. Run the Swag in your Go project root folder which contains `main.go` file, Swag will parse your comments and generate required files(`docs` folder and `docs/doc.go`)
|
|
||||||
|
3. Run the [Swag](https://github.com/swag-gonic/swag) in your Go project root folder which contains `main.go` file, [Swag](https://github.com/swag-gonic/swag) will parse comments and generate required files(`docs` folder and `docs/doc.go`).
|
||||||
```sh
|
```sh
|
||||||
$ swag init
|
$ swag init
|
||||||
```
|
```
|
||||||
3.
|
4.Import following in your code:
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ go get github.com/swag-gonic/gin-swagger
|
|
||||||
```
|
|
||||||
|
|
||||||
Import it in your code:
|
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "github.com/gin-gonic/gin"
|
import "github.com/swag-gonic/gin-swagger" // gin-swagger middleware
|
||||||
import "github.com/swag-gonic/gin-swagger"
|
import "github.com/swag-gonic/gin-swagger/swaggerFiles" // swagger embed files
|
||||||
import "github.com/swag-gonic/gin-swagger/swaggerFiles"
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -45,7 +38,7 @@ import (
|
|||||||
"github.com/swag-gonic/gin-swagger"
|
"github.com/swag-gonic/gin-swagger"
|
||||||
"github.com/swag-gonic/gin-swagger/swaggerFiles"
|
"github.com/swag-gonic/gin-swagger/swaggerFiles"
|
||||||
|
|
||||||
_ "github.com/swag-gonic/gin-swagger/example/docs"
|
_ "github.com/swag-gonic/gin-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.
|
||||||
)
|
)
|
||||||
|
|
||||||
// @title Swagger Example API
|
// @title Swagger Example API
|
||||||
@@ -69,4 +62,6 @@ func main() {
|
|||||||
|
|
||||||
r.Run()
|
r.Run()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
5. Run it, and broswer to http://localhost:8080/swagger, you can see Swagger 2.0 Api documents.
|
||||||
|
|||||||
Reference in New Issue
Block a user