diff --git a/cmd/internal/pkgsite-cli/client/client.go b/cmd/internal/pkgsite-cli/client/client.go
index e50784a..e8eec81 100644
--- a/cmd/internal/pkgsite-cli/client/client.go
+++ b/cmd/internal/pkgsite-cli/client/client.go
@@ -159,11 +159,11 @@
}
u := c.server.JoinPath("v1", "symbols", path)
u.RawQuery = q.Encode()
- var resp PaginatedResponse[Symbol]
+ var resp PackageSymbols
if err := c.get(ctx, u.String(), &resp); err != nil {
return nil, err
}
- return &resp, nil
+ return &resp.Symbols, nil
}
// ImportedByOptions contains options for GetImportedBy.
diff --git a/cmd/internal/pkgsite-cli/client/client_test.go b/cmd/internal/pkgsite-cli/client/client_test.go
index 2a0069a..9052c90 100644
--- a/cmd/internal/pkgsite-cli/client/client_test.go
+++ b/cmd/internal/pkgsite-cli/client/client_test.go
@@ -202,13 +202,17 @@
func TestGetSymbols(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- json.NewEncoder(w).Encode(PaginatedResponse[Symbol]{
- Items: []Symbol{{
- Name: "Marshal",
- Kind: "func",
- Synopsis: "func Marshal(v any) ([]byte, error)",
- }},
- Total: 1,
+ json.NewEncoder(w).Encode(PackageSymbols{
+ ModulePath: "std",
+ Version: "go1.26.0",
+ Symbols: PaginatedResponse[Symbol]{
+ Items: []Symbol{{
+ Name: "Marshal",
+ Kind: "func",
+ Synopsis: "func Marshal(v any) ([]byte, error)",
+ }},
+ Total: 1,
+ },
})
}))
defer srv.Close()
diff --git a/cmd/internal/pkgsite-cli/client/types_gen.go b/cmd/internal/pkgsite-cli/client/types_gen.go
index 70a9b0e..22a7ddd 100644
--- a/cmd/internal/pkgsite-cli/client/types_gen.go
+++ b/cmd/internal/pkgsite-cli/client/types_gen.go
@@ -80,14 +80,19 @@
Contents string `json:"contents"`
}
-// Symbol is a symbol in /v1/symbols/{packagePath}.
+// PackageSymbols is the response for /v1/symbols/{packagePath}.
+type PackageSymbols struct {
+ ModulePath string `json:"modulePath"`
+ Version string `json:"version"`
+ Symbols PaginatedResponse[Symbol] `json:"symbols"`
+}
+
+// Symbol is a symbol in a package.
type Symbol struct {
- ModulePath string `json:"modulePath"`
- Version string `json:"version"`
- Name string `json:"name"`
- Kind string `json:"kind"`
- Synopsis string `json:"synopsis"`
- Parent string `json:"parent,omitempty"`
+ Name string `json:"name"`
+ Kind string `json:"kind"`
+ Synopsis string `json:"synopsis"`
+ Parent string `json:"parent,omitempty"`
}
// SearchResults is the response for /v1/search?q={query}.
diff --git a/internal/api/api.go b/internal/api/api.go
index 95c898f..d7ff45b 100644
--- a/internal/api/api.go
+++ b/internal/api/api.go
@@ -372,20 +372,23 @@
var items []Symbol
for _, s := range syms {
items = append(items, Symbol{
- ModulePath: um.ModulePath,
- Version: um.Version,
- Name: s.Name,
- Kind: string(s.Kind),
- Synopsis: s.Synopsis,
- Parent: s.ParentName,
+ Name: s.Name,
+ Kind: string(s.Kind),
+ Synopsis: s.Synopsis,
+ Parent: s.ParentName,
})
}
- // api:response PaginatedResponse[Symbol]
- resp, err := paginate(items, params.ListParams, defaultLimit)
+ // api:response PackageSymbols
+ paged, err := paginate(items, params.ListParams, defaultLimit)
if err != nil {
return err
}
+ resp := PackageSymbols{
+ ModulePath: um.ModulePath,
+ Version: um.Version,
+ Symbols: paged,
+ }
return serveJSON(w, http.StatusOK, resp, versionCacheDur(params.Version))
}
diff --git a/internal/api/types.go b/internal/api/types.go
index 93c590f..e765a13 100644
--- a/internal/api/types.go
+++ b/internal/api/types.go
@@ -81,14 +81,19 @@
Contents string `json:"contents"`
}
-// Symbol is a symbol in /v1/symbols/{packagePath}.
+// PackageSymbols is the response for /v1/symbols/{packagePath}.
+type PackageSymbols struct {
+ ModulePath string `json:"modulePath"`
+ Version string `json:"version"`
+ Symbols PaginatedResponse[Symbol] `json:"symbols"`
+}
+
+// Symbol is a symbol in a package.
type Symbol struct {
- ModulePath string `json:"modulePath"`
- Version string `json:"version"`
- Name string `json:"name"`
- Kind string `json:"kind"`
- Synopsis string `json:"synopsis"`
- Parent string `json:"parent,omitempty"`
+ Name string `json:"name"`
+ Kind string `json:"kind"`
+ Synopsis string `json:"synopsis"`
+ Parent string `json:"parent,omitempty"`
}
// SearchResults is the response for /v1/search?q={query}.
diff --git a/internal/tests/api/api_test.go b/internal/tests/api/api_test.go
index c4d6f6a..7c7fd90 100644
--- a/internal/tests/api/api_test.go
+++ b/internal/tests/api/api_test.go
@@ -1174,12 +1174,12 @@
}
if test.wantStatus == http.StatusOK {
- var got api.PaginatedResponse[api.Symbol]
+ var got api.PackageSymbols
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
t.Fatalf("json.Unmarshal: %v", err)
}
var gotNames []string
- for _, it := range got.Items {
+ for _, it := range got.Symbols.Items {
gotNames = append(gotNames, it.Name)
}
slices.Sort(gotNames)