Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions database/queries/registry_entries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ SELECT e.entry_type,
SELECT e.entry_type,
e.name,
v.version,
v.title,
v.description,
v.created_at,
v.updated_at,
src.name AS source_name,
rs.position
FROM registry_source rs
Expand Down
15 changes: 15 additions & 0 deletions docs/thv-registry-api/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions docs/thv-registry-api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,30 @@
},
"github.com_stacklok_toolhive-registry-server_internal_service.RegistryEntryInfo": {
"properties": {
"createdAt": {
"type": "string"
},
"description": {
"type": "string"
},
"entryType": {
"type": "string"
},
"name": {
"type": "string"
},
"position": {
"type": "integer"
},
"sourceName": {
"type": "string"
},
"title": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
"version": {
"type": "string"
}
Expand Down
10 changes: 10 additions & 0 deletions docs/thv-registry-api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,22 @@ components:
type: object
github.com_stacklok_toolhive-registry-server_internal_service.RegistryEntryInfo:
properties:
createdAt:
type: string
description:
type: string
entryType:
type: string
name:
type: string
position:
type: integer
sourceName:
type: string
title:
type: string
updatedAt:
type: string
version:
type: string
type: object
Expand Down
14 changes: 10 additions & 4 deletions internal/api/v1/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,12 @@ func TestListRegistryEntries(t *testing.T) {
registryName: "my-registry",
mockReturn: []service.RegistryEntryInfo{
{
EntryType: "MCP",
Name: "my-server",
Version: "1.0.0",
SourceName: "src1",
EntryType: "MCP",
Name: "my-server",
Version: "1.0.0",
Title: "My Server",
Description: "A test server",
SourceName: "src1",
},
},
wantStatus: http.StatusOK,
Expand Down Expand Up @@ -730,6 +732,10 @@ func TestListRegistryEntries(t *testing.T) {
err = json.Unmarshal(rr.Body.Bytes(), &resp)
require.NoError(t, err)
assert.Len(t, resp.Entries, tt.wantLen)
if tt.wantLen > 0 {
assert.Equal(t, tt.mockReturn[0].Title, resp.Entries[0].Title)
assert.Equal(t, tt.mockReturn[0].Description, resp.Entries[0].Description)
}
}
})
}
Expand Down
22 changes: 17 additions & 5 deletions internal/db/sqlc/registry_entries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions internal/service/db/impl_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,26 @@ func (s *dbService) ListRegistryEntries(ctx context.Context, registryName string
// Map each row directly to RegistryEntryInfo (flat, no grouping)
result := make([]service.RegistryEntryInfo, 0, len(rows))
for _, row := range rows {
result = append(result, service.RegistryEntryInfo{
info := service.RegistryEntryInfo{
EntryType: string(row.EntryType),
Name: row.Name,
Version: row.Version,
SourceName: row.SourceName,
})
Position: row.Position,
}
if row.Title != nil {
info.Title = *row.Title
}
if row.Description != nil {
info.Description = *row.Description
}
if row.CreatedAt != nil {
info.CreatedAt = *row.CreatedAt
}
if row.UpdatedAt != nil {
info.UpdatedAt = *row.UpdatedAt
}
result = append(result, info)
}

span.SetAttributes(otel.AttrResultCount.Int(len(result)))
Expand Down
13 changes: 9 additions & 4 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,15 @@ type SourceEntriesResponse struct {

// RegistryEntryInfo represents a lightweight entry in a registry listing.
type RegistryEntryInfo struct {
EntryType string `json:"entryType"`
Name string `json:"name"`
Version string `json:"version"`
SourceName string `json:"sourceName"`
EntryType string `json:"entryType"`
Name string `json:"name"`
Version string `json:"version"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
SourceName string `json:"sourceName"`
Position int32 `json:"position"`
}

// RegistryEntriesResponse is the JSON envelope for listing registry entries.
Expand Down
Loading