-
Notifications
You must be signed in to change notification settings - Fork 54
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
base: main
Are you sure you want to change the base?
Conversation
final class UniversalComponentClass extends UniversalDataClass { | ||
/// Constructor for [UniversalComponentClass] | ||
const UniversalComponentClass({ | ||
UniversalComponentClass({ |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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.