Skip to content

Commit 7aba9f2

Browse files
committed
Rename api/v1 -> api/v0 to match API paths
1 parent 099a2d7 commit 7aba9f2

File tree

19 files changed

+176
-177
lines changed

19 files changed

+176
-177
lines changed

internal/api/handlers/v0/edit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/modelcontextprotocol/registry/internal/database"
1414
"github.com/modelcontextprotocol/registry/internal/service"
1515
"github.com/modelcontextprotocol/registry/internal/validators"
16-
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
16+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
1717
"github.com/modelcontextprotocol/registry/pkg/model"
1818
)
1919

@@ -39,7 +39,7 @@ func RegisterEditEndpoints(api huma.API, registry service.RegistryService, cfg *
3939
Security: []map[string][]string{
4040
{"bearer": {}},
4141
},
42-
}, func(ctx context.Context, input *EditServerInput) (*Response[apiv1.ServerRecord], error) {
42+
}, func(ctx context.Context, input *EditServerInput) (*Response[apiv0.ServerRecord], error) {
4343
// Extract bearer token
4444
const bearerPrefix = "Bearer "
4545
authHeader := input.Authorization
@@ -74,7 +74,7 @@ func RegisterEditEndpoints(api huma.API, registry service.RegistryService, cfg *
7474
}
7575

7676
// Parse the validated request body
77-
var editRequest apiv1.PublishRequest
77+
var editRequest apiv0.PublishRequest
7878
if err := json.Unmarshal(input.RawBody, &editRequest); err != nil {
7979
return nil, huma.Error400BadRequest("Invalid JSON format", err)
8080
}
@@ -104,7 +104,7 @@ func RegisterEditEndpoints(api huma.API, registry service.RegistryService, cfg *
104104
return nil, huma.Error400BadRequest("Failed to edit server", err)
105105
}
106106

107-
return &Response[apiv1.ServerRecord]{
107+
return &Response[apiv0.ServerRecord]{
108108
Body: *updatedServer,
109109
}, nil
110110
})

internal/api/handlers/v0/edit_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/modelcontextprotocol/registry/internal/auth"
1818
"github.com/modelcontextprotocol/registry/internal/config"
1919
"github.com/modelcontextprotocol/registry/internal/database"
20-
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
20+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
2121
"github.com/modelcontextprotocol/registry/pkg/model"
2222
)
2323

