Rename api/v1 -> api/v0 to match API paths (#320)
This PR renames the API paths from v1 to v0 to align with the actual API versioning scheme.
This commit is contained in:
parent
099a2d702e
commit
c0a94cca8c
8 changed files with 176 additions and 177 deletions
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/internal/database"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
"github.com/modelcontextprotocol/registry/internal/validators"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
)
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ func RegisterEditEndpoints(api huma.API, registry service.RegistryService, cfg *
|
|||
Security: []map[string][]string{
|
||||
{"bearer": {}},
|
||||
},
|
||||
}, func(ctx context.Context, input *EditServerInput) (*Response[apiv1.ServerRecord], error) {
|
||||
}, func(ctx context.Context, input *EditServerInput) (*Response[apiv0.ServerRecord], error) {
|
||||
// Extract bearer token
|
||||
const bearerPrefix = "Bearer "
|
||||
authHeader := input.Authorization
|
||||
|
|
@ -74,7 +74,7 @@ func RegisterEditEndpoints(api huma.API, registry service.RegistryService, cfg *
|
|||
}
|
||||
|
||||
// Parse the validated request body
|
||||
var editRequest apiv1.PublishRequest
|
||||
var editRequest apiv0.PublishRequest
|
||||
if err := json.Unmarshal(input.RawBody, &editRequest); err != nil {
|
||||
return nil, huma.Error400BadRequest("Invalid JSON format", err)
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func RegisterEditEndpoints(api huma.API, registry service.RegistryService, cfg *
|
|||
return nil, huma.Error400BadRequest("Failed to edit server", err)
|
||||
}
|
||||
|
||||
return &Response[apiv1.ServerRecord]{
|
||||
return &Response[apiv0.ServerRecord]{
|
||||
Body: *updatedServer,
|
||||
}, nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/database"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
)
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
})
|
||||
return "Bearer " + token
|
||||
}(),
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Updated test server",
|
||||
|
|
@ -62,7 +62,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
// Current server (not deleted)
|
||||
currentServer := &apiv1.ServerRecord{
|
||||
currentServer := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Original server",
|
||||
|
|
@ -71,14 +71,14 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
}
|
||||
registry.On("GetByID", "550e8400-e29b-41d4-a716-446655440001").Return(currentServer, nil)
|
||||
|
||||
expectedResponse := &apiv1.ServerRecord{
|
||||
expectedResponse := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Updated test server",
|
||||
Status: model.StatusDeprecated,
|
||||
},
|
||||
}
|
||||
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v1.PublishRequest")).Return(expectedResponse, nil)
|
||||
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v0.PublishRequest")).Return(expectedResponse, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
|
|
@ -86,7 +86,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
name: "missing authorization header",
|
||||
serverID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
authHeader: "",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: 422,
|
||||
expectedError: "required header parameter is missing",
|
||||
|
|
@ -95,7 +95,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
name: "invalid authorization header format",
|
||||
serverID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
authHeader: "InvalidFormat token123",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
expectedError: "Unauthorized",
|
||||
|
|
@ -104,7 +104,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
name: "invalid token",
|
||||
serverID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
authHeader: "Bearer invalid-token",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
expectedError: "Unauthorized",
|
||||
|
|
@ -123,7 +123,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
})
|
||||
return "Bearer " + token
|
||||
}(),
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Updated test server",
|
||||
|
|
@ -131,7 +131,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
// Need to mock GetByID since we check permissions against existing server name
|
||||
currentServer := &apiv1.ServerRecord{
|
||||
currentServer := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Original server",
|
||||
|
|
@ -157,7 +157,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
})
|
||||
return "Bearer " + token
|
||||
}(),
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.other/test-server",
|
||||
Description: "Updated test server",
|
||||
|
|
@ -166,7 +166,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
setupMocks: func(registry *MockRegistryService) {
|
||||
// Need to mock GetByID since we check permissions against existing server name
|
||||
// This test case shows a different scenario: existing server is "other" but user only has perms for "domdomegg"
|
||||
currentServer := &apiv1.ServerRecord{
|
||||
currentServer := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.other/test-server",
|
||||
Description: "Original server",
|
||||
|
|
@ -192,7 +192,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
})
|
||||
return "Bearer " + token
|
||||
}(),
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Updated test server",
|
||||
|
|
@ -218,7 +218,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
})
|
||||
return "Bearer " + token
|
||||
}(),
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Updated test server",
|
||||
|
|
@ -226,7 +226,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
// Current server (not deleted)
|
||||
currentServer := &apiv1.ServerRecord{
|
||||
currentServer := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Original server",
|
||||
|
|
@ -234,7 +234,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
},
|
||||
}
|
||||
registry.On("GetByID", "550e8400-e29b-41d4-a716-446655440001").Return(currentServer, nil)
|
||||
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v1.PublishRequest")).Return(nil, errors.New("database error"))
|
||||
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v0.PublishRequest")).Return(nil, errors.New("database error"))
|
||||
},
|
||||
expectedStatus: http.StatusBadRequest,
|
||||
expectedError: "Bad Request",
|
||||
|
|
@ -272,7 +272,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
})
|
||||
return "Bearer " + token
|
||||
}(),
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Trying to undelete server",
|
||||
|
|
@ -281,7 +281,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
|||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
// Current server is deleted
|
||||
currentServer := &apiv1.ServerRecord{
|
||||
currentServer := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.domdomegg/test-server",
|
||||
Description: "Original server",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
"github.com/modelcontextprotocol/registry/internal/validators"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
)
|
||||
|
||||
// PublishServerInput represents the input for publishing a server
|
||||
|
|
@ -35,7 +35,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
|
|||
Security: []map[string][]string{
|
||||
{"bearer": {}},
|
||||
},
|
||||
}, func(ctx context.Context, input *PublishServerInput) (*Response[apiv1.ServerRecord], error) {
|
||||
}, func(ctx context.Context, input *PublishServerInput) (*Response[apiv0.ServerRecord], error) {
|
||||
// Extract bearer token
|
||||
const bearerPrefix = "Bearer "
|
||||
authHeader := input.Authorization
|
||||
|
|
@ -56,7 +56,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
|
|||
}
|
||||
|
||||
// Parse the validated request body
|
||||
var publishRequest apiv1.PublishRequest
|
||||
var publishRequest apiv0.PublishRequest
|
||||
if err := json.Unmarshal(input.RawBody, &publishRequest); err != nil {
|
||||
return nil, huma.Error400BadRequest("Invalid JSON format", err)
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
|
|||
}
|
||||
|
||||
// Return the published server in extension wrapper format
|
||||
return &Response[apiv1.ServerRecord]{
|
||||
return &Response[apiv0.ServerRecord]{
|
||||
Body: *publishedServer,
|
||||
}, nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -54,7 +54,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
v0.RegisterPublishEndpoint(api, registryService, testConfig)
|
||||
|
||||
t.Run("successful publish with GitHub auth", func(t *testing.T) {
|
||||
publishReq := apiv1.PublishRequest{
|
||||
publishReq := apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.testuser/test-mcp-server",
|
||||
Description: "A test MCP server for integration testing",
|
||||
|
|
@ -92,7 +92,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
|
||||
assert.Equal(t, http.StatusOK, rr.Code)
|
||||
|
||||
var response apiv1.ServerRecord
|
||||
var response apiv0.ServerRecord
|
||||
err = json.Unmarshal(rr.Body.Bytes(), &response)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("successful publish with none auth (no prefix)", func(t *testing.T) {
|
||||
publishReq := apiv1.PublishRequest{
|
||||
publishReq := apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "com.example/test-mcp-server-no-auth",
|
||||
Description: "A test MCP server without authentication",
|
||||
|
|
@ -138,7 +138,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
|
||||
assert.Equal(t, http.StatusOK, rr.Code)
|
||||
|
||||
var response apiv1.ServerRecord
|
||||
var response apiv0.ServerRecord
|
||||
err = json.Unmarshal(rr.Body.Bytes(), &response)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("publish fails with missing authorization header", func(t *testing.T) {
|
||||
publishReq := apiv1.PublishRequest{
|
||||
publishReq := apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server",
|
||||
},
|
||||
|
|
@ -167,7 +167,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("publish fails with invalid token", func(t *testing.T) {
|
||||
publishReq := apiv1.PublishRequest{
|
||||
publishReq := apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server",
|
||||
},
|
||||
|
|
@ -188,7 +188,7 @@ func TestPublishIntegration(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("publish fails when permission denied", func(t *testing.T) {
|
||||
publishReq := apiv1.PublishRequest{
|
||||
publishReq := apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.other/test-server",
|
||||
Description: "A test server",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
|
||||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
|
@ -29,33 +29,33 @@ type MockRegistryService struct {
|
|||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) List(cursor string, limit int) ([]apiv1.ServerRecord, string, error) {
|
||||
func (m *MockRegistryService) List(cursor string, limit int) ([]apiv0.ServerRecord, string, error) {
|
||||
args := m.Called(cursor, limit)
|
||||
return args.Get(0).([]apiv1.ServerRecord), args.String(1), args.Error(2)
|
||||
return args.Get(0).([]apiv0.ServerRecord), args.String(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) GetByID(id string) (*apiv1.ServerRecord, error) {
|
||||
func (m *MockRegistryService) GetByID(id string) (*apiv0.ServerRecord, error) {
|
||||
args := m.Called(id)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).(*apiv1.ServerRecord), args.Error(1)
|
||||
return args.Get(0).(*apiv0.ServerRecord), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) Publish(request apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
|
||||
func (m *MockRegistryService) Publish(request apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
|
||||
args := m.Called(request)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).(*apiv1.ServerRecord), args.Error(1)
|
||||
return args.Get(0).(*apiv0.ServerRecord), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) EditServer(id string, request apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
|
||||
func (m *MockRegistryService) EditServer(id string, request apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
|
||||
args := m.Called(id, request)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).(*apiv1.ServerRecord), args.Error(1)
|
||||
return args.Get(0).(*apiv0.ServerRecord), args.Error(1)
|
||||
}
|
||||
|
||||
// Helper function to generate a valid JWT token for testing
|
||||
|
|
@ -88,7 +88,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "successful publish with GitHub auth",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.example/test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -110,13 +110,13 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.On("Publish", mock.AnythingOfType("v1.PublishRequest")).Return(&apiv1.ServerRecord{}, nil)
|
||||
registry.On("Publish", mock.AnythingOfType("v0.PublishRequest")).Return(&apiv0.ServerRecord{}, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "successful publish with no auth (AuthMethodNone)",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "example/test-server",
|
||||
Description: "A test server without auth",
|
||||
|
|
@ -137,13 +137,13 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.On("Publish", mock.AnythingOfType("v1.PublishRequest")).Return(&apiv1.ServerRecord{}, nil)
|
||||
registry.On("Publish", mock.AnythingOfType("v0.PublishRequest")).Return(&apiv0.ServerRecord{}, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "missing authorization header",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
authHeader: "", // Empty auth header
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: http.StatusUnprocessableEntity,
|
||||
|
|
@ -151,7 +151,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "invalid authorization header format",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
authHeader: "InvalidFormat",
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
|
|
@ -159,7 +159,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "invalid token",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -175,7 +175,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "permission denied",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.other/test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -201,7 +201,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "registry service error",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "example/test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -222,7 +222,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.On("Publish", mock.AnythingOfType("v1.PublishRequest")).Return(nil, errors.New("cannot publish duplicate version"))
|
||||
registry.On("Publish", mock.AnythingOfType("v0.PublishRequest")).Return(nil, errors.New("cannot publish duplicate version"))
|
||||
},
|
||||
expectedStatus: http.StatusBadRequest,
|
||||
expectedError: "Failed to publish server",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/danielgtaylor/huma/v2"
|
||||
"github.com/google/uuid"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
)
|
||||
|
||||
// Metadata contains pagination metadata
|
||||
|
|
@ -25,7 +25,7 @@ type ListServersInput struct {
|
|||
|
||||
// ListServersBody represents the paginated server list response body
|
||||
type ListServersBody struct {
|
||||
Servers []apiv1.ServerRecord `json:"servers" doc:"List of MCP servers with extensions"`
|
||||
Servers []apiv0.ServerRecord `json:"servers" doc:"List of MCP servers with extensions"`
|
||||
Metadata *Metadata `json:"metadata,omitempty" doc:"Pagination metadata"`
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ func RegisterServersEndpoints(api huma.API, registry service.RegistryService) {
|
|||
Summary: "Get MCP server details",
|
||||
Description: "Get detailed information about a specific MCP server",
|
||||
Tags: []string{"servers"},
|
||||
}, func(_ context.Context, input *ServerDetailInput) (*Response[apiv1.ServerRecord], error) {
|
||||
}, func(_ context.Context, input *ServerDetailInput) (*Response[apiv0.ServerRecord], error) {
|
||||
// Get the server details from the registry service
|
||||
serverDetail, err := registry.GetByID(input.ID)
|
||||
if err != nil {
|
||||
|
|
@ -95,7 +95,7 @@ func RegisterServersEndpoints(api huma.API, registry service.RegistryService) {
|
|||
return nil, huma.Error500InternalServerError("Failed to get server details", err)
|
||||
}
|
||||
|
||||
return &Response[apiv1.ServerRecord]{
|
||||
return &Response[apiv0.ServerRecord]{
|
||||
Body: *serverDetail,
|
||||
}, nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/danielgtaylor/huma/v2/adapters/humago"
|
||||
"github.com/google/uuid"
|
||||
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
|
@ -24,14 +24,14 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
queryParams string
|
||||
setupMocks func(*MockRegistryService)
|
||||
expectedStatus int
|
||||
expectedServers []apiv1.ServerRecord
|
||||
expectedServers []apiv0.ServerRecord
|
||||
expectedMeta *v0.Metadata
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
name: "successful list with default parameters",
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
servers := []apiv1.ServerRecord{
|
||||
servers := []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-1",
|
||||
|
|
@ -45,7 +45,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
},
|
||||
},
|
||||
|
|
@ -62,7 +62,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
},
|
||||
},
|
||||
|
|
@ -70,7 +70,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
registry.Mock.On("List", "", 30).Return(servers, "", nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
expectedServers: []apiv1.ServerRecord{
|
||||
expectedServers: []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-1",
|
||||
|
|
@ -84,7 +84,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
},
|
||||
},
|
||||
|
|
@ -101,7 +101,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
},
|
||||
},
|
||||
|
|
@ -111,7 +111,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
name: "successful list with cursor and limit",
|
||||
queryParams: "?cursor=550e8400-e29b-41d4-a716-446655440000&limit=10",
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
servers := []apiv1.ServerRecord{
|
||||
servers := []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-3",
|
||||
|
|
@ -125,7 +125,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.5.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440003",
|
||||
},
|
||||
},
|
||||
|
|
@ -134,7 +134,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
registry.Mock.On("List", mock.AnythingOfType("string"), 10).Return(servers, nextCursor, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
expectedServers: []apiv1.ServerRecord{
|
||||
expectedServers: []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-3",
|
||||
|
|
@ -148,7 +148,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.5.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440003",
|
||||
},
|
||||
},
|
||||
|
|
@ -196,7 +196,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
{
|
||||
name: "registry service error",
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.Mock.On("List", "", 30).Return([]apiv1.ServerRecord{}, "", errors.New("database connection error"))
|
||||
registry.Mock.On("List", "", 30).Return([]apiv0.ServerRecord{}, "", errors.New("database connection error"))
|
||||
},
|
||||
expectedStatus: http.StatusInternalServerError,
|
||||
expectedError: "Failed to get registry list",
|
||||
|
|
@ -233,7 +233,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
|
||||
// Parse response body
|
||||
var resp struct {
|
||||
Servers []apiv1.ServerRecord `json:"servers"`
|
||||
Servers []apiv0.ServerRecord `json:"servers"`
|
||||
Metadata *v0.Metadata `json:"metadata,omitempty"`
|
||||
}
|
||||
err := json.NewDecoder(w.Body).Decode(&resp)
|
||||
|
|
@ -268,14 +268,14 @@ func TestServersDetailEndpoint(t *testing.T) {
|
|||
serverID string
|
||||
setupMocks func(*MockRegistryService, string)
|
||||
expectedStatus int
|
||||
expectedServer *apiv1.ServerRecord
|
||||
expectedServer *apiv0.ServerRecord
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
name: "successful get server detail",
|
||||
serverID: uuid.New().String(),
|
||||
setupMocks: func(registry *MockRegistryService, serverID string) {
|
||||
serverDetail := &apiv1.ServerRecord{
|
||||
serverDetail := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-detail",
|
||||
Description: "Test server detail",
|
||||
|
|
@ -288,7 +288,7 @@ func TestServersDetailEndpoint(t *testing.T) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: serverID,
|
||||
},
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ func TestServersDetailEndpoint(t *testing.T) {
|
|||
assert.Equal(t, "application/json", w.Header().Get("Content-Type"))
|
||||
|
||||
// Parse response body
|
||||
var serverDetailResp apiv1.ServerRecord
|
||||
var serverDetailResp apiv0.ServerRecord
|
||||
err := json.NewDecoder(w.Body).Decode(&serverDetailResp)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
|
||||
// Test data
|
||||
serverID := uuid.New().String()
|
||||
servers := []apiv1.ServerRecord{
|
||||
servers := []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "integration-test-server",
|
||||
|
|
@ -390,13 +390,13 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: serverID,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
serverDetail := &apiv1.ServerRecord{
|
||||
serverDetail := &apiv0.ServerRecord{
|
||||
Server: servers[0].Server,
|
||||
XIOModelContextProtocolRegistry: servers[0].XIOModelContextProtocolRegistry,
|
||||
}
|
||||
|
|
@ -439,7 +439,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
|
||||
// Parse response body
|
||||
var listResp struct {
|
||||
Servers []apiv1.ServerRecord `json:"servers"`
|
||||
Servers []apiv0.ServerRecord `json:"servers"`
|
||||
}
|
||||
err = json.NewDecoder(resp.Body).Decode(&listResp)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -470,7 +470,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
||||
|
||||
// Parse response body
|
||||
var serverDetailResp apiv1.ServerRecord
|
||||
var serverDetailResp apiv0.ServerRecord
|
||||
err = json.NewDecoder(resp.Body).Decode(&serverDetailResp)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/internal/api/router"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/telemetry"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
)
|
||||
|
||||
func mockServerEndpoint(registry *MockRegistryService, serverID string) {
|
||||
serverDetail := &apiv1.ServerRecord{
|
||||
serverDetail := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-detail",
|
||||
Description: "Test server detail",
|
||||
|
|
@ -33,7 +33,7 @@ func mockServerEndpoint(registry *MockRegistryService, serverID string) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: serverID,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue