File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
examples/petstore/lib/testdata/doc Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 949
949
"description" : " local server" ,
950
950
"url" : " http://localhost:9999"
951
951
}
952
+ ],
953
+ "tags" : [
954
+ {
955
+ "name" : " pets"
956
+ },
957
+ {
958
+ "name" : " my-tag"
959
+ }
952
960
]
953
961
}
Original file line number Diff line number Diff line change @@ -52,10 +52,26 @@ func (s *Server) Show() *Server {
52
52
return s
53
53
}
54
54
55
+ func declareAllTagsFromOperations (s * Server ) {
56
+ for _ , pathItem := range s .OpenApiSpec .Paths .Map () {
57
+ for _ , op := range pathItem .Operations () {
58
+ for _ , tag := range op .Tags {
59
+ if s .OpenApiSpec .Tags .Get (tag ) == nil {
60
+ s .OpenApiSpec .Tags = append (s .OpenApiSpec .Tags , & openapi3.Tag {
61
+ Name : tag ,
62
+ })
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+
55
69
// OutputOpenAPISpec takes the OpenAPI spec and outputs it to a JSON file and/or serves it on a URL.
56
70
// Also serves a Swagger UI.
57
71
// To modify its behavior, use the [WithOpenAPIConfig] option.
58
72
func (s * Server ) OutputOpenAPISpec () openapi3.T {
73
+ declareAllTagsFromOperations (s )
74
+
59
75
// Validate
60
76
err := s .OpenApiSpec .Validate (context .Background ())
61
77
if err != nil {
You can’t perform that action at this time.
0 commit comments