Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for multiple TypedExtra subclasses. #714

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

devRaphe
Copy link
Contributor

@devRaphe devRaphe commented Oct 12, 2024

Handle Multiple @TypedExtras Annotations/Subclasses

Description

This PR enhances the flexibility of the Retrofit generator by allowing multiple TypedExtras subclass to be used on a single method. Previously, only one TypedExtras subclass was supported, limiting the ability to organise and group extra parameters. This change brings the behavior of TypedExtras subclass in line with how Extra subclasses are handled.

Changes

  • Updated the logic of _getMapFromTypedExtras to include all @TypedExtras data
  • Maintained backward compatibility with existing implementation

Implementation Details

  • The _getMapFromTypedExtras method now iterates through all @TypedExtras annotations on a method, extracting and combining their field values.
  • In case of conflicting keys across multiple @TypedExtras annotations, the later annotations take precedence.

Benefits

  • Greater flexibility in organising and grouping extra parameters

Testing

  • Added unit tests to verify the correct handling of multiple @TypedExtras annotations
  • Ensured existing tests for @extra continue to pass
  • Tested with various combinations of @extra, @TypedExtras, to ensure correct merging behaviour.

Example Usage

@TypedExtraSubclass1({'group1': 'value1'})
@TypedExtraSubclass2({'group2': 'value2'})
@GET('/endpoint')
Future<void> someMethod();

@devRaphe
Copy link
Contributor Author

devRaphe commented Oct 15, 2024

@trevorwang

@trevorwang trevorwang merged commit 0631416 into trevorwang:master Oct 15, 2024
2 checks passed
@trevorwang
Copy link
Owner

Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants