Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* [#504](https://github.com/workos/workos-ruby/pull/504) fix(generated): regenerate from spec

**Fixes**
* **[organization_membership](https://workos.com/docs/reference/authkit/organization-membership)**:
* Added `roles` to organization membership models
2 changes: 1 addition & 1 deletion .last-synced-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b6a68da8bd60c1478e0a86ca97c75448677e8871
1a2f47b20f63f2c8f0eb56bbd2adb3b5947d693a
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class OrganizationMembership < WorkOS::Types::BaseModel
created_at: :created_at,
updated_at: :updated_at,
role: :role,
roles: :roles,
user: :user
}.freeze

Expand All @@ -31,6 +32,7 @@ class OrganizationMembership < WorkOS::Types::BaseModel
:created_at,
:updated_at,
:role,
:roles,
:user

def initialize(json)
Expand All @@ -46,6 +48,7 @@ def initialize(json)
@created_at = hash[:created_at]
@updated_at = hash[:updated_at]
@role = hash[:role] ? WorkOS::SlimRole.new(hash[:role]) : nil
@roles = (hash[:roles] || []).map { |item| item ? WorkOS::SlimRole.new(item) : nil }
@user = hash[:user] ? WorkOS::User.new(hash[:user]) : nil
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class UserOrganizationMembership < WorkOS::Types::BaseModel
created_at: :created_at,
updated_at: :updated_at,
role: :role,
roles: :roles,
user: :user
}.freeze

Expand All @@ -31,6 +32,7 @@ class UserOrganizationMembership < WorkOS::Types::BaseModel
:created_at,
:updated_at,
:role,
:roles,
:user

def initialize(json)
Expand All @@ -46,6 +48,7 @@ def initialize(json)
@created_at = hash[:created_at]
@updated_at = hash[:updated_at]
@role = hash[:role] ? WorkOS::SlimRole.new(hash[:role]) : nil
@roles = (hash[:roles] || []).map { |item| item ? WorkOS::SlimRole.new(item) : nil }
@user = hash[:user] ? WorkOS::User.new(hash[:user]) : nil
end
end
Expand Down
6 changes: 6 additions & 0 deletions rbi/workos/organization_membership.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ module WorkOS
sig { params(value: WorkOS::SlimRole).returns(WorkOS::SlimRole) }
def role=(value); end

sig { returns(T::Array[WorkOS::SlimRole]) }
def roles; end

sig { params(value: T::Array[WorkOS::SlimRole]).returns(T::Array[WorkOS::SlimRole]) }
def roles=(value); end
Comment on lines +78 to +82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nullable Roles Type Mismatch

The Ruby model keeps nil entries in roles, but this RBI tells Sorbet callers every element is a WorkOS::SlimRole. When the API returns roles: [null], typed callers can safely compile code like membership.roles.each { |role| role.slug } and then crash at runtime.

