Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump github.com/swaggo/swag to v2 #319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ gin middleware to automatically generate RESTful API documentation with Swagger

### Start using it

1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swaggo/swag/blob/master/README.md#declarative-comments-format).
2. Download [Swag](https://github.com/swaggo/swag) for Go by using:
1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swaggo/swag/v2/blob/master/README.md#declarative-comments-format).
2. Download [Swag](https://github.com/swaggo/swag/v2) for Go by using:

```sh
go get -u github.com/swaggo/swag/cmd/swag
go get -u github.com/swaggo/swag/v2/cmd/swag
```

Starting in Go 1.17, installing executables with `go get` is deprecated. `go install` may be used instead:

```sh
go install github.com/swaggo/swag/cmd/swag@latest
go install github.com/swaggo/swag/v2/cmd/swag@latest
```

3. Run the [Swag](https://github.com/swaggo/swag) at your Go project root path(for instance `~/root/go-project-name`),
[Swag](https://github.com/swaggo/swag) will parse comments and generate required files(`docs` folder and `docs/doc.go`)
3. Run the [Swag](https://github.com/swaggo/swag/v2) at your Go project root path(for instance `~/root/go-project-name`),
[Swag](https://github.com/swaggo/swag/v2) will parse comments and generate required files(`docs` folder and `docs/doc.go`)
at `~/root/go-project-name/docs`.

```sh
Expand Down
3 changes: 1 addition & 2 deletions example/basic/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package api
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/swaggo/swag/example/basic/web"
"github.com/swaggo/swag/v2/example/basic/web"
)

//
// @Summary Add a new pet to the store
// @Description get string by ID
// @Accept json
Expand Down
157 changes: 18 additions & 139 deletions example/basic/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 8 additions & 128 deletions example/basic/docs/swagger.json
Original file line number Diff line number Diff line change
@@ -1,130 +1,10 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.",
"title": "Swagger Example API",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0"
},
"host": "petstore.swagger.io:8080",
"basePath": "/v2",
"paths": {
"/testapi/get-string-by-int/{some_id}": {
"get": {
"description": "get string by ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Add a new pet to the store",
"parameters": [
{
"type": "integer",
"description": "Some ID",
"name": "some_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "ok",
"schema": {
"type": "string"
}
},
"400": {
"description": "We need ID!!",
"schema": {
"$ref": "#/definitions/web.APIError"
}
},
"404": {
"description": "Can not find ID",
"schema": {
"$ref": "#/definitions/web.APIError"
}
}
}
}
},
"/testapi/get-struct-array-by-string/{some_id}": {
"get": {
"description": "get struct array by ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"type": "string",
"description": "Some ID",
"name": "some_id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "Offset",
"name": "limit",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "ok",
"schema": {
"type": "string"
}
},
"400": {
"description": "We need ID!!",
"schema": {
"$ref": "#/definitions/web.APIError"
}
},
"404": {
"description": "Can not find ID",
"schema": {
"$ref": "#/definitions/web.APIError"
}
}
}
}
}
},
"definitions": {
"web.APIError": {
"type": "object",
"properties": {
"errorCode": {
"type": "integer"
},
"errorMessage": {
"type": "string"
}
}
}
}
"components": {"schemas":{"web.APIError":{"properties":{"errorCode":{"type":"integer"},"errorMessage":{"type":"string"}},"type":"object"}}},
"info": {"contact":{"email":"[email protected]","name":"API Support","url":"http://www.swagger.io/support"},"description":"This is a sample server Petstore server.","license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"},"termsOfService":"http://swagger.io/terms/","title":"Swagger Example API","version":"1.0"},
"externalDocs": {"description":"","url":""},
"paths": {"/testapi/get-string-by-int/{some_id}":{"get":{"description":"get string by ID","parameters":[{"description":"Some ID","in":"path","name":"some_id","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"string"}}},"description":"ok"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/web.APIError"}}},"description":"We need ID!!"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/web.APIError"}}},"description":"Can not find ID"}},"summary":"Add a new pet to the store"}},"/testapi/get-struct-array-by-string/{some_id}":{"get":{"description":"get struct array by ID","parameters":[{"description":"Some ID","in":"path","name":"some_id","required":true,"schema":{"type":"string"}},{"description":"Offset","in":"query","name":"offset","required":true,"schema":{"type":"integer"}},{"description":"Limit","in":"query","name":"limit","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"string"}}},"description":"ok"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/web.APIError"}}},"description":"We need ID!!"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/web.APIError"}}},"description":"Can not find ID"}}}}},
"openapi": "3.1.0",
"servers": [
{"url":"petstore.swagger.io:8080/v2"}
]
}
Loading