4 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
5 changed files with 42 additions and 1 deletions

View File

@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
## 0.6.0 - 04-11-2022
### Added
- Tags support to `router.AddRoute` accepted definition
## 0.5.1 - 03-10-2022
### Fixed

View File

@@ -17,7 +17,7 @@ test:
.PHONY: version
version:
sed -i.bck "s|## Unreleased|## ${VERSION} - ${NOW_DATE}|g" "CHANGELOG.md"
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}"

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": ""
}
}
}
}
}
}