Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb0f664

Browse files
committed
fix(coderd): add UUID formats to chat model routes
1 parent 860c858 commit bb0f664

4 files changed

Lines changed: 41 additions & 3 deletions

File tree

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderdtest/swagger_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package coderdtest_test
22

33
import (
4+
"encoding/json"
45
"go/ast"
56
"go/parser"
67
"go/token"
@@ -10,6 +11,7 @@ import (
1011
"github.com/stretchr/testify/assert"
1112
"github.com/stretchr/testify/require"
1213

14+
"github.com/coder/coder/v2/coderd/apidoc"
1315
"github.com/coder/coder/v2/coderd/coderdtest"
1416
)
1517

@@ -30,6 +32,36 @@ func TestEndpointsDocumented(t *testing.T) {
3032
coderdtest.VerifySwaggerDefinitions(t, api.APIHandler, swaggerComments, coderdtest.WithSwaggerRoutePrefix("/api/v2"))
3133
}
3234

35+
func TestChatModelPathParametersFormatted(t *testing.T) {
36+
t.Parallel()
37+
38+
var swagger struct {
39+
Paths map[string]map[string]struct {
40+
Parameters []struct {
41+
Name string `json:"name"`
42+
In string `json:"in"`
43+
Format string `json:"format"`
44+
} `json:"parameters"`
45+
} `json:"paths"`
46+
}
47+
require.NoError(t, json.Unmarshal([]byte(apidoc.SwaggerInfo.ReadDoc()), &swagger))
48+
49+
operations := swagger.Paths["/api/v2/organizations/{organization}/chats/models/{model}"]
50+
for _, method := range []string{"get", "patch", "delete"} {
51+
t.Run(method, func(t *testing.T) {
52+
t.Parallel()
53+
54+
for _, parameter := range operations[method].Parameters {
55+
if parameter.Name == "model" && parameter.In == "path" {
56+
require.Equal(t, "uuid", parameter.Format)
57+
return
58+
}
59+
}
60+
require.Fail(t, "model path parameter not found")
61+
})
62+
}
63+
}
64+
3365
func TestSDKFieldsFormatted(t *testing.T) {
3466
t.Parallel()
3567

coderd/exp_chats.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7117,7 +7117,7 @@ func chatModelConfigRBACObject(config database.ChatModelConfig) rbac.Object {
71177117
// @Tags Chats
71187118
// @Produce json
71197119
// @Param organization path string true "Organization name or ID"
7120-
// @Param model path string true "Model ID"
7120+
// @Param model path string true "Model ID" format(uuid)
71217121
// @Success 200 {object} codersdk.ChatModel
71227122
// @Router /api/v2/organizations/{organization}/chats/models/{model} [get]
71237123
// @x-apidocgen {"skip": true}
@@ -7438,7 +7438,7 @@ func (api *API) createChatModelConfig(rw http.ResponseWriter, r *http.Request) {
74387438
// @Accept json
74397439
// @Produce json
74407440
// @Param organization path string true "Organization name or ID"
7441-
// @Param model path string true "Model ID"
7441+
// @Param model path string true "Model ID" format(uuid)
74427442
// @Param request body codersdk.UpdateChatModelRequest true "Model updates"
74437443
// @Success 200 {object} codersdk.ChatModel
74447444
// @Router /api/v2/organizations/{organization}/chats/models/{model} [patch]
@@ -7692,7 +7692,7 @@ func (api *API) updateChatModelConfig(rw http.ResponseWriter, r *http.Request) {
76927692
// @Security CoderSessionToken
76937693
// @Tags Chats
76947694
// @Param organization path string true "Organization name or ID"
7695-
// @Param model path string true "Model ID"
7695+
// @Param model path string true "Model ID" format(uuid)
76967696
// @Success 204
76977697
// @Router /api/v2/organizations/{organization}/chats/models/{model} [delete]
76987698
// @x-apidocgen {"skip": true}

0 commit comments

Comments
 (0)