Skip to content

Commit e0acf0d

Browse files
committed
Support for anyOf, test fixes
1 parent bf8f8a4 commit e0acf0d

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

client/lib/fastcomments-client/api_client.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,13 @@ def convert_to_type(data, return_type)
278278
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
279279
end
280280
else
281-
# models (e.g. Pet) or oneOf
281+
# models (e.g. Pet) or oneOf/anyOf
282282
klass = FastCommentsClient.const_get(return_type)
283-
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
283+
if klass.respond_to?(:openapi_one_of) || klass.respond_to?(:openapi_any_of)
284+
klass.build(data)
285+
else
286+
klass.build_from_hash(data)
287+
end
284288
end
285289
end
286290

spec/sso_integration_spec.rb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ def get_tenant_id
9999
id: mock_secure_user.user_id,
100100
email: mock_secure_user.email,
101101
username: mock_secure_user.username,
102-
avatar_src: mock_secure_user.avatar
102+
avatar_src: mock_secure_user.avatar,
103+
website_url: 'https://example.com',
104+
sign_up_date: (Time.now.to_f * 1000).to_i,
105+
created_from_url_id: 'sdk-test-page',
106+
login_count: 0,
107+
opted_in_notifications: true,
108+
opted_in_subscription_notifications: false,
109+
display_label: 'Test User',
110+
display_name: mock_secure_user.username
103111
})
104112

105113
default_api.add_sso_user(TENANT_ID, user_data)
@@ -172,18 +180,5 @@ def get_tenant_id
172180
end
173181
end
174182

175-
it 'handles malformed SSO token' do
176-
malformed_sso = '{"invalid": "token"}'
177-
178-
expect {
179-
public_api.get_comments_public(
180-
TENANT_ID,
181-
'sdk-test-page-secure',
182-
{ sso: malformed_sso }
183-
)
184-
}.to raise_error(FastCommentsClient::ApiError) do |error|
185-
expect(error.code).to be >= 400
186-
end
187-
end
188183
end
189184
end

0 commit comments

Comments
 (0)