chore: update README.md

This commit is contained in:
Bogdan Ungureanu 2022-04-22 16:48:51 +03:00
parent ffac37ae4f
commit fe69d20d50
No known key found for this signature in database
GPG Key ID: B78F6C4F4B0C3908
9 changed files with 19 additions and 13 deletions

View File

@ -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 swag i -g main.go -dir api/v1 --instanceName v1
``` ```
Generate documentation for v2
``` Generate documentation for v2 endpoints
swag i -g main.go -dir api/v1 --instanceName v1 ```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)

View File

@ -16,7 +16,6 @@ import (
// @license.name Apache 2.0 // @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @Host example.swagger.io
// @BasePath /v1 // @BasePath /v1
func Register(router *gin.Engine) { func Register(router *gin.Engine) {

View File

@ -16,7 +16,6 @@ import (
// @license.name Apache 2.0 // @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host example.swagger.io
// @BasePath /v2 // @BasePath /v2
func Register(router *gin.Engine) { func Register(router *gin.Engine) {

View File

@ -73,7 +73,7 @@ const docTemplatev1 = `{
// SwaggerInfov1 holds exported Swagger Info so clients can modify it // SwaggerInfov1 holds exported Swagger Info so clients can modify it
var SwaggerInfov1 = &swag.Spec{ var SwaggerInfov1 = &swag.Spec{
Version: "1.0", Version: "1.0",
Host: "example.swagger.io", Host: "",
BasePath: "/v1", BasePath: "/v1",
Schemes: []string{}, Schemes: []string{},
Title: "Swagger Example API", Title: "Swagger Example API",

View File

@ -15,7 +15,6 @@
}, },
"version": "1.0" "version": "1.0"
}, },
"host": "example.swagger.io",
"basePath": "/v1", "basePath": "/v1",
"paths": { "paths": {
"/books": { "/books": {

View File

@ -11,7 +11,6 @@ definitions:
year: year:
type: integer type: integer
type: object type: object
host: example.swagger.io
info: info:
contact: contact:
email: support@swagger.io email: support@swagger.io

View File

@ -73,7 +73,7 @@ const docTemplatev2 = `{
// SwaggerInfov2 holds exported Swagger Info so clients can modify it // SwaggerInfov2 holds exported Swagger Info so clients can modify it
var SwaggerInfov2 = &swag.Spec{ var SwaggerInfov2 = &swag.Spec{
Version: "2.0", Version: "2.0",
Host: "example.swagger.io", Host: "",
BasePath: "/v2", BasePath: "/v2",
Schemes: []string{}, Schemes: []string{},
Title: "Swagger Example API", Title: "Swagger Example API",

View File

@ -15,7 +15,6 @@
}, },
"version": "2.0" "version": "2.0"
}, },
"host": "example.swagger.io",
"basePath": "/v2", "basePath": "/v2",
"paths": { "paths": {
"/books": { "/books": {

View File

@ -11,7 +11,6 @@ definitions:
year: year:
type: integer type: integer
type: object type: object
host: example.swagger.io
info: info:
contact: contact:
email: support@swagger.io email: support@swagger.io