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:
adam jones 2025-08-28 15:06:00 +01:00 • committed by GitHub
commit c0a94cca8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 176 additions and 177 deletions

View file

@ -7,7 +7,7 @@ import (
"github.com/google/uuid"
"github.com/modelcontextprotocol/registry/internal/database"
"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"
)
@ -71,7 +71,7 @@ func NewFakeRegistryService() RegistryService {
}
// List retrieves servers with extension wrapper format
func (s *fakeRegistryService) List(cursor string, limit int) ([]apiv1.ServerRecord, string, error) {
func (s *fakeRegistryService) List(cursor string, limit int) ([]apiv0.ServerRecord, string, error) {
// Create a timeout context for the database operation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -83,7 +83,7 @@ func (s *fakeRegistryService) List(cursor string, limit int) ([]apiv1.ServerReco
}
// Return ServerRecords directly (they're now the same as ServerResponse)
result := make([]apiv1.ServerRecord, len(serverRecords))
result := make([]apiv0.ServerRecord, len(serverRecords))
for i, record := range serverRecords {
result[i] = *record
}
@ -92,7 +92,7 @@ func (s *fakeRegistryService) List(cursor string, limit int) ([]apiv1.ServerReco
}
// GetByID retrieves a specific server by its registry metadata ID in extension wrapper format
func (s *fakeRegistryService) GetByID(id string) (*apiv1.ServerRecord, error) {
func (s *fakeRegistryService) GetByID(id string) (*apiv0.ServerRecord, error) {
// Create a timeout context for the database operation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -108,7 +108,7 @@ func (s *fakeRegistryService) GetByID(id string) (*apiv1.ServerRecord, error) {
}
// Publish publishes a server with separated extensions
func (s *fakeRegistryService) Publish(req apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
func (s *fakeRegistryService) Publish(req apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
// Create a timeout context for the database operation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -128,7 +128,7 @@ func (s *fakeRegistryService) Publish(req apiv1.PublishRequest) (*apiv1.ServerRe
// Create registry metadata for fake service (always marks as latest)
now := time.Now()
registryMetadata := apiv1.RegistryExtensions{
registryMetadata := apiv0.RegistryExtensions{
ID: uuid.New().String(),
PublishedAt: now,
UpdatedAt: now,
@ -147,7 +147,7 @@ func (s *fakeRegistryService) Publish(req apiv1.PublishRequest) (*apiv1.ServerRe
}
// EditServer updates an existing server with new details (admin operation)
func (s *fakeRegistryService) EditServer(id string, req apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
func (s *fakeRegistryService) EditServer(id string, req apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

View file

@ -11,7 +11,7 @@ import (
"github.com/google/uuid"
"github.com/modelcontextprotocol/registry/internal/database"
"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"
)
@ -30,7 +30,7 @@ func NewRegistryServiceWithDB(db database.Database) RegistryService {
}
// List returns registry entries with cursor-based pagination in extension wrapper format
func (s *registryServiceImpl) List(cursor string, limit int) ([]apiv1.ServerRecord, string, error) {
func (s *registryServiceImpl) List(cursor string, limit int) ([]apiv0.ServerRecord, string, error) {
// Create a timeout context for the database operation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -47,7 +47,7 @@ func (s *registryServiceImpl) List(cursor string, limit int) ([]apiv1.ServerReco
}
// Return ServerRecords directly (they're now the same as ServerResponse)
result := make([]apiv1.ServerRecord, len(serverRecords))
result := make([]apiv0.ServerRecord, len(serverRecords))
for i, record := range serverRecords {
result[i] = *record
}
@ -56,7 +56,7 @@ func (s *registryServiceImpl) List(cursor string, limit int) ([]apiv1.ServerReco
}
// GetByID retrieves a specific server by its registry metadata ID in extension wrapper format
func (s *registryServiceImpl) GetByID(id string) (*apiv1.ServerRecord, error) {
func (s *registryServiceImpl) GetByID(id string) (*apiv0.ServerRecord, error) {
// Create a timeout context for the database operation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -127,7 +127,7 @@ func validatePackage(pkg *model.Package) error {
}
// Publish publishes a server with separated extensions
func (s *registryServiceImpl) Publish(req apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
func (s *registryServiceImpl) Publish(req apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
// Create a timeout context for the database operation
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
@ -204,7 +204,7 @@ func (s *registryServiceImpl) Publish(req apiv1.PublishRequest) (*apiv1.ServerRe
publisherExtensions := validators.ExtractPublisherExtensions(req)
// Create registry metadata with service-determined values
registryMetadata := apiv1.RegistryExtensions{
registryMetadata := apiv0.RegistryExtensions{
ID: uuid.New().String(),
PublishedAt: currentTime,
UpdatedAt: currentTime,
@ -256,7 +256,7 @@ func (s *registryServiceImpl) validateNoDuplicateRemoteURLs(ctx context.Context,
}
// EditServer updates an existing server with new details (admin operation)
func (s *registryServiceImpl) EditServer(id string, req apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
func (s *registryServiceImpl) EditServer(id string, req apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

View file

@ -1,15 +1,15 @@
package service
import apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
import apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
// RegistryService defines the interface for registry operations
type RegistryService interface {
// List retrieves servers with unified format
List(cursor string, limit int) ([]apiv1.ServerRecord, string, error)
List(cursor string, limit int) ([]apiv0.ServerRecord, string, error)
// GetByID retrieves a single server by registry metadata ID with unified format
GetByID(id string) (*apiv1.ServerRecord, error)
GetByID(id string) (*apiv0.ServerRecord, error)
// Publish publishes a server with separated extensions
Publish(req apiv1.PublishRequest) (*apiv1.ServerRecord, error)
Publish(req apiv0.PublishRequest) (*apiv0.ServerRecord, error)
// EditServer updates an existing server with new details
EditServer(id string, req apiv1.PublishRequest) (*apiv1.ServerRecord, error)
EditServer(id string, req apiv0.PublishRequest) (*apiv0.ServerRecord, error)
}