Clean up schema by simplifying version structure (#379)

## Summary

Simplified the schema structure by:
- Replacing `version_detail.version` with direct `version` field  
- Removing unused `release_date` field from seed data
- Updating all API types, models, and tests to match new structure
- Maintaining backwards compatibility in API responses

This change makes the schema more intuitive and reduces nesting depth.
This commit is contained in:
adam jones 2025-09-08 14:32:59 -07:00 • committed by GitHub
commit f975e68cf2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 540 additions and 1973 deletions

View file

@ -102,8 +102,8 @@ func (s *registryServiceImpl) Publish(req apiv0.ServerJSON) (*apiv0.ServerJSON,
// Check this isn't a duplicate version
for _, server := range existingServerVersions {
existingVersion := server.VersionDetail.Version
if existingVersion == serverJSON.VersionDetail.Version {
existingVersion := server.Version
if existingVersion == serverJSON.Version {
return nil, database.ErrInvalidVersion
}
}
@ -117,8 +117,8 @@ func (s *registryServiceImpl) Publish(req apiv0.ServerJSON) (*apiv0.ServerJSON,
existingPublishedAt = existingLatest.Meta.Official.PublishedAt
}
isNewLatest = CompareVersions(
serverJSON.VersionDetail.Version,
existingLatest.VersionDetail.Version,
serverJSON.Version,
existingLatest.Version,
publishTime,
existingPublishedAt,
) > 0
@ -138,7 +138,6 @@ func (s *registryServiceImpl) Publish(req apiv0.ServerJSON) (*apiv0.ServerJSON,
PublishedAt: publishTime,
UpdatedAt: publishTime,
IsLatest: isNewLatest,
ReleaseDate: publishTime.Format(time.RFC3339),
}
// Create server in database

View file

@ -18,9 +18,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
"existing1": {
Name: "com.example/existing-server",
Description: "An existing server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Remotes: []model.Transport{
{Type: "streamable-http", URL: "https://api.example.com/mcp"},
{Type: "sse", URL: "https://webhook.example.com/sse"},
@ -29,9 +27,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
"existing2": {
Name: "com.microsoft/another-server",
Description: "Another existing server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Remotes: []model.Transport{
{Type: "streamable-http", URL: "https://api.microsoft.com/mcp"},
},
@ -59,9 +55,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
serverDetail: apiv0.ServerJSON{
Name: "com.example/new-server",
Description: "A new server with no remotes",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Remotes: []model.Transport{},
},
expectError: false,
@ -71,9 +65,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
serverDetail: apiv0.ServerJSON{
Name: "com.example/new-server",
Description: "A new server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Remotes: []model.Transport{
{Type: "streamable-http", URL: "https://new.example.com/mcp"},
{Type: "sse", URL: "https://unique.example.com/sse"},
@ -86,9 +78,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
serverDetail: apiv0.ServerJSON{
Name: "com.example/new-server",
Description: "A new server with duplicate URL",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Remotes: []model.Transport{
{Type: "streamable-http", URL: "https://api.example.com/mcp"}, // This URL already exists
},
@ -101,9 +91,7 @@ func TestValidateNoDuplicateRemoteURLs(t *testing.T) {
serverDetail: apiv0.ServerJSON{
Name: "com.example/existing-server", // Same name as existing
Description: "Updated existing server",
VersionDetail: model.VersionDetail{
Version: "1.1.0",
},
Version: "1.1.0",
Remotes: []model.Transport{
{Type: "streamable-http", URL: "https://api.example.com/mcp"}, // Same URL as before
},