Skip to content

Commit 966b211

Browse files
committed
feat: add support for tags in OpenAPI endpoint registration
1 parent 9baf901 commit 966b211

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (s *App) Sync() {
6565
for _, e := range s.endpoints {
6666
s.framework.Register(e.path, e.method, s.createHandler(e.handlers...))
6767
if e.addToSpec {
68-
s.spec.Register(s.framework.GetOpenAPICompatiblePathPattern(e.path), e.method, e.handlers...)
68+
s.spec.Register(s.framework.GetOpenAPICompatiblePathPattern(e.path), e.method, e.tags, e.handlers...)
6969
}
7070
}
7171
}

pkg/spec/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ func (s *Spec) ToJson() any {
7979
return s.spec
8080
}
8181

82-
func (s *Spec) Register(path string, method string, handlers ...interface{}) {
82+
func (s *Spec) Register(path string, method string, tags []string, handlers ...interface{}) {
8383
if s.spec.Paths.Find(path) == nil {
8484
s.spec.Paths.Set(path, &openapi3.PathItem{})
8585
}
8686

8787
op := openapi3.NewOperation()
8888

89+
if tags != nil {
90+
op.Tags = tags
91+
}
92+
8993
for _, h := range handlers {
9094
addRequestInfo(s.gen, s.spec.Components.Schemas, op, h)
9195
}

0 commit comments

Comments
 (0)