fix(import): adjust import path
This commit is contained in:
@@ -2,29 +2,29 @@
|
|||||||
|
|
||||||
gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
|
gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
|
||||||
|
|
||||||
[](https://travis-ci.org/swag-gonic/gin-swagger)
|
[](https://travis-ci.org/swaggo/gin-swagger)
|
||||||
[](https://codecov.io/gh/swag-gonic/gin-swagger)
|
[](https://codecov.io/gh/swaggo/gin-swagger)
|
||||||
[](https://goreportcard.com/report/github.com/swag-gonic/gin-swagger)
|
[](https://goreportcard.com/report/github.com/swaggo/gin-swagger)
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Start using it
|
### Start using it
|
||||||
1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swag-gonic/swag#declarative-comments-format).
|
1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swaggo/swag#declarative-comments-format).
|
||||||
2. Download [Swag](https://github.com/swag-gonic/swag) for Go by using:
|
2. Download [Swag](https://github.com/swaggo/swag) for Go by using:
|
||||||
```sh
|
```sh
|
||||||
$ go get -u github.com/swag-gonic/swag
|
$ go get -u github.com/swaggo/swag
|
||||||
```
|
```
|
||||||
|
|
||||||
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`).
|
3. Run the [Swag](https://github.com/swaggo/swag) in your Go project root folder which contains `main.go` file, [Swag](https://github.com/swaggo/swag) will parse comments and generate required files(`docs` folder and `docs/doc.go`).
|
||||||
```sh
|
```sh
|
||||||
$ swag init
|
$ swag init
|
||||||
```
|
```
|
||||||
4.Import following in your code:
|
4.Import following in your code:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "github.com/swag-gonic/gin-swagger" // gin-swagger middleware
|
import "github.com/swaggo/gin-swagger" // gin-swagger middleware
|
||||||
import "github.com/swag-gonic/gin-swagger/swaggerFiles" // swagger embed files
|
import "github.com/swaggo/gin-swagger/swaggerFiles" // swagger embed files
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -35,10 +35,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/swag-gonic/gin-swagger"
|
"github.com/swaggo/gin-swagger"
|
||||||
"github.com/swag-gonic/gin-swagger/swaggerFiles"
|
"github.com/swaggo/gin-swagger/swaggerFiles"
|
||||||
|
|
||||||
_ "github.com/swag-gonic/gin-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.
|
_ "github.com/swaggo/gin-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.
|
||||||
)
|
)
|
||||||
|
|
||||||
// @title Swagger Example API
|
// @title Swagger Example API
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/swag-gonic/swag/example/web"
|
"github.com/swaggo/swag/example/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
// This file was generated by swag-gonic/swag at
|
// This file was generated by swaggo/swag at
|
||||||
// 2017-06-25 01:25:37.872454531 +0800 CST
|
// 2017-06-25 01:25:37.872454531 +0800 CST
|
||||||
|
|
||||||
package docs
|
package docs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/swag-gonic/swag/swagger"
|
"github.com/swaggo/swag/swagger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var doc = `{
|
var doc = `{
|
||||||
|
|||||||
+3
-3
@@ -2,10 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/swag-gonic/gin-swagger"
|
"github.com/swaggo/gin-swagger"
|
||||||
"github.com/swag-gonic/gin-swagger/swaggerFiles"
|
"github.com/swaggo/gin-swagger/swaggerFiles"
|
||||||
|
|
||||||
_ "github.com/swag-gonic/gin-swagger/example/docs"
|
_ "github.com/swaggo/gin-swagger/example/docs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @title Swagger Example API
|
// @title Swagger Example API
|
||||||
|
|||||||
+3
-2
@@ -2,7 +2,7 @@ package ginSwagger
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/swag-gonic/swag/swagger"
|
"github.com/swaggo/swag/swagger"
|
||||||
"golang.org/x/net/webdav"
|
"golang.org/x/net/webdav"
|
||||||
"html/template"
|
"html/template"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -38,7 +38,8 @@ func WrapHandler(h *webdav.Handler) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
index.Execute(c.Writer, s)
|
index.Execute(c.Writer, s)
|
||||||
case "doc.json":
|
case "doc.json":
|
||||||
c.Writer.Write([]byte(swagger.ReadDoc()))
|
doc, _ := swagger.ReadDoc()
|
||||||
|
c.Writer.Write([]byte(doc))
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
h.ServeHTTP(c.Writer, c.Request)
|
h.ServeHTTP(c.Writer, c.Request)
|
||||||
|
|||||||
+2
-2
@@ -3,11 +3,11 @@ package ginSwagger
|
|||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/swag-gonic/gin-swagger/swaggerFiles"
|
"github.com/swaggo/gin-swagger/swaggerFiles"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/swag-gonic/gin-swagger/example/docs"
|
_ "github.com/swaggo/gin-swagger/example/docs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWrapHandler(t *testing.T) {
|
func TestWrapHandler(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user