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

fix: #290 supports oneOf polymorphic types with dart_mappable #292

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

josh-burton
Copy link

This PR adds support for oneOf polymorphic (discriminated) types with dart_mappable.

Most of the changes are within the dart mappable dto template, but a few parser changes were required.

I've made some comments on various lines which are areas of discussion.

final class UniversalComponentClass extends UniversalDataClass {
/// Constructor for [UniversalComponentClass]
const UniversalComponentClass({
UniversalComponentClass({
Copy link
Author

Choose a reason for hiding this comment

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

I had to remove the const constuctor as the discriminatorValue field needs to be updated after the initial UniversalComponentClass class is constructed.

// The name of the property that is used to discriminate the oneOf variants
String propertyValue,
String parentClass,
})? discriminatorValue;
Copy link
Author

Choose a reason for hiding this comment

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

This discriminatorValue field could potentially be combined with discriminator above, perhaps adding an extra field to denote whether this class is a discrinator parent or discriminated value class.

@@ -198,6 +198,19 @@ void main() {
);
});

test('discriminated_one_of.3.0_mappable', () async {
Copy link
Author

Choose a reason for hiding this comment

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

It would be nice to combine this test with the discriminated_one_of.3.0 test above.

I've opened #291 to suggest some changes to the test structure to allow this.

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.

1 participant