Suggested change
sig { returns(T::Array[WorkOS::SlimRole]) }
def roles; end
sig { params(value: T::Array[WorkOS::SlimRole]).returns(T::Array[WorkOS::SlimRole]) }
def roles=(value); end
sig { returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
def roles; end
sig { params(value: T::Array[T.nilable(WorkOS::SlimRole)]).returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
def roles=(value); end
Prompt To Fix With AI
This is a comment left during a code review.
Path: rbi/workos/organization_membership.rbi
Line: 78-82

Comment:
**Nullable Roles Type Mismatch**

The Ruby model keeps `nil` entries in `roles`, but this RBI tells Sorbet callers every element is a `WorkOS::SlimRole`. When the API returns `roles: [null]`, typed callers can safely compile code like `membership.roles.each { |role| role.slug }` and then crash at runtime.

```suggestion
    sig { returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
    def roles; end

    sig { params(value: T::Array[T.nilable(WorkOS::SlimRole)]).returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
    def roles=(value); end
```

How can I resolve this? If you propose a fix, please make it concise.


sig { returns(WorkOS::User) }
def user; end

Expand Down
6 changes: 6 additions & 0 deletions rbi/workos/user_organization_membership.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ module WorkOS
sig { params(value: WorkOS::SlimRole).returns(WorkOS::SlimRole) }
def role=(value); end

sig { returns(T::Array[WorkOS::SlimRole]) }
def roles; end

sig { params(value: T::Array[WorkOS::SlimRole]).returns(T::Array[WorkOS::SlimRole]) }
def roles=(value); end
Comment on lines +78 to +82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nullable Roles Type Mismatch

The Ruby model keeps nil entries in roles, but this RBI tells Sorbet callers every element is a WorkOS::SlimRole. When the API returns roles: [null], typed callers can safely compile code like membership.roles.each { |role| role.slug } and then crash at runtime.

Suggested change
sig { returns(T::Array[WorkOS::SlimRole]) }
def roles; end
sig { params(value: T::Array[WorkOS::SlimRole]).returns(T::Array[WorkOS::SlimRole]) }
def roles=(value); end
sig { returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
def roles; end
sig { params(value: T::Array[T.nilable(WorkOS::SlimRole)]).returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
def roles=(value); end
Prompt To Fix With AI
This is a comment left during a code review.
Path: rbi/workos/user_organization_membership.rbi
Line: 78-82

Comment:
**Nullable Roles Type Mismatch**

The Ruby model keeps `nil` entries in `roles`, but this RBI tells Sorbet callers every element is a `WorkOS::SlimRole`. When the API returns `roles: [null]`, typed callers can safely compile code like `membership.roles.each { |role| role.slug }` and then crash at runtime.

```suggestion
    sig { returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
    def roles; end

    sig { params(value: T::Array[T.nilable(WorkOS::SlimRole)]).returns(T::Array[T.nilable(WorkOS::SlimRole)]) }
    def roles=(value); end
```

How can I resolve this? If you propose a fix, please make it concise.


sig { returns(WorkOS::User) }
def user; end

Expand Down
189 changes: 26 additions & 163 deletions test/workos/test_model_round_trip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,39 +1099,6 @@ def test_object_metadata_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Public Models Lose Coverage

This deletion removes round-trip coverage for still-existing public models such as WorkOS::ObjectSummary, WorkOS::ObjectVersion, and WorkOS::EventSchema. A later regeneration can now drop or mis-key fields like etag, size, data, or context while this model round-trip suite still passes.

Prompt To Fix With AI
This is a comment left during a code review.
Path: test/workos/test_model_round_trip.rb
Line: 1099

Comment:
**Public Models Lose Coverage**

This deletion removes round-trip coverage for still-existing public models such as `WorkOS::ObjectSummary`, `WorkOS::ObjectVersion`, and `WorkOS::EventSchema`. A later regeneration can now drop or mis-key fields like `etag`, `size`, `data`, or `context` while this model round-trip suite still passes.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

end

def test_object_summary_round_trip
fixture = {
"id" => "stub",
"name" => "stub",
"updated_at" => nil
}
model = WorkOS::ObjectSummary.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
assert_equal fixture["name"], json[:name]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_object_version_round_trip
fixture = {
"created_at" => "stub",
"current_version" => true,
"etag" => "stub",
"id" => "stub",
"size" => 1
}
model = WorkOS::ObjectVersion.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["created_at"], json[:created_at]
assert_equal fixture["current_version"], json[:current_version]
assert_equal fixture["etag"], json[:etag]
assert_equal fixture["id"], json[:id]
assert_equal fixture["size"], json[:size]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_object_without_value_round_trip
fixture = {
"id" => "stub",
Expand Down Expand Up @@ -1926,24 +1893,6 @@ def test_waitlist_user_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_event_schema_round_trip
fixture = {
"object" => "event",
"id" => "stub",
"event" => "stub",
"data" => {},
"created_at" => "stub",
"context" => {}
}
model = WorkOS::EventSchema.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
assert_equal fixture["event"], json[:event]
assert_equal fixture["created_at"], json[:created_at]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_action_authentication_denied_round_trip
fixture = {
"object" => "event",
Expand Down Expand Up @@ -6181,30 +6130,6 @@ def test_waitlist_user_denied_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_domain_stand_alone_round_trip
fixture = {
"object" => "organization_domain",
"id" => "stub",
"organization_id" => "stub",
"domain" => "stub",
"state" => "stub",
"verification_prefix" => "stub",
"verification_token" => "stub",
"verification_strategy" => "stub",
"created_at" => "stub",
"updated_at" => "stub"
}
model = WorkOS::OrganizationDomainStandAlone.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
assert_equal fixture["organization_id"], json[:organization_id]
assert_equal fixture["domain"], json[:domain]
assert_equal fixture["created_at"], json[:created_at]
assert_equal fixture["updated_at"], json[:updated_at]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_flag_round_trip
fixture = {
"object" => "feature_flag",
Expand Down Expand Up @@ -6233,32 +6158,6 @@ def test_flag_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_api_key_round_trip
fixture = {
"object" => "api_key",
"id" => "stub",
"owner" => {},
"name" => "stub",
"obfuscated_value" => "stub",
"last_used_at" => nil,
"expires_at" => nil,
"permissions" => [],
"created_at" => "stub",
"updated_at" => "stub"
}
model = WorkOS::OrganizationApiKey.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
assert_equal fixture["name"], json[:name]
assert_equal fixture["obfuscated_value"], json[:obfuscated_value]
assert_nil json[:last_used_at]
assert_nil json[:expires_at]
assert_equal fixture["created_at"], json[:created_at]
assert_equal fixture["updated_at"], json[:updated_at]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_api_key_with_value_round_trip
fixture = {
"object" => "api_key",
Expand Down Expand Up @@ -6595,6 +6494,7 @@ def test_user_organization_membership_round_trip
"created_at" => "stub",
"updated_at" => "stub",
"role" => {},
"roles" => [],
"user" => {}
}
model = WorkOS::UserOrganizationMembership.new(fixture.to_json)
Expand Down Expand Up @@ -6938,6 +6838,30 @@ def test_jwt_template_response_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_domain_round_trip
fixture = {
"object" => "organization_domain",
"id" => "stub",
"organization_id" => "stub",
"domain" => "stub",
"state" => "stub",
"verification_prefix" => "stub",
"verification_token" => "stub",
"verification_strategy" => "stub",
"created_at" => "stub",
"updated_at" => "stub"
}
model = WorkOS::OrganizationDomain.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
assert_equal fixture["organization_id"], json[:organization_id]
assert_equal fixture["domain"], json[:domain]
assert_equal fixture["created_at"], json[:created_at]
assert_equal fixture["updated_at"], json[:updated_at]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_jwks_response_keys_round_trip
fixture = {
"alg" => "RS256",
Expand Down Expand Up @@ -7099,30 +7023,6 @@ def test_audit_log_configuration_log_stream_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_domain_round_trip
fixture = {
"object" => "organization_domain",
"id" => "stub",
"organization_id" => "stub",
"domain" => "stub",
"state" => "stub",
"verification_prefix" => "stub",
"verification_token" => "stub",
"verification_strategy" => "stub",
"created_at" => "stub",
"updated_at" => "stub"
}
model = WorkOS::OrganizationDomain.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
assert_equal fixture["organization_id"], json[:organization_id]
assert_equal fixture["domain"], json[:domain]
assert_equal fixture["created_at"], json[:created_at]
assert_equal fixture["updated_at"], json[:updated_at]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_api_key_with_value_owner_round_trip
fixture = {
"type" => "organization",
Expand All @@ -7135,18 +7035,6 @@ def test_organization_api_key_with_value_owner_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_organization_api_key_owner_round_trip
fixture = {
"type" => "organization",
"id" => "stub"
}
model = WorkOS::OrganizationApiKeyOwner.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_flag_owner_round_trip
fixture = {
"email" => "stub",
Expand All @@ -7162,17 +7050,6 @@ def test_flag_owner_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_event_list_list_metadata_round_trip
fixture = {
"after" => nil
}
model = WorkOS::EventListListMetadata.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_nil json[:after]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_directory_user_email_round_trip
fixture = {
"primary" => true,
Expand Down Expand Up @@ -7379,21 +7256,6 @@ def test_audit_log_schema_target_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_authorized_connect_application_list_data_round_trip
fixture = {
"object" => "authorized_connect_application",
"id" => "stub",
"granted_scopes" => [],
"oauth_resource" => "stub",
"application" => {}
}
model = WorkOS::AuthorizedConnectApplicationListData.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["id"], json[:id]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_api_key_owner_round_trip
fixture = {
"type" => "organization",
Expand Down Expand Up @@ -7831,6 +7693,7 @@ def test_organization_membership_round_trip
"created_at" => "stub",
"updated_at" => "stub",
"role" => {},
"roles" => [],
"user" => {}
}
model = WorkOS::OrganizationMembership.new(fixture.to_json)
Expand Down