chore: update README.md
This commit is contained in:
parent
ffac37ae4f
commit
fe69d20d50
|
|
@ -1,11 +1,23 @@
|
|||
|
||||
Generate documentation for v2
|
||||
``
|
||||
# Multiple API feature
|
||||
Since swag 1.7.9 we are allowing registration of multiple endpoints into the same server.
|
||||
|
||||
Generate documentation for v1 endpoints
|
||||
```shell
|
||||
swag i -g main.go -dir api/v1 --instanceName v1
|
||||
```
|
||||
|
||||
Generate documentation for v2
|
||||
```
|
||||
swag i -g main.go -dir api/v1 --instanceName v1
|
||||
|
||||
Generate documentation for v2 endpoints
|
||||
```shell
|
||||
swag i -g main.go -dir api/v2 --instanceName v2
|
||||
```
|
||||
|
||||
Run example
|
||||
```shell
|
||||
go run main.go
|
||||
```
|
||||
|
||||
Now you can access the v1 swagger here [http://localhost:8080/swagger/v1/index.html](http://localhost:8080/swagger/v1/index.html) ,
|
||||
and v2 swagger here [http://localhost:8080/swagger/v2/index.html](http://localhost:8080/swagger/v2/index.html)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// @Host example.swagger.io
|
||||
// @BasePath /v1
|
||||
|
||||
func Register(router *gin.Engine) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// @host example.swagger.io
|
||||
// @BasePath /v2
|
||||
|
||||
func Register(router *gin.Engine) {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ const docTemplatev1 = `{
|
|||
// SwaggerInfov1 holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfov1 = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "example.swagger.io",
|
||||
Host: "",
|
||||
BasePath: "/v1",
|
||||
Schemes: []string{},
|
||||
Title: "Swagger Example API",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "example.swagger.io",
|
||||
"basePath": "/v1",
|
||||
"paths": {
|
||||
"/books": {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ definitions:
|
|||
year:
|
||||
type: integer
|
||||
type: object
|
||||
host: example.swagger.io
|
||||
info:
|
||||
contact:
|
||||
email: support@swagger.io
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ const docTemplatev2 = `{
|
|||
// SwaggerInfov2 holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfov2 = &swag.Spec{
|
||||
Version: "2.0",
|
||||
Host: "example.swagger.io",
|
||||
Host: "",
|
||||
BasePath: "/v2",
|
||||
Schemes: []string{},
|
||||
Title: "Swagger Example API",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
},
|
||||
"version": "2.0"
|
||||
},
|
||||
"host": "example.swagger.io",
|
||||
"basePath": "/v2",
|
||||
"paths": {
|
||||
"/books": {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ definitions:
|
|||
year:
|
||||
type: integer
|
||||
type: object
|
||||
host: example.swagger.io
|
||||
info:
|
||||
contact:
|
||||
email: support@swagger.io
|
||||
|
|
|
|||
Loading…
Reference in New Issue