feat(cmd/api): dedupe sdk spec groups
This commit is contained in:
parent
eb7e1e51cb
commit
14eedd7f91
2 changed files with 24 additions and 2 deletions
|
|
@ -131,8 +131,11 @@ func sdkSpecBuilder(title, description, version, termsURL, contactName, contactU
|
|||
}
|
||||
|
||||
func sdkSpecGroups() []goapi.RouteGroup {
|
||||
bridge := goapi.NewToolBridge("/tools")
|
||||
return append(goapi.RegisteredSpecGroups(), bridge)
|
||||
groups := make([]goapi.RouteGroup, 0)
|
||||
for group := range sdkSpecGroupsIter() {
|
||||
groups = append(groups, group)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
func sdkSpecGroupsIter() iter.Seq[goapi.RouteGroup] {
|
||||
|
|
|
|||
|
|
@ -589,3 +589,22 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) {
|
|||
t.Fatalf("expected second server to be /, got %v", servers[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestAPISDKCmd_Good_SpecGroupsDeduplicateToolBridge(t *testing.T) {
|
||||
snapshot := api.RegisteredSpecGroups()
|
||||
api.ResetSpecGroups()
|
||||
t.Cleanup(func() {
|
||||
api.ResetSpecGroups()
|
||||
api.RegisterSpecGroups(snapshot...)
|
||||
})
|
||||
|
||||
api.RegisterSpecGroups(api.NewToolBridge("/tools"))
|
||||
|
||||
groups := sdkSpecGroups()
|
||||
if len(groups) != 1 {
|
||||
t.Fatalf("expected the built-in tools bridge to be deduplicated, got %d groups", len(groups))
|
||||
}
|
||||
if groups[0].BasePath() != "/tools" {
|
||||
t.Fatalf("expected the remaining group to be /tools, got %s", groups[0].BasePath())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue