mirror of
https://github.com/davidebianchi/gswagger.git
synced 2026-01-03 20:58:44 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24dfb293ea | ||
|
|
a5b9bd3dc4 | ||
|
|
7f7c92eaca | ||
|
|
9fac38a162 |
@@ -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
|
||||
|
||||
2
Makefile
2
Makefile
@@ -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}"
|
||||
|
||||
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