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
26 changed files with 540 additions and 1973 deletions

View file

@ -309,9 +309,7 @@ func createServerJSON(
URL: repoURL,
Source: repoSource,
},
VersionDetail: model.VersionDetail{
Version: version,
},
Version: version,
Packages: []model.Package{pkg},
}
}

File diff suppressed because it is too large Load diff

View file

@ -19,9 +19,7 @@ Server authors SHOULD use [semantic versions](https://semver.org/) following the
```json
{
"version_detail": {
"version": "1.2.3"
}
"version": "1.2.3"
}
```
@ -30,9 +28,7 @@ Server authors SHOULD use versions aligned with their underlying packages to red
```json
{
"version_detail": {
"version": "1.2.3"
},
"version": "1.2.3",
"packages": [{
"registry_name": "npm",
"name": "@myorg/my-server",
@ -46,9 +42,7 @@ If server authors expect to have multiple registry versions for the same package
```json
{
"version_detail": {
"version": "1.2.3-1"
},
"version": "1.2.3-1",
"packages": [{
"registry_name": "npm",
"name": "@myorg/my-server",
@ -111,9 +105,7 @@ Registry clients SHOULD:
### Alignment Examples
```json
{
"version_detail": {
"version": "1.2.3-1"
},
"version": "1.2.3-1",
"packages": [{
"registry_name": "npm",
"name": "@myorg/k8s-server",
@ -136,9 +128,7 @@ Existing servers with non-semantic versions will continue to work without change
**Package and server versions aligned**:
```json
{
"version_detail": {
"version": "1.2.3"
},
"version": "1.2.3",
"packages": [
{
"registry_type": "npm",
@ -153,9 +143,7 @@ Existing servers with non-semantic versions will continue to work without change
**Server metadata changes without package updates**:
```json
{
"version_detail": {
"version": "1.2.3-1"
},
"version": "1.2.3-1",
"packages": [
{
"registry_type": "npm",
@ -172,9 +160,7 @@ Note: `1.2.3-1` is considered lower than `1.2.3` in semver ordering. Publish pre
**Remote servers without package dependencies**:
```json
{
"version_detail": {
"version": "2.1.0"
},
"version": "2.1.0",
"remotes": [
{
"transport_type": "sse",
@ -193,9 +179,7 @@ Version strategy options:
**Different package versions**:
```json
{
"version_detail": {
"version": "1.3.0"
},
"version": "1.3.0",
"packages": [
{
"registry_type": "npm",

View file

@ -34,9 +34,7 @@ You can also add custom metadata to servers using the `_meta` field. For example
"name": "io.github.yourname/weather-server",
"description": "MCP server for weather data access",
"status": "active",
"version_detail": {
"version": "1.0.0"
},
"version": "1.0.0",
"packages": [
{
"registry_type": "npm",

View file

@ -254,7 +254,7 @@ Keep your package version and server.json version in sync:
- name: Update server.json version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
jq --arg version "$VERSION" '.version_detail.version = $version' server.json > tmp.json
jq --arg version "$VERSION" '.version = $version' server.json > tmp.json
mv tmp.json server.json
```

View file

@ -47,9 +47,7 @@ This creates a `server.json` with auto-detected values. You'll see something lik
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.github.yourname/your-server",
"description": "A description of your MCP server",
"version_detail": {
"version": "1.0.0"
},
"version": "1.0.0",
"packages": [
{
"registry_type": "npm",

View file

@ -38,10 +38,7 @@ curl https://registry.example.com/v0/servers?limit=10
"name": "io.modelcontextprotocol/filesystem",
"description": "Filesystem operations server",
"status": "active",
"version_detail": {
"version": "1.0.2",
"is_latest": true
}
"version": "1.0.2"
}
],
"metadata": {

View file

@ -97,8 +97,7 @@ paths:
repository:
url: "https://github.com/modelcontextprotocol/servers"
source: "github"
version_detail:
version: "1.0.2"
version: "1.0.2"
packages:
- registry_type: "npm"
registry_base_url: "https://registry.npmjs.org"
@ -120,8 +119,7 @@ paths:
repository:
url: "https://github.com/example/mcp-demo"
source: "github"
version_detail:
version: "1.0.0"
version: "1.0.0"
packages:
- registry_type: "npm"
registry_base_url: "https://registry.npmjs.org"
@ -213,7 +211,7 @@ components:
required:
- name
- description
- version_detail
- version
properties:
name:
type: string
@ -231,8 +229,10 @@ components:
example: "active"
repository:
$ref: '#/components/schemas/Repository'
version_detail:
$ref: '#/components/schemas/VersionDetail'
version:
type: string
example: "1.0.2"
description: "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification."
created_at:
type: string
format: date-time
@ -240,26 +240,6 @@ components:
type: string
format: date-time
VersionDetail:
type: object
required:
- version
- release_date
- is_latest
properties:
version:
type: string
example: "1.0.2"
description: Equivalent of Implementation.version in MCP specification.
release_date:
type: string
format: date-time
example: "2023-06-15T10:30:00Z"
description: Datetime that the MCP server version was published to the registry.
is_latest:
type: boolean
example: true
description: Whether the MCP server version is the latest version available in the registry.
ServerList:
type: object
@ -535,10 +515,5 @@ components:
type: boolean
description: Whether this is the latest version of the server
example: true
release_date:
type: string
format: date-time
description: Release date of the server version
example: "2023-12-01T10:30:00Z"
additionalProperties: false
additionalProperties: true

View file

@ -45,7 +45,7 @@ mcp-publisher init [options]
{
"name": "io.github.username/server-name",
"description": "TODO: Add server description",
"version_detail": { "version": "1.0.0" },
"version": "1.0.0",
"packages": [
{
"registry_type": "npm",

View file

@ -30,9 +30,7 @@ The official registry has some more restrictions on top of this. See the [offici
"url": "https://github.com/modelcontextprotocol/servers",
"source": "github"
},
"version_detail": {
"version": "1.0.2"
},
"version": "1.0.2",
"packages": [
{
"registry_type": "npm",
@ -79,9 +77,7 @@ For MCP servers located within a subdirectory of a larger repository (monorepo s
"source": "github",
"subfolder": "src/everything"
},
"version_detail": {
"version": "0.6.2"
},
"version": "0.6.2",
"packages": [
{
"registry_type": "npm",
@ -113,9 +109,7 @@ Suppose your MCP server application requires a `mcp start` CLI arguments to star
{
"name": "io.github.joelverhagen/knapcode-samplemcpserver",
"description": "Sample NuGet MCP server for a random number and random weather",
"version_detail": {
"version": "0.4.0-beta"
},
"version": "0.4.0-beta",
"packages": [
{
"registry_type": "nuget",
@ -165,9 +159,7 @@ This will essentially instruct the MCP client to execute `dnx Knapcode.SampleMcp
"source": "github",
"id": "b94b5f7e-c7c6-d760-2c78-a5e9b8a5b8c9"
},
"version_detail": {
"version": "1.0.2"
},
"version": "1.0.2",
"packages": [
{
"registry_type": "npm",
@ -267,9 +259,7 @@ This will essentially instruct the MCP client to execute `dnx Knapcode.SampleMcp
"source": "github",
"id": "xyz789ab-cdef-0123-4567-890ghijklmno"
},
"version_detail": {
"version": "2.0.0"
},
"version": "2.0.0",
"remotes": [
{
"type": "sse",
@ -302,9 +292,7 @@ This will essentially instruct the MCP client to execute `dnx Knapcode.SampleMcp
"source": "github",
"id": "def456gh-ijkl-7890-mnop-qrstuvwxyz12"
},
"version_detail": {
"version": "0.5.0"
},
"version": "0.5.0",
"packages": [
{
"registry_type": "pypi",
@ -358,9 +346,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
"source": "github",
"id": "example-nuget-id-0000-1111-222222222222"
},
"version_detail": {
"version": "0.5.0"
},
"version": "0.5.0",
"packages": [
{
"registry_type": "nuget",
@ -408,9 +394,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
"source": "github",
"id": "ghi789jk-lmno-1234-pqrs-tuvwxyz56789"
},
"version_detail": {
"version": "3.1.0"
},
"version": "3.1.0",
"packages": [
{
"registry_type": "oci",
@ -521,9 +505,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
"source": "github",
"id": "klm012no-pqrs-3456-tuvw-xyz789abcdef"
},
"version_detail": {
"version": "1.5.0"
},
"version": "1.5.0",
"packages": [
{
"registry_type": "npm",
@ -606,9 +588,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
"url": "https://github.com/modelcontextprotocol/text-editor-mcpb",
"source": "github"
},
"version_detail": {
"version": "1.0.2"
},
"version": "1.0.2",
"packages": [
{
"registry_type": "mcpb",
@ -649,9 +629,7 @@ Some CLI tools bundle an MCP server, without a standalone MCP package or a publi
"name": "io.snyk/cli-mcp",
"description": "MCP server provided by the Snyk CLI",
"status": "active",
"version_detail": {
"version": "1.1298.0"
},
"version": "1.1298.0",
"packages": [
{
"registry_type": "npm",
@ -688,9 +666,7 @@ Some CLI tools bundle an MCP server, without a standalone MCP package or a publi
"source": "github",
"id": "legacy-abc123-def456-789012-345678-901234567890"
},
"version_detail": {
"version": "0.9.5"
},
"version": "0.9.5",
"packages": [
{
"registry_type": "npm",

View file

@ -35,27 +35,12 @@
}
}
},
"VersionDetail": {
"type": "object",
"description": "Version information for this server. Defined as an object to allow for downstream extensibility (e.g. release_date)",
"required": [
"version"
],
"properties": {
"version": {
"type": "string",
"maxLength": 255,
"example": "1.0.2",
"description": "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification. Non-semantic versions are allowed but may not sort predictably."
}
}
},
"Server": {
"type": "object",
"required": [
"name",
"description",
"version_detail"
"version"
],
"properties": {
"name": {
@ -83,8 +68,11 @@
"$ref": "#/$defs/Repository",
"description": "Optional repository metadata for the MCP server source code. Recommended for transparency and security inspection."
},
"version_detail": {
"$ref": "#/$defs/VersionDetail"
"version": {
"type": "string",
"maxLength": 255,
"example": "1.0.2",
"description": "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification. Non-semantic versions are allowed but may not sort predictably."
}
}
},

View file

@ -34,9 +34,7 @@ func TestEditServerEndpoint(t *testing.T) {
Source: "github",
ID: "domdomegg/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
published, err := registryService.Publish(testServer)
assert.NoError(t, err)
@ -56,9 +54,7 @@ func TestEditServerEndpoint(t *testing.T) {
Source: "github",
ID: "other/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
otherPublished, err := registryService.Publish(otherServer)
assert.NoError(t, err)
@ -78,9 +74,7 @@ func TestEditServerEndpoint(t *testing.T) {
Source: "github",
ID: "domdomegg/deleted-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
deletedPublished, err := registryService.Publish(deletedServer)
assert.NoError(t, err)
@ -120,9 +114,7 @@ func TestEditServerEndpoint(t *testing.T) {
Source: "github",
ID: "domdomegg/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.1",
},
Version: "1.0.1",
},
serverID: testServerID,
expectedStatus: http.StatusOK,
@ -141,7 +133,7 @@ func TestEditServerEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.domdomegg/test-server",
Description: "Test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
serverID: testServerID,
expectedStatus: http.StatusUnauthorized,
@ -153,7 +145,7 @@ func TestEditServerEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.domdomegg/test-server",
Description: "Test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
serverID: testServerID,
expectedStatus: http.StatusUnauthorized,
@ -175,7 +167,7 @@ func TestEditServerEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.domdomegg/test-server",
Description: "Updated test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
serverID: testServerID,
expectedStatus: http.StatusForbidden,
@ -197,7 +189,7 @@ func TestEditServerEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.other/test-server",
Description: "Updated test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
serverID: otherServerID,
expectedStatus: http.StatusForbidden,
@ -219,7 +211,7 @@ func TestEditServerEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.domdomegg/nonexistent-server",
Description: "Updated test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
serverID: "550e8400-e29b-41d4-a716-446655440999", // Non-existent ID
expectedStatus: http.StatusNotFound,
@ -241,7 +233,7 @@ func TestEditServerEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "invalid-name-format", // Missing namespace/name format
Description: "Test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
serverID: testServerID,
expectedStatus: http.StatusBadRequest,
@ -269,9 +261,7 @@ func TestEditServerEndpoint(t *testing.T) {
Source: "github",
ID: "domdomegg/deleted-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.1",
},
Version: "1.0.1",
},
serverID: deletedServerID,
expectedStatus: http.StatusBadRequest,

View file

@ -64,9 +64,7 @@ func TestPublishIntegration(t *testing.T) {
Source: "github",
ID: "testuser/test-mcp-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
// Generate valid JWT token
@ -97,7 +95,7 @@ func TestPublishIntegration(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, publishReq.Name, response.Name)
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
assert.Equal(t, publishReq.Version, response.Version)
})
t.Run("successful publish with none auth (no prefix)", func(t *testing.T) {
@ -109,9 +107,7 @@ func TestPublishIntegration(t *testing.T) {
Source: "github",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
// Generate valid JWT token with wildcard permission
@ -166,7 +162,7 @@ func TestPublishIntegration(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "io.github.domdomegg/test-server",
Description: "Test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
body, err := json.Marshal(publishReq)
@ -187,9 +183,7 @@ func TestPublishIntegration(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "io.github.other/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Repository: model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
@ -225,9 +219,7 @@ func TestPublishIntegration(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "io.github.domdomegg/airtable-mcp-server",
Description: "A test server with MCPB package",
VersionDetail: model.VersionDetail{
Version: "1.7.2",
},
Version: "1.7.2",
Status: model.StatusActive,
Packages: []model.Package{
{
@ -269,7 +261,7 @@ func TestPublishIntegration(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, publishReq.Name, response.Name)
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
assert.Equal(t, publishReq.Version, response.Version)
assert.Len(t, response.Packages, 1)
assert.Equal(t, model.RegistryTypeMCPB, response.Packages[0].RegistryType)
})

View file

@ -47,9 +47,7 @@ func TestPublishRegistryValidation(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "com.example/test-server-with-npm",
Description: "A test server with invalid npm package reference",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Packages: []model.Package{
{
RegistryType: model.RegistryTypeNPM,
@ -90,9 +88,7 @@ func TestPublishRegistryValidation(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "com.example/test-server-mcpb-validation",
Description: "A test server with MCPB package and registry validation enabled",
VersionDetail: model.VersionDetail{
Version: "0.0.36",
},
Version: "0.0.36",
Packages: []model.Package{
{
RegistryType: model.RegistryTypeMCPB,
@ -133,7 +129,7 @@ func TestPublishRegistryValidation(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, publishReq.Name, response.Name)
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
assert.Equal(t, publishReq.Version, response.Version)
assert.Len(t, response.Packages, 1)
assert.Equal(t, model.RegistryTypeMCPB, response.Packages[0].RegistryType)
})
@ -142,9 +138,7 @@ func TestPublishRegistryValidation(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "com.example/test-server-multiple-packages",
Description: "A test server with multiple packages where second fails",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Packages: []model.Package{
{
RegistryType: model.RegistryTypeMCPB,
@ -195,9 +189,7 @@ func TestPublishRegistryValidation(t *testing.T) {
publishReq := apiv0.ServerJSON{
Name: "com.example/test-server-first-package-fails",
Description: "A test server where first package fails",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Packages: []model.Package{
{
RegistryType: model.RegistryTypeNPM,

View file

@ -63,9 +63,7 @@ func TestPublishEndpoint(t *testing.T) {
Source: "github",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
},
tokenClaims: &auth.JWTClaims{
AuthMethod: auth.MethodGitHubAT,
@ -89,9 +87,7 @@ func TestPublishEndpoint(t *testing.T) {
Source: "github",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
},
tokenClaims: &auth.JWTClaims{
AuthMethod: auth.MethodNone,
@ -119,7 +115,7 @@ func TestPublishEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.domdomegg/test-server",
Description: "Test server",
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
},
authHeader: "InvalidFormat",
setupRegistryService: func(_ service.RegistryService) {
@ -133,9 +129,7 @@ func TestPublishEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
},
authHeader: "Bearer invalidToken",
setupRegistryService: func(_ service.RegistryService) {
@ -149,9 +143,7 @@ func TestPublishEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "io.github.other/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Repository: model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
@ -175,9 +167,7 @@ func TestPublishEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "example/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Repository: model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
@ -195,9 +185,7 @@ func TestPublishEndpoint(t *testing.T) {
existingServer := apiv0.ServerJSON{
Name: "example/test-server",
Description: "Existing test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Repository: model.Repository{
URL: "https://github.com/example/test-server-existing",
Source: "github",
@ -214,9 +202,7 @@ func TestPublishEndpoint(t *testing.T) {
requestBody: apiv0.ServerJSON{
Name: "com.example/test-server-mcpb",
Description: "A test server with MCPB package",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Packages: []model.Package{
{
RegistryType: model.RegistryTypeMCPB,

View file

@ -41,9 +41,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/test-server-1",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
server2 := apiv0.ServerJSON{
Name: "com.example/test-server-2",
@ -53,9 +51,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/test-server-2",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
},
Version: "2.0.0",
}
_, _ = registry.Publish(server1)
_, _ = registry.Publish(server2)
@ -75,9 +71,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/test-server-3",
},
VersionDetail: model.VersionDetail{
Version: "1.5.0",
},
Version: "1.5.0",
}
_, _ = registry.Publish(server)
},
@ -139,7 +133,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/test-matching",
},
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
server2 := apiv0.ServerJSON{
Name: "com.example/other-server",
@ -149,7 +143,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/other",
},
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
_, _ = registry.Publish(server1)
_, _ = registry.Publish(server2)
@ -169,7 +163,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/recent",
},
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
_, _ = registry.Publish(server)
},
@ -188,7 +182,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/versioned",
},
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
server2 := apiv0.ServerJSON{
Name: "com.example/versioned-server",
@ -198,7 +192,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/versioned",
},
VersionDetail: model.VersionDetail{Version: "2.0.0"},
Version: "2.0.0",
}
_, _ = registry.Publish(server1)
_, _ = registry.Publish(server2) // This will be marked as latest
@ -218,7 +212,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/combined",
},
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
server2 := apiv0.ServerJSON{
Name: "com.example/other-server",
@ -228,7 +222,7 @@ func TestServersListEndpoint(t *testing.T) {
Source: "github",
ID: "example/nomatch",
},
VersionDetail: model.VersionDetail{Version: "1.0.0"},
Version: "1.0.0",
}
_, _ = registry.Publish(server1)
_, _ = registry.Publish(server2)
@ -342,9 +336,7 @@ func TestServersDetailEndpoint(t *testing.T) {
testServer, err := registryService.Publish(apiv0.ServerJSON{
Name: "com.example/test-server",
Description: "A test server",
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
})
assert.NoError(t, err)
@ -430,9 +422,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
Source: "github",
ID: "example/integration-test",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
}
published, err := registryService.Publish(testServer)
@ -488,7 +478,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
assert.Equal(t, servers[0].Name, listResp.Servers[0].Name)
assert.Equal(t, servers[0].Description, listResp.Servers[0].Description)
assert.Equal(t, servers[0].Repository, listResp.Servers[0].Repository)
assert.Equal(t, servers[0].VersionDetail, listResp.Servers[0].VersionDetail)
assert.Equal(t, servers[0].Version, listResp.Servers[0].Version)
}
})
@ -522,7 +512,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
assert.Equal(t, serverDetail.Name, serverDetailResp.Name)
assert.Equal(t, serverDetail.Description, serverDetailResp.Description)
assert.Equal(t, serverDetail.Repository, serverDetailResp.Repository)
assert.Equal(t, serverDetail.VersionDetail, serverDetailResp.VersionDetail)
assert.Equal(t, serverDetail.Version, serverDetailResp.Version)
})
// Verify mock expectations

View file

@ -30,9 +30,7 @@ func TestPrometheusHandler(t *testing.T) {
Source: "github",
ID: "example/test-server",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
},
Version: "2.0.0",
})
assert.NoError(t, err)

View file

@ -213,7 +213,7 @@ func (db *MemoryDB) matchesFilter(entry *apiv0.ServerJSON, filter *ServerFilter)
// Check exact version filter
if filter.Version != nil {
if entry.VersionDetail.Version != *filter.Version {
if entry.Version != *filter.Version {
return false
}
}

View file

@ -29,9 +29,7 @@ func TestImportService_LocalFile(t *testing.T) {
Source: "github",
ID: "123",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Meta: &apiv0.ServerMeta{
Official: &apiv0.RegistryExtensions{
ID: "test-id-1",
@ -75,9 +73,7 @@ func TestImportService_HTTPFile(t *testing.T) {
Source: "github",
ID: "123",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
},
Version: "2.0.0",
Meta: &apiv0.ServerMeta{
Official: &apiv0.RegistryExtensions{
ID: "test-id-2",
@ -120,9 +116,7 @@ func TestImportService_RegistryAPI(t *testing.T) {
Source: "github",
ID: "123",
},
VersionDetail: model.VersionDetail{
Version: "1.0.0",
},
Version: "1.0.0",
Meta: &apiv0.ServerMeta{
Official: &apiv0.RegistryExtensions{
ID: "api-test-id-1",
@ -140,9 +134,7 @@ func TestImportService_RegistryAPI(t *testing.T) {
Source: "github",
ID: "456",
},
VersionDetail: model.VersionDetail{
Version: "2.0.0",
},
Version: "2.0.0",
Meta: &apiv0.ServerMeta{
Official: &apiv0.RegistryExtensions{
ID: "api-test-id-2",

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

Some files were not shown because too many files have changed in this diff Show more