Skip to content

Commit 2a79b99

Browse files
committed
Add AIConfiguration openapi schema
1 parent fc2160c commit 2a79b99

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,40 @@ 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: "googleai",
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+
example: %{
35+
provider: "googleai",
36+
model: "gemini-2.0-flash"
37+
},
38+
required: [:provider, :model]
39+
},
40+
struct?: false
41+
)
42+
end
43+
1044
defmodule UserTOTPEnrollmentPayload do
1145
@moduledoc false
1246

@@ -157,6 +191,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.User do
157191
nullable: false,
158192
example: true
159193
},
194+
ai_configuration: AIConfiguration,
160195
created_at: %OpenApiSpex.Schema{
161196
type: :string,
162197
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)