Skip to content

Commit 52fe66f

Browse files
committed
Add AIConfiguration openapi schema
1 parent b60ecb2 commit 52fe66f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/trento_web/openapi/v1/schema/user.ex

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ defmodule TrentoWeb.OpenApi.V1.Schema.User do
77
alias TrentoWeb.OpenApi.V1.Schema.Ability.AbilityCollection
88
alias TrentoWeb.OpenApi.V1.Schema.PersonalAccessToken.PersonalAccessTokenCollection
99

10+
defmodule AIConfiguration do
11+
@moduledoc false
12+
13+
OpenApiSpex.schema(
14+
%{
15+
title: "AIConfigurationV1",
16+
description: "AI configuration for a user.",
17+
type: :object,
18+
nullable: true,
19+
additionalProperties: false,
20+
properties: %{
21+
provider: %Schema{
22+
type: :string,
23+
description: "Chosen AI provider.",
24+
example: "Google Gemini",
25+
nullable: false
26+
},
27+
model: %Schema{
28+
type: :string,
29+
description: "Chosen AI model.",
30+
example: "gemini-2.0-flash",
31+
nullable: false
32+
}
33+
},
34+
required: [:provider, :model]
35+
},
36+
struct?: false
37+
)
38+
end
39+
1040
defmodule UserTOTPEnrollmentPayload do
1141
@moduledoc false
1242

@@ -157,6 +187,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.User do
157187
nullable: false,
158188
example: true
159189
},
190+
ai_configuration: AIConfiguration,
160191
created_at: %OpenApiSpex.Schema{
161192
type: :string,
162193
format: :"date-time",

test/trento_web/controllers/v1/profile_controller_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ defmodule TrentoWeb.V1.ProfileControllerTest do
5858
|> json_response(200)
5959
|> assert_schema("UserProfileV1", api_spec)
6060

61-
assert %{id: ^user_id} = resp
61+
assert %{
62+
id: ^user_id,
63+
personal_access_tokens: _,
64+
ai_configuration: _
65+
} = resp
6266
end
6367

6468
test "should update the profile with allowed fields", %{

0 commit comments

Comments
 (0)