@@ -45,7 +45,7 @@ func TestEditServerEndpoint(t *testing.T) {
4545
})
4646
return "Bearer " + token
4747
}(),
48-
requestBody: apiv1.PublishRequest{
48+
requestBody: apiv0.PublishRequest{
4949
Server: model.ServerJSON{
5050
Name: "io.github.domdomegg/test-server",
5151
Description: "Updated test server",
@@ -62,7 +62,7 @@ func TestEditServerEndpoint(t *testing.T) {
6262
},
6363
setupMocks: func(registry *MockRegistryService) {
6464
// Current server (not deleted)
65-
currentServer := &apiv1.ServerRecord{
65+
currentServer := &apiv0.ServerRecord{
6666
Server: model.ServerJSON{
6767
Name: "io.github.domdomegg/test-server",
6868
Description: "Original server",
@@ -71,22 +71,22 @@ func TestEditServerEndpoint(t *testing.T) {
7171
}
7272
registry.On("GetByID", "550e8400-e29b-41d4-a716-446655440001").Return(currentServer, nil)
7373

74-
expectedResponse := &apiv1.ServerRecord{
74+
expectedResponse := &apiv0.ServerRecord{
7575
Server: model.ServerJSON{
7676
Name: "io.github.domdomegg/test-server",
7777
Description: "Updated test server",
7878
Status: model.StatusDeprecated,
7979
},
8080
}
81-
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v1.PublishRequest")).Return(expectedResponse, nil)
81+
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v0.PublishRequest")).Return(expectedResponse, nil)
8282
},
8383
expectedStatus: http.StatusOK,
8484
},
8585
{
8686
name: "missing authorization header",
8787
serverID: "550e8400-e29b-41d4-a716-446655440001",
8888
authHeader: "",
89-
requestBody: apiv1.PublishRequest{},
89+
requestBody: apiv0.PublishRequest{},
9090
setupMocks: func(_ *MockRegistryService) {},
9191
expectedStatus: 422,
9292
expectedError: "required header parameter is missing",
@@ -95,7 +95,7 @@ func TestEditServerEndpoint(t *testing.T) {
9595
name: "invalid authorization header format",
9696
serverID: "550e8400-e29b-41d4-a716-446655440001",
9797
authHeader: "InvalidFormat token123",
98-
requestBody: apiv1.PublishRequest{},
98+
requestBody: apiv0.PublishRequest{},
9999
setupMocks: func(_ *MockRegistryService) {},
100100
expectedStatus: http.StatusUnauthorized,
101101
expectedError: "Unauthorized",
@@ -104,7 +104,7 @@ func TestEditServerEndpoint(t *testing.T) {
104104
name: "invalid token",
105105
serverID: "550e8400-e29b-41d4-a716-446655440001",
106106
authHeader: "Bearer invalid-token",
107-
requestBody: apiv1.PublishRequest{},
107+
requestBody: apiv0.PublishRequest{},
108108
setupMocks: func(_ *MockRegistryService) {},
109109
expectedStatus: http.StatusUnauthorized,
110110
expectedError: "Unauthorized",
@@ -123,15 +123,15 @@ func TestEditServerEndpoint(t *testing.T) {
123123
})
124124
return "Bearer " + token
125125
}(),
126-
requestBody: apiv1.PublishRequest{
126+
requestBody: apiv0.PublishRequest{
127127
Server: model.ServerJSON{
128128
Name: "io.github.domdomegg/test-server",
129129
Description: "Updated test server",
130130
},
131131
},
132132
setupMocks: func(registry *MockRegistryService) {
133133
// Need to mock GetByID since we check permissions against existing server name
134-
currentServer := &apiv1.ServerRecord{
134+
currentServer := &apiv0.ServerRecord{
135135
Server: model.ServerJSON{
136136
Name: "io.github.domdomegg/test-server",
137137
Description: "Original server",
@@ -157,7 +157,7 @@ func TestEditServerEndpoint(t *testing.T) {
157157
})
158158
return "Bearer " + token
159159
}(),
160-
requestBody: apiv1.PublishRequest{
160+
requestBody: apiv0.PublishRequest{
161161
Server: model.ServerJSON{
162162
Name: "io.github.other/test-server",
163163
Description: "Updated test server",
@@ -166,7 +166,7 @@ func TestEditServerEndpoint(t *testing.T) {
166166
setupMocks: func(registry *MockRegistryService) {
167167
// Need to mock GetByID since we check permissions against existing server name
168168
// This test case shows a different scenario: existing server is "other" but user only has perms for "domdomegg"
169-
currentServer := &apiv1.ServerRecord{
169+
currentServer := &apiv0.ServerRecord{
170170
Server: model.ServerJSON{
171171
Name: "io.github.other/test-server",
172172
Description: "Original server",
@@ -192,7 +192,7 @@ func TestEditServerEndpoint(t *testing.T) {
192192
})
193193
return "Bearer " + token
194194
}(),
195-
requestBody: apiv1.PublishRequest{
195+
requestBody: apiv0.PublishRequest{
196196
Server: model.ServerJSON{
197197
Name: "io.github.domdomegg/test-server",
198198
Description: "Updated test server",
@@ -218,23 +218,23 @@ func TestEditServerEndpoint(t *testing.T) {
218218
})
219219
return "Bearer " + token
220220
}(),
221-
requestBody: apiv1.PublishRequest{
221+
requestBody: apiv0.PublishRequest{
222222
Server: model.ServerJSON{
223223
Name: "io.github.domdomegg/test-server",
224224
Description: "Updated test server",
225225
},
226226
},
227227
setupMocks: func(registry *MockRegistryService) {
228228
// Current server (not deleted)
229-
currentServer := &apiv1.ServerRecord{
229+
currentServer := &apiv0.ServerRecord{
230230
Server: model.ServerJSON{
231231
Name: "io.github.domdomegg/test-server",
232232
Description: "Original server",
233233
Status: model.StatusActive,
234234
},
235235
}
236236
registry.On("GetByID", "550e8400-e29b-41d4-a716-446655440001").Return(currentServer, nil)
237-
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v1.PublishRequest")).Return(nil, errors.New("database error"))
237+
registry.On("EditServer", "550e8400-e29b-41d4-a716-446655440001", mock.AnythingOfType("v0.PublishRequest")).Return(nil, errors.New("database error"))
238238
},
239239
expectedStatus: http.StatusBadRequest,
240240
expectedError: "Bad Request",
@@ -272,7 +272,7 @@ func TestEditServerEndpoint(t *testing.T) {
272272
})
273273
return "Bearer " + token
274274
}(),
275-
requestBody: apiv1.PublishRequest{
275+
requestBody: apiv0.PublishRequest{
276276
Server: model.ServerJSON{
277277
Name: "io.github.domdomegg/test-server",
278278
Description: "Trying to undelete server",
@@ -281,7 +281,7 @@ func TestEditServerEndpoint(t *testing.T) {
281281
},
282282
setupMocks: func(registry *MockRegistryService) {
283283
// Current server is deleted
284-
currentServer := &apiv1.ServerRecord{
284+
currentServer := &apiv0.ServerRecord{
285285
Server: model.ServerJSON{
286286
Name: "io.github.domdomegg/test-server",
287287
Description: "Original server",

internal/api/handlers/v0/publish.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/modelcontextprotocol/registry/internal/config"
1212
"github.com/modelcontextprotocol/registry/internal/service"
1313
"github.com/modelcontextprotocol/registry/internal/validators"
14-
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
14+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
1515
)
1616

1717
// PublishServerInput represents the input for publishing a server
@@ -35,7 +35,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
3535
Security: []map[string][]string{
3636
{"bearer": {}},
3737
},
38-
}, func(ctx context.Context, input *PublishServerInput) (*Response[apiv1.ServerRecord], error) {
38+
}, func(ctx context.Context, input *PublishServerInput) (*Response[apiv0.ServerRecord], error) {
3939
// Extract bearer token
4040
const bearerPrefix = "Bearer "
4141
authHeader := input.Authorization
@@ -56,7 +56,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
5656
}
5757

5858
// Parse the validated request body
59-
var publishRequest apiv1.PublishRequest
59+
var publishRequest apiv0.PublishRequest
6060
if err := json.Unmarshal(input.RawBody, &publishRequest); err != nil {
6161
return nil, huma.Error400BadRequest("Invalid JSON format", err)
6262
}
@@ -82,7 +82,7 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
8282
}
8383

8484
// Return the published server in extension wrapper format
85-
return &Response[apiv1.ServerRecord]{
85+
return &Response[apiv0.ServerRecord]{
8686
Body: *publishedServer,
8787
}, nil
8888
})

internal/api/handlers/v0/publish_integration_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/modelcontextprotocol/registry/internal/auth"
1818
"github.com/modelcontextprotocol/registry/internal/config"
1919
"github.com/modelcontextprotocol/registry/internal/service"
20-
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
20+
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
2121
"github.com/modelcontextprotocol/registry/pkg/model"
2222
"github.com/stretchr/testify/assert"
2323
"github.com/stretchr/testify/require"
@@ -54,7 +54,7 @@ func TestPublishIntegration(t *testing.T) {
5454
v0.RegisterPublishEndpoint(api, registryService, testConfig)
5555

5656
t.Run("successful publish with GitHub auth", func(t *testing.T) {
57-
publishReq := apiv1.PublishRequest{
57+
publishReq := apiv0.PublishRequest{
5858
Server: model.ServerJSON{
5959
Name: "io.github.testuser/test-mcp-server",
6060
Description: "A test MCP server for integration testing",
@@ -92,7 +92,7 @@ func TestPublishIntegration(t *testing.T) {
9292

9393
assert.Equal(t, http.StatusOK, rr.Code)
9494

95-
var response apiv1.ServerRecord
95+
var response apiv0.ServerRecord
9696
err = json.Unmarshal(rr.Body.Bytes(), &response)
9797
require.NoError(t, err)
9898

@@ -101,7 +101,7 @@ func TestPublishIntegration(t *testing.T) {
101101
})
102102

103103
t.Run("successful publish with none auth (no prefix)", func(t *testing.T) {
104-
publishReq := apiv1.PublishRequest{
104+
publishReq := apiv0.PublishRequest{
105105
Server: model.ServerJSON{
106106
Name: "com.example/test-mcp-server-no-auth",
107107
Description: "A test MCP server without authentication",
@@ -138,15 +138,15 @@ func TestPublishIntegration(t *testing.T) {
138138

139139
assert.Equal(t, http.StatusOK, rr.Code)
140140

141-
var response apiv1.ServerRecord
141+
var response apiv0.ServerRecord
142142
err = json.Unmarshal(rr.Body.Bytes(), &response)
143143
require.NoError(t, err)
144144

145145
assert.Equal(t, publishReq.Server.Name, response.Server.Name)
146146
})
147147

148148
t.Run("publish fails with missing authorization header", func(t *testing.T) {
149-
publishReq := apiv1.PublishRequest{
149+
publishReq := apiv0.PublishRequest{
150150
Server: model.ServerJSON{
151151
Name: "test-server",
152152
},
@@ -167,7 +167,7 @@ func TestPublishIntegration(t *testing.T) {
167167
})
168168

169169
t.Run("publish fails with invalid token", func(t *testing.T) {
170-
publishReq := apiv1.PublishRequest{
170+
publishReq := apiv0.PublishRequest{
171171
Server: model.ServerJSON{
172172
Name: "test-server",
173173
},
@@ -188,7 +188,7 @@ func TestPublishIntegration(t *testing.T) {
188188
})
189189

190190
t.Run("publish fails when permission denied", func(t *testing.T) {
191-
publishReq := apiv1.PublishRequest{
191+
publishReq := apiv0.PublishRequest{
192192
Server: model.ServerJSON{
193193
Name: "io.github.other/test-server",
194194
Description: "A test server",

0 commit comments

Comments
 (0)