Skip to content

[AND-433] Add default values to the collection properties generated by Open API - #1353

Closed
rahul-lohra wants to merge 17 commits into
developfrom
feature/rahullohra/add_default_values
Closed

rahul-lohra wants to merge 17 commits into
developfrom
feature/rahullohra/add_default_values

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

🎯 Goal

[AND-433] Add default values to the collection properties generated by Open API

OpenAPI generated models have fields which are mandatory, but sometimes don't arrive from the backend.
e.g. custom field in OwnUserResponse.

The signature of the field is val custom: Map<String, Any?>
We should generate these fields with a default value of empty map to prevent the parsers from failing if the field is missing. We already use relaxed parsing on the Moshi parsers, however they cannot handle everything.

The best approach for us is to generate the models to include default values for collections:
e.g.
val custom: Map<String, Any?> = emptyMap()

For optional fields the handling should remain the same.

We are also adding default values to the properties which are mentioned in the Open API like

Previous

@Json(name = "type")
val type: kotlin.String

Now

@Json(name = "type")
val type: kotlin.String = "call.blocked_user",
    

@rahul-lohra rahul-lohra self-assigned this Apr 9, 2025
@rahul-lohra
rahul-lohra requested a review from a team as a code owner April 9, 2025 07:01
@github-actions

github-actions Bot commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 11.40 MB 11.41 MB 0.02 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.68 MB -0.02 MB 🚀
stream-video-android-ui-compose 5.86 MB 5.88 MB 0.02 MB 🟢

@rahul-lohra
rahul-lohra marked this pull request as draft April 9, 2025 08:14
@rahul-lohra
rahul-lohra marked this pull request as ready for review April 9, 2025 18:30
Comment thread scripts/coverage.gradle Outdated
currentProject {
instrumentation {
excludedClasses.addAll(
"io.getstream.android.video.generated.models.*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Won't the next line cover this path as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right, I will remove this line.

@sonarqubecloud

Copy link
Copy Markdown

@aleksandar-apostolov aleksandar-apostolov added the pr:internal Internal or infra-only changes label May 8, 2025
@rahul-lohra
rahul-lohra marked this pull request as draft July 10, 2025 08:29
@sonarqubecloud

Copy link
Copy Markdown

@rahul-lohra

Copy link
Copy Markdown
Contributor Author

Closed. Will pick this up later

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

Labels

pr:internal Internal or infra-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants