mirror of
https://github.com/davidebianchi/gswagger.git
synced 2026-01-02 20:28:29 -05:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24dfb293ea | ||
|
|
a5b9bd3dc4 | ||
|
|
7f7c92eaca | ||
|
|
9fac38a162 | ||
|
|
424779a7d8 | ||
|
|
d6a528ea28 | ||
|
|
909c58608a | ||
|
|
43c6e37a47 | ||
|
|
b9dc8ff83c | ||
|
|
1b95853d11 | ||
|
|
e8369933fc | ||
|
|
89d668771a | ||
|
|
0039a3f74f |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -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
24
Makefile
Normal 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
4
go.mod
@@ -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
8
go.sum
@@ -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=
|
||||
|
||||
2
route.go
2
route.go
@@ -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 {
|
||||
|
||||
@@ -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
20
testdata/tags.json
vendored
Normal 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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user