Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tags are not mandatory. Filter logic was b0rked.
  • Loading branch information
zxchris committed Apr 19, 2016
1 parent 18ca65d commit e0bf135
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion petstore/spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"format": "double"
}
],
"tags": [
"x-tags": [
"Products"
],
"responses": {
Expand Down
13 changes: 9 additions & 4 deletions spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,15 @@ func getMethod(tag spec.Tag, api *API, methods *[]Method, version string, pathit
// Filter and sort by matching current top-level tag with the operation tags.
// If Tagging is not used by spec, then process each operation without filtering.
taglen := len(operation.Tags)
for _, t := range operation.Tags {
if taglen == 0 || tag.Name == "" || t == tag.Name {
method := processMethod(api, pathitem, operation, path, methodname, version)
*methods = append(*methods, *method)
if taglen == 0 {
method := processMethod(api, pathitem, operation, path, methodname, version)
*methods = append(*methods, *method)
} else {
for _, t := range operation.Tags {
if tag.Name == "" || t == tag.Name {
method := processMethod(api, pathitem, operation, path, methodname, version)
*methods = append(*methods, *method)
}
}
}
}
Expand Down

0 comments on commit e0bf135

Please sign in to comment.