Skip to content

Migrate roles search to generated models#6563

Merged
gpunto merged 1 commit into
developfrom
migrate/roles
Jul 10, 2026
Merged

Migrate roles search to generated models#6563
gpunto merged 1 commit into
developfrom
migrate/roles

Conversation

@gpunto

@gpunto gpunto commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the /roles/search endpoint to generated models. Part of the incremental OpenAPI model migration.

Part of AND-1291

Implementation

  • Add generated Role and SearchRolesResponse; delete the hand-written DownstreamRoleDto and SearchRolesResponse.
  • The generated Role collides with the domain io.getstream.chat.android.models.Role, so it is imported aliased as RoleDto in the mapper and tests (the necessary name-collision case, not an alias to avoid renames).
  • Point RoleApi/mapper/tests at the generated types; the mapper now reads the generated camelCase createdAt/updatedAt.
  • No parser-infra change: Role's Date fields are handled by the existing date adapter, so this slice is independent of the Serializer foundation.

Testing

  • Project-wide spotlessApply, apiDump (no API drift), lint, detekt, and testDebugUnitTest all pass.
  • Verified on device: searchRoles parses a real SearchRolesResponse + Role (count=1, name and required createdAt populated).

Summary by CodeRabbit

  • Bug Fixes

    • Updated role search responses to use the latest role data format, improving consistency across role-related API responses and mappings.
    • Adjusted role timestamps and role lists to be handled with the newer field names and structure.
  • Tests

    • Refreshed role-related test data and assertions to match the updated response format.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.94 MB 5.94 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.20 MB 11.21 MB 0.01 MB 🟢
stream-chat-android-compose 12.68 MB 12.68 MB 0.00 MB 🟢

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@gpunto gpunto marked this pull request as ready for review July 9, 2026 14:12
@gpunto gpunto requested a review from a team as a code owner July 9, 2026 14:12
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Migrates the Role and SearchRolesResponse DTOs from client.api2.model.* (including deletion of DownstreamRoleDto) to new definitions under network.models, updates RoleApi and DomainMapping to reference the new types with createdAt/updatedAt field names, and updates related test helpers and assertions.

Changes

Role DTO migration

Layer / File(s) Summary
New network.models Role and SearchRolesResponse
stream-chat-android-client/.../network/models/Role.kt, stream-chat-android-client/.../network/models/SearchRolesResponse.kt
Adds a new Moshi-annotated Role data class and updates SearchRolesResponse to use List<Role>, a non-null duration, and @Json(name=...) mappings.
API endpoint and domain mapper updates
stream-chat-android-client/.../api2/endpoint/RoleApi.kt, stream-chat-android-client/.../api2/mapping/DomainMapping.kt, stream-chat-android-client/.../api2/model/dto/DownstreamRoleDto.kt
RoleApi.searchRoles and DomainMapping.toDomain() are switched to the new network.models types, mapping createdAt/updatedAt instead of created_at/updated_at; the old DownstreamRoleDto.kt file is deleted.
Test helper and assertion updates
stream-chat-android-client/src/test/.../Mother.kt, .../api2/MoshiChatApiTest.kt, .../api2/MoshiChatApiTestArguments.kt, .../api2/mapping/DomainMappingTest.kt
Renames randomDownstreamRoleDto to randomRoleDto returning non-null timestamps, updates imports across test files, and adjusts test construction/assertions to use the new DTO and field names.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

Suggested labels: pr:improvement

Suggested reviewers: andremion

Poem

A DTO hopped to a brand new nest,
network.models is now its address.
createdAt, updatedAt, no nulls in sight,
The old Downstream burrow was tidied up right.
🐇✨ Roles now mapped, tests all in a row —
This bunny approves of the migration flow!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: migrating roles search to generated models.
Description check ✅ Passed The description includes Goal, Implementation, and Testing and matches the requested template well enough despite optional UI/checklist sections being absent.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/roles

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/Role.kt (1)

17-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Undocumented @file:Suppress.

The suppression list has no comment explaining why each rule is disabled. As per coding guidelines, **/*.kt: "avoid suppressions unless documented". Given this is generated boilerplate, low priority, but worth a brief comment for future maintainers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/Role.kt`
around lines 17 - 22, The file-level suppression in Role.kt is undocumented, so
add a brief comment near the `@file`:Suppress declaration explaining that these
rules are intentionally disabled for generated boilerplate. Keep the note short
and explicit for each suppressed rule group, so future maintainers understand
why ArrayInDataClass, EnumEntryName, RemoveRedundantQualifierName, and
UnusedImport are being suppressed in this file.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/Role.kt`:
- Around line 17-22: The file-level suppression in Role.kt is undocumented, so
add a brief comment near the `@file`:Suppress declaration explaining that these
rules are intentionally disabled for generated boilerplate. Keep the note short
and explicit for each suppressed rule group, so future maintainers understand
why ArrayInDataClass, EnumEntryName, RemoveRedundantQualifierName, and
UnusedImport are being suppressed in this file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 24dab071-e129-44c9-a74c-f9738f68b487

📥 Commits

Reviewing files that changed from the base of the PR and between e26038e and 899dcd4.

📒 Files selected for processing (9)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/RoleApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamRoleDto.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/Role.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SearchRolesResponse.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTestArguments.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt
💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/DownstreamRoleDto.kt

@gpunto gpunto enabled auto-merge (squash) July 9, 2026 14:50
@gpunto gpunto merged commit 4fbbe25 into develop Jul 10, 2026
25 of 27 checks passed
@gpunto gpunto deleted the migrate/roles branch July 10, 2026 08:23
@stream-public-bot stream-public-bot added the released Included in a release label Jul 13, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants