13 Commits

Author SHA1 Message Date
Davide Bianchi
24dfb293ea Upgrade version to v0.6.0 2022-11-04 15:15:01 +01:00
Davide Bianchi
a5b9bd3dc4 Merge pull request #86 from davidebianchi/feat/tags-support-in-add-routes 2022-11-04 15:10:02 +01:00
Federico Maggi
7f7c92eaca feat: tags support 2022-11-04 15:01:26 +01:00
Davide Bianchi
9fac38a162 fix 2022-10-03 09:18:13 +02:00
Davide Bianchi
424779a7d8 Upgrade version to v0.5.1 2022-10-03 09:17:33 +02:00
Davide Bianchi
d6a528ea28 fix: changelog 2022-10-03 09:17:25 +02:00
Davide Bianchi
909c58608a upgrade deps 2022-10-03 09:17:02 +02:00
Davide Bianchi
43c6e37a47 Merge pull request #78 from davidebianchi/dependabot/go_modules/github.com/getkin/kin-openapi-0.103.0 2022-10-03 09:14:37 +02:00
dependabot[bot]
b9dc8ff83c chore(deps): bump github.com/getkin/kin-openapi from 0.102.0 to 0.103.0
Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.102.0 to 0.103.0.
- [Release notes](https://github.com/getkin/kin-openapi/releases)
- [Commits](https://github.com/getkin/kin-openapi/compare/v0.102.0...v0.103.0)

---
updated-dependencies:
- dependency-name: github.com/getkin/kin-openapi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-22 03:20:06 +00:00
Davide Bianchi
1b95853d11 Merge pull request #77 from davidebianchi/dependabot/go_modules/github.com/getkin/kin-openapi-0.102.0 2022-09-20 21:44:58 +02:00
Davide Bianchi
e8369933fc Merge pull request #74 from davidebianchi/dependabot/go_modules/github.com/labstack/echo/v4-4.9.0 2022-09-20 21:44:24 +02:00
dependabot[bot]
89d668771a chore(deps): bump github.com/getkin/kin-openapi from 0.98.0 to 0.102.0
Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.98.0 to 0.102.0.
- [Release notes](https://github.com/getkin/kin-openapi/releases)
- [Commits](https://github.com/getkin/kin-openapi/compare/v0.98.0...v0.102.0)

---
updated-dependencies:
- dependency-name: github.com/getkin/kin-openapi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 03:08:43 +00:00
dependabot[bot]
0039a3f74f chore(deps): bump github.com/labstack/echo/v4 from 4.7.2 to 4.9.0
Bumps [github.com/labstack/echo/v4](https://github.com/labstack/echo) from 4.7.2 to 4.9.0.
- [Release notes](https://github.com/labstack/echo/releases)
- [Changelog](https://github.com/labstack/echo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/labstack/echo/compare/v4.7.2...v4.9.0)

---
updated-dependencies:
- dependency-name: github.com/labstack/echo/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 13:15:57 +00:00
7 changed files with 75 additions and 6 deletions

View File

@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
## 0.6.0 - 04-11-2022
### Added
- Tags support to `router.AddRoute` accepted definition
## 0.5.1 - 03-10-2022
### Fixed
- upgrade deps
## v0.5.0 - 05-08-2022
### Added

24
Makefile Normal file
View File

@@ -0,0 +1,24 @@
VERSION ?= latest
# Create a variable that contains the current date in UTC
# Different flow if this script is running on Darwin or Linux machines.
ifeq (Darwin,$(shell uname))
NOW_DATE = $(shell date -u +%d-%m-%Y)
else
NOW_DATE = $(shell date -u -I)
endif
all: test
.PHONY: test
test:
go test ./... -coverprofile coverage.out
$(MAKE) clean
.PHONY: version
version:
sed -i.bck "s|## Unreleased|## Unreleased\n\n## ${VERSION} - ${NOW_DATE}|g" "CHANGELOG.md"
rm -fr "CHANGELOG.md.bck"
git add "CHANGELOG.md"
git commit -m "Upgrade version to v${VERSION}"
git tag v${VERSION}

4
go.mod
View File

@@ -3,13 +3,13 @@ module github.com/davidebianchi/gswagger
go 1.17
require (
github.com/getkin/kin-openapi v0.98.0
github.com/getkin/kin-openapi v0.103.0
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/swag v0.21.1 // indirect
github.com/gorilla/mux v1.8.0
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/invopop/jsonschema v0.6.0
github.com/labstack/echo/v4 v4.7.2
github.com/labstack/echo/v4 v4.9.0
github.com/mailru/easyjson v0.7.7 // indirect
github.com/stretchr/testify v1.8.0
)

8
go.sum
View File

@@ -2,8 +2,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/getkin/kin-openapi v0.98.0 h1:lIACvCG9cxmFsEywz+LCoVhcZHFLUy+Nv5QSkb43eAE=
github.com/getkin/kin-openapi v0.98.0/go.mod h1:w4lRPHiyOdwGbOkLIyk+P0qCwlu7TXPCHD/64nSXzgE=
github.com/getkin/kin-openapi v0.103.0 h1:F5wAtaQvPWxKCAYZ69LgHAThgu16p4u41VQtbn1U8LA=
github.com/getkin/kin-openapi v0.103.0/go.mod h1:w4lRPHiyOdwGbOkLIyk+P0qCwlu7TXPCHD/64nSXzgE=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
@@ -29,8 +29,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/labstack/echo/v4 v4.7.2 h1:Kv2/p8OaQ+M6Ex4eGimg9b9e6icoxA42JSlOR3msKtI=
github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks=
github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY=
github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks=
github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o=
github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=

View File

@@ -73,6 +73,7 @@ type ContentValue struct {
// Definitions of the route.
type Definitions struct {
Tags []string
PathParams ParameterValue
Querystring ParameterValue
Headers ParameterValue
@@ -92,6 +93,7 @@ const (
func (r Router) AddRoute(method string, path string, handler apirouter.HandlerFunc, schema Definitions) (interface{}, error) {
operation := NewOperation()
operation.Responses = make(openapi3.Responses)
operation.Tags = schema.Tags
err := r.resolveRequestBodySchema(schema.RequestBody, operation)
if err != nil {

View File

@@ -422,6 +422,17 @@ func TestAddRoutes(t *testing.T) {
testMethod: http.MethodPost,
fixturesPath: "testdata/oneOf.json",
},
{
name: "schema with tags",
routes: func(t *testing.T, router *Router) {
_, err := router.AddRoute(http.MethodGet, "/users", okHandler, Definitions{
Tags: []string{"Tag1", "Tag2"},
})
require.NoError(t, err)
},
testPath: "/users",
fixturesPath: "testdata/tags.json",
},
}
for _, test := range tests {

20
testdata/tags.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"components": {},
"info": {
"title": "test swagger title",
"version": "test swagger version"
},
"openapi": "3.0.0",
"paths": {
"/users": {
"get": {
"tags": ["Tag1", "Tag2"],
"responses": {
"default": {
"description": ""
}
}
}
}
}
}