diff --git a/angel_orm_generator/pubspec.yaml b/angel_orm_generator/pubspec.yaml index e0001369..4cdf41bb 100644 --- a/angel_orm_generator/pubspec.yaml +++ b/angel_orm_generator/pubspec.yaml @@ -38,3 +38,5 @@ dev_dependencies: dependency_overrides: angel_orm: path: ../angel_orm + angel_serialize_generator: + path: ../../serialize/angel_serialize_generator diff --git a/angel_orm_generator/test/models/author.g.dart b/angel_orm_generator/test/models/author.g.dart index f64258e7..5834d0d5 100644 --- a/angel_orm_generator/test/models/author.g.dart +++ b/angel_orm_generator/test/models/author.g.dart @@ -142,11 +142,7 @@ class AuthorQueryValues extends MapQueryValues { @generatedSerializable class Author extends _Author { - Author( - {this.id, - @required this.name = 'Tobe Osakwe', - this.createdAt, - this.updatedAt}); + Author({this.id, this.name = 'Tobe Osakwe', this.createdAt, this.updatedAt}); @override final String id; diff --git a/angel_orm_generator/test/models/book.g.dart b/angel_orm_generator/test/models/book.g.dart index cbf349ed..ebabf7b0 100644 --- a/angel_orm_generator/test/models/book.g.dart +++ b/angel_orm_generator/test/models/book.g.dart @@ -188,9 +188,9 @@ class BookQueryValues extends MapQueryValues { class Book extends _Book { Book( {this.id, - this.author, - this.partnerAuthor, - this.name, + @required this.author, + @required this.partnerAuthor, + @required this.name, this.createdAt, this.updatedAt}); @@ -254,6 +254,19 @@ class Book extends _Book { abstract class BookSerializer { static Book fromMap(Map map) { + if (map['author'] == null) { + throw new FormatException("Missing required field 'author' on Book."); + } + + if (map['partner_author'] == null) { + throw new FormatException( + "Missing required field 'partner_author' on Book."); + } + + if (map['name'] == null) { + throw new FormatException("Missing required field 'name' on Book."); + } + return new Book( id: map['id'] as String, author: map['author'] != null @@ -279,6 +292,19 @@ abstract class BookSerializer { if (model == null) { return null; } + if (model.author == null) { + throw new FormatException("Missing required field 'author' on Book."); + } + + if (model.partnerAuthor == null) { + throw new FormatException( + "Missing required field 'partner_author' on Book."); + } + + if (model.name == null) { + throw new FormatException("Missing required field 'name' on Book."); + } + return { 'id': model.id, 'author': AuthorSerializer.toMap(model.author), diff --git a/angel_orm_generator/test/models/car.g.dart b/angel_orm_generator/test/models/car.g.dart index 945402ad..58171721 100644 --- a/angel_orm_generator/test/models/car.g.dart +++ b/angel_orm_generator/test/models/car.g.dart @@ -191,10 +191,10 @@ class CarQueryValues extends MapQueryValues { class Car extends _Car { Car( {this.id, - this.make, - this.description, - this.familyFriendly, - this.recalledAt, + @required this.make, + @required this.description, + @required this.familyFriendly, + @required this.recalledAt, this.createdAt, this.updatedAt}); @@ -272,6 +272,23 @@ class Car extends _Car { abstract class CarSerializer { static Car fromMap(Map map) { + if (map['make'] == null) { + throw new FormatException("Missing required field 'make' on Car."); + } + + if (map['description'] == null) { + throw new FormatException("Missing required field 'description' on Car."); + } + + if (map['family_friendly'] == null) { + throw new FormatException( + "Missing required field 'family_friendly' on Car."); + } + + if (map['recalled_at'] == null) { + throw new FormatException("Missing required field 'recalled_at' on Car."); + } + return new Car( id: map['id'] as String, make: map['make'] as String, @@ -298,6 +315,23 @@ abstract class CarSerializer { if (model == null) { return null; } + if (model.make == null) { + throw new FormatException("Missing required field 'make' on Car."); + } + + if (model.description == null) { + throw new FormatException("Missing required field 'description' on Car."); + } + + if (model.familyFriendly == null) { + throw new FormatException( + "Missing required field 'family_friendly' on Car."); + } + + if (model.recalledAt == null) { + throw new FormatException("Missing required field 'recalled_at' on Car."); + } + return { 'id': model.id, 'make': model.make, diff --git a/angel_orm_generator/test/models/foot.g.dart b/angel_orm_generator/test/models/foot.g.dart index c23b674b..3216124f 100644 --- a/angel_orm_generator/test/models/foot.g.dart +++ b/angel_orm_generator/test/models/foot.g.dart @@ -151,7 +151,12 @@ class FootQueryValues extends MapQueryValues { @generatedSerializable class Foot extends _Foot { - Foot({this.id, this.legId, this.nToes, this.createdAt, this.updatedAt}); + Foot( + {this.id, + @required this.legId, + @required this.nToes, + this.createdAt, + this.updatedAt}); @override final String id; @@ -207,6 +212,14 @@ class Foot extends _Foot { abstract class FootSerializer { static Foot fromMap(Map map) { + if (map['leg_id'] == null) { + throw new FormatException("Missing required field 'leg_id' on Foot."); + } + + if (map['n_toes'] == null) { + throw new FormatException("Missing required field 'n_toes' on Foot."); + } + return new Foot( id: map['id'] as String, legId: map['leg_id'] as int, @@ -227,6 +240,14 @@ abstract class FootSerializer { if (model == null) { return null; } + if (model.legId == null) { + throw new FormatException("Missing required field 'leg_id' on Foot."); + } + + if (model.nToes == null) { + throw new FormatException("Missing required field 'n_toes' on Foot."); + } + return { 'id': model.id, 'leg_id': model.legId, diff --git a/angel_orm_generator/test/models/fruit.g.dart b/angel_orm_generator/test/models/fruit.g.dart index cb34d70a..754501be 100644 --- a/angel_orm_generator/test/models/fruit.g.dart +++ b/angel_orm_generator/test/models/fruit.g.dart @@ -152,7 +152,11 @@ class FruitQueryValues extends MapQueryValues { @generatedSerializable class Fruit extends _Fruit { Fruit( - {this.id, this.treeId, this.commonName, this.createdAt, this.updatedAt}); + {this.id, + @required this.treeId, + @required this.commonName, + this.createdAt, + this.updatedAt}); @override final String id; @@ -208,6 +212,15 @@ class Fruit extends _Fruit { abstract class FruitSerializer { static Fruit fromMap(Map map) { + if (map['tree_id'] == null) { + throw new FormatException("Missing required field 'tree_id' on Fruit."); + } + + if (map['common_name'] == null) { + throw new FormatException( + "Missing required field 'common_name' on Fruit."); + } + return new Fruit( id: map['id'] as String, treeId: map['tree_id'] as int, @@ -228,6 +241,15 @@ abstract class FruitSerializer { if (model == null) { return null; } + if (model.treeId == null) { + throw new FormatException("Missing required field 'tree_id' on Fruit."); + } + + if (model.commonName == null) { + throw new FormatException( + "Missing required field 'common_name' on Fruit."); + } + return { 'id': model.id, 'tree_id': model.treeId, diff --git a/angel_orm_generator/test/models/has_car.dart b/angel_orm_generator/test/models/has_car.dart index a8c83c24..6e7a7c8e 100644 --- a/angel_orm_generator/test/models/has_car.dart +++ b/angel_orm_generator/test/models/has_car.dart @@ -20,6 +20,6 @@ abstract class _HasCar extends Model { // serializesTo: Map, serializer: #_carToMap, deserializer: #_carFromMap) // Car get car; - @SerializableField(isNullable: false) + @SerializableField(isNullable: false, defaultValue: CarType.sedan) CarType get type; } diff --git a/angel_orm_generator/test/models/has_car.g.dart b/angel_orm_generator/test/models/has_car.g.dart index e6f3b1b6..340cdcae 100644 --- a/angel_orm_generator/test/models/has_car.g.dart +++ b/angel_orm_generator/test/models/has_car.g.dart @@ -11,7 +11,7 @@ class HasCarMigration extends Migration { up(Schema schema) { schema.create('has_cars', (table) { table.serial('id')..primaryKey(); - table.integer('type'); + table.integer('type')..defaultsTo(0); table.timeStamp('created_at'); table.timeStamp('updated_at'); }); @@ -140,7 +140,7 @@ class HasCarQueryValues extends MapQueryValues { @generatedSerializable class HasCar extends _HasCar { - HasCar({this.id, @required this.type, this.createdAt, this.updatedAt}); + HasCar({this.id, this.type = CarType.sedan, this.createdAt, this.updatedAt}); @override final String id; @@ -195,7 +195,9 @@ abstract class HasCarSerializer { id: map['id'] as String, type: map['type'] is CarType ? (map['type'] as CarType) - : (map['type'] is int ? CarType.values[map['type'] as int] : null), + : (map['type'] is int + ? CarType.values[map['type'] as int] + : CarType.sedan), createdAt: map['created_at'] != null ? (map['created_at'] is DateTime ? (map['created_at'] as DateTime) diff --git a/angel_orm_generator/test/models/has_map.g.dart b/angel_orm_generator/test/models/has_map.g.dart index 0a662e5d..49a53c50 100644 --- a/angel_orm_generator/test/models/has_map.g.dart +++ b/angel_orm_generator/test/models/has_map.g.dart @@ -119,7 +119,9 @@ class HasMapQueryValues extends MapQueryValues { @generatedSerializable class HasMap implements _HasMap { - const HasMap({Map this.value, List this.list}); + const HasMap( + {@required Map this.value, + @required List this.list}); @override final Map value; @@ -156,6 +158,14 @@ class HasMap implements _HasMap { abstract class HasMapSerializer { static HasMap fromMap(Map map) { + if (map['value'] == null) { + throw new FormatException("Missing required field 'value' on HasMap."); + } + + if (map['list'] == null) { + throw new FormatException("Missing required field 'list' on HasMap."); + } + return new HasMap( value: map['value'] is Map ? (map['value'] as Map).cast() @@ -169,6 +179,14 @@ abstract class HasMapSerializer { if (model == null) { return null; } + if (model.value == null) { + throw new FormatException("Missing required field 'value' on HasMap."); + } + + if (model.list == null) { + throw new FormatException("Missing required field 'list' on HasMap."); + } + return {'value': model.value, 'list': model.list}; } } diff --git a/angel_orm_generator/test/models/leg.g.dart b/angel_orm_generator/test/models/leg.g.dart index 9c303253..b874312c 100644 --- a/angel_orm_generator/test/models/leg.g.dart +++ b/angel_orm_generator/test/models/leg.g.dart @@ -19,7 +19,7 @@ class LegMigration extends Migration { @override down(Schema schema) { - schema.drop('legs'); + schema.drop('legs', cascade: true); } } @@ -152,7 +152,12 @@ class LegQueryValues extends MapQueryValues { @generatedSerializable class Leg extends _Leg { - Leg({this.id, this.foot, this.name, this.createdAt, this.updatedAt}); + Leg( + {this.id, + @required this.foot, + @required this.name, + this.createdAt, + this.updatedAt}); @override final String id; @@ -208,6 +213,14 @@ class Leg extends _Leg { abstract class LegSerializer { static Leg fromMap(Map map) { + if (map['foot'] == null) { + throw new FormatException("Missing required field 'foot' on Leg."); + } + + if (map['name'] == null) { + throw new FormatException("Missing required field 'name' on Leg."); + } + return new Leg( id: map['id'] as String, foot: map['foot'] != null @@ -230,6 +243,14 @@ abstract class LegSerializer { if (model == null) { return null; } + if (model.foot == null) { + throw new FormatException("Missing required field 'foot' on Leg."); + } + + if (model.name == null) { + throw new FormatException("Missing required field 'name' on Leg."); + } + return { 'id': model.id, 'foot': FootSerializer.toMap(model.foot), diff --git a/angel_orm_generator/test/models/order.g.dart b/angel_orm_generator/test/models/order.g.dart index 170eaf5a..635ff568 100644 --- a/angel_orm_generator/test/models/order.g.dart +++ b/angel_orm_generator/test/models/order.g.dart @@ -199,10 +199,10 @@ class OrderQueryValues extends MapQueryValues { class Order extends _Order { Order( {this.id, - this.customer, - this.employeeId, - this.orderDate, - this.shipperId, + @required this.customer, + @required this.employeeId, + @required this.orderDate, + @required this.shipperId, this.createdAt, this.updatedAt}); @@ -273,6 +273,25 @@ class Order extends _Order { abstract class OrderSerializer { static Order fromMap(Map map) { + if (map['customer'] == null) { + throw new FormatException("Missing required field 'customer' on Order."); + } + + if (map['employee_id'] == null) { + throw new FormatException( + "Missing required field 'employee_id' on Order."); + } + + if (map['order_date'] == null) { + throw new FormatException( + "Missing required field 'order_date' on Order."); + } + + if (map['shipper_id'] == null) { + throw new FormatException( + "Missing required field 'shipper_id' on Order."); + } + return new Order( id: map['id'] as String, customer: map['customer'] != null @@ -301,6 +320,25 @@ abstract class OrderSerializer { if (model == null) { return null; } + if (model.customer == null) { + throw new FormatException("Missing required field 'customer' on Order."); + } + + if (model.employeeId == null) { + throw new FormatException( + "Missing required field 'employee_id' on Order."); + } + + if (model.orderDate == null) { + throw new FormatException( + "Missing required field 'order_date' on Order."); + } + + if (model.shipperId == null) { + throw new FormatException( + "Missing required field 'shipper_id' on Order."); + } + return { 'id': model.id, 'customer': CustomerSerializer.toMap(model.customer), diff --git a/angel_orm_generator/test/models/tree.g.dart b/angel_orm_generator/test/models/tree.g.dart index e338054b..7f980a9c 100644 --- a/angel_orm_generator/test/models/tree.g.dart +++ b/angel_orm_generator/test/models/tree.g.dart @@ -19,7 +19,7 @@ class TreeMigration extends Migration { @override down(Schema schema) { - schema.drop('trees'); + schema.drop('trees', cascade: true); } } @@ -213,7 +213,11 @@ class TreeQueryValues extends MapQueryValues { @generatedSerializable class Tree extends _Tree { Tree( - {this.id, this.rings, List fruits, this.createdAt, this.updatedAt}) + {this.id, + @required this.rings, + @required List fruits, + this.createdAt, + this.updatedAt}) : this.fruits = new List.unmodifiable(fruits ?? []); @override @@ -271,6 +275,14 @@ class Tree extends _Tree { abstract class TreeSerializer { static Tree fromMap(Map map) { + if (map['rings'] == null) { + throw new FormatException("Missing required field 'rings' on Tree."); + } + + if (map['fruits'] == null) { + throw new FormatException("Missing required field 'fruits' on Tree."); + } + return new Tree( id: map['id'] as String, rings: map['rings'] as int, @@ -296,6 +308,14 @@ abstract class TreeSerializer { if (model == null) { return null; } + if (model.rings == null) { + throw new FormatException("Missing required field 'rings' on Tree."); + } + + if (model.fruits == null) { + throw new FormatException("Missing required field 'fruits' on Tree."); + } + return { 'id': model.id, 'rings': model.rings, diff --git a/angel_orm_generator/test/models/unorthodox.g.dart b/angel_orm_generator/test/models/unorthodox.g.dart index 0f2f80ca..e39d9cc4 100644 --- a/angel_orm_generator/test/models/unorthodox.g.dart +++ b/angel_orm_generator/test/models/unorthodox.g.dart @@ -30,7 +30,7 @@ class WeirdJoinMigration extends Migration { @override down(Schema schema) { - schema.drop('weird_joins'); + schema.drop('weird_joins', cascade: true); } } @@ -75,7 +75,7 @@ class FooMigration extends Migration { @override down(Schema schema) { - schema.drop('foos'); + schema.drop('foos', cascade: true); } } @@ -821,7 +821,7 @@ class FooPivotQueryValues extends MapQueryValues { @generatedSerializable class Unorthodox implements _Unorthodox { - const Unorthodox({this.name}); + const Unorthodox({@required this.name}); @override final String name; @@ -847,11 +847,11 @@ class Unorthodox implements _Unorthodox { @generatedSerializable class WeirdJoin implements _WeirdJoin { const WeirdJoin( - {this.id, - this.unorthodox, - this.song, - List<_Numba> this.numbas, - List<_Foo> this.foos}); + {@required this.id, + @required this.unorthodox, + @required this.song, + @required List<_Numba> this.numbas, + @required List<_Foo> this.foos}); @override final int id; @@ -905,7 +905,12 @@ class WeirdJoin implements _WeirdJoin { @generatedSerializable class Song extends _Song { - Song({this.id, this.weirdJoinId, this.title, this.createdAt, this.updatedAt}); + Song( + {this.id, + @required this.weirdJoinId, + @required this.title, + this.createdAt, + this.updatedAt}); @override final String id; @@ -957,7 +962,7 @@ class Song extends _Song { @generatedSerializable class Numba extends _Numba { - Numba({this.i, this.parent}); + Numba({@required this.i, @required this.parent}); @override final int i; @@ -985,7 +990,7 @@ class Numba extends _Numba { @generatedSerializable class Foo implements _Foo { - const Foo({this.bar, List<_WeirdJoin> this.weirdJoins}); + const Foo({@required this.bar, @required List<_WeirdJoin> this.weirdJoins}); @override final String bar; @@ -1017,7 +1022,7 @@ class Foo implements _Foo { @generatedSerializable class FooPivot implements _FooPivot { - const FooPivot({this.weirdJoin, this.foo}); + const FooPivot({@required this.weirdJoin, @required this.foo}); @override final _WeirdJoin weirdJoin; @@ -1052,6 +1057,10 @@ class FooPivot implements _FooPivot { abstract class UnorthodoxSerializer { static Unorthodox fromMap(Map map) { + if (map['name'] == null) { + throw new FormatException("Missing required field 'name' on Unorthodox."); + } + return new Unorthodox(name: map['name'] as String); } @@ -1059,6 +1068,10 @@ abstract class UnorthodoxSerializer { if (model == null) { return null; } + if (model.name == null) { + throw new FormatException("Missing required field 'name' on Unorthodox."); + } + return {'name': model.name}; } } @@ -1071,6 +1084,28 @@ abstract class UnorthodoxFields { abstract class WeirdJoinSerializer { static WeirdJoin fromMap(Map map) { + if (map['id'] == null) { + throw new FormatException("Missing required field 'id' on WeirdJoin."); + } + + if (map['unorthodox'] == null) { + throw new FormatException( + "Missing required field 'unorthodox' on WeirdJoin."); + } + + if (map['song'] == null) { + throw new FormatException("Missing required field 'song' on WeirdJoin."); + } + + if (map['numbas'] == null) { + throw new FormatException( + "Missing required field 'numbas' on WeirdJoin."); + } + + if (map['foos'] == null) { + throw new FormatException("Missing required field 'foos' on WeirdJoin."); + } + return new WeirdJoin( id: map['id'] as int, unorthodox: map['unorthodox'] != null @@ -1097,6 +1132,28 @@ abstract class WeirdJoinSerializer { if (model == null) { return null; } + if (model.id == null) { + throw new FormatException("Missing required field 'id' on WeirdJoin."); + } + + if (model.unorthodox == null) { + throw new FormatException( + "Missing required field 'unorthodox' on WeirdJoin."); + } + + if (model.song == null) { + throw new FormatException("Missing required field 'song' on WeirdJoin."); + } + + if (model.numbas == null) { + throw new FormatException( + "Missing required field 'numbas' on WeirdJoin."); + } + + if (model.foos == null) { + throw new FormatException("Missing required field 'foos' on WeirdJoin."); + } + return { 'id': model.id, 'unorthodox': UnorthodoxSerializer.toMap(model.unorthodox), @@ -1129,6 +1186,15 @@ abstract class WeirdJoinFields { abstract class SongSerializer { static Song fromMap(Map map) { + if (map['weird_join_id'] == null) { + throw new FormatException( + "Missing required field 'weird_join_id' on Song."); + } + + if (map['title'] == null) { + throw new FormatException("Missing required field 'title' on Song."); + } + return new Song( id: map['id'] as String, weirdJoinId: map['weird_join_id'] as int, @@ -1149,6 +1215,15 @@ abstract class SongSerializer { if (model == null) { return null; } + if (model.weirdJoinId == null) { + throw new FormatException( + "Missing required field 'weird_join_id' on Song."); + } + + if (model.title == null) { + throw new FormatException("Missing required field 'title' on Song."); + } + return { 'id': model.id, 'weird_join_id': model.weirdJoinId, @@ -1181,6 +1256,14 @@ abstract class SongFields { abstract class NumbaSerializer { static Numba fromMap(Map map) { + if (map['i'] == null) { + throw new FormatException("Missing required field 'i' on Numba."); + } + + if (map['parent'] == null) { + throw new FormatException("Missing required field 'parent' on Numba."); + } + return new Numba(i: map['i'] as int, parent: map['parent'] as int); } @@ -1188,6 +1271,14 @@ abstract class NumbaSerializer { if (model == null) { return null; } + if (model.i == null) { + throw new FormatException("Missing required field 'i' on Numba."); + } + + if (model.parent == null) { + throw new FormatException("Missing required field 'parent' on Numba."); + } + return {'i': model.i, 'parent': model.parent}; } } @@ -1202,6 +1293,14 @@ abstract class NumbaFields { abstract class FooSerializer { static Foo fromMap(Map map) { + if (map['bar'] == null) { + throw new FormatException("Missing required field 'bar' on Foo."); + } + + if (map['weird_joins'] == null) { + throw new FormatException("Missing required field 'weird_joins' on Foo."); + } + return new Foo( bar: map['bar'] as String, weirdJoins: map['weird_joins'] is Iterable @@ -1216,6 +1315,14 @@ abstract class FooSerializer { if (model == null) { return null; } + if (model.bar == null) { + throw new FormatException("Missing required field 'bar' on Foo."); + } + + if (model.weirdJoins == null) { + throw new FormatException("Missing required field 'weird_joins' on Foo."); + } + return { 'bar': model.bar, 'weird_joins': @@ -1234,6 +1341,15 @@ abstract class FooFields { abstract class FooPivotSerializer { static FooPivot fromMap(Map map) { + if (map['weird_join'] == null) { + throw new FormatException( + "Missing required field 'weird_join' on FooPivot."); + } + + if (map['foo'] == null) { + throw new FormatException("Missing required field 'foo' on FooPivot."); + } + return new FooPivot( weirdJoin: map['weird_join'] != null ? WeirdJoinSerializer.fromMap(map['weird_join'] as Map) @@ -1247,6 +1363,15 @@ abstract class FooPivotSerializer { if (model == null) { return null; } + if (model.weirdJoin == null) { + throw new FormatException( + "Missing required field 'weird_join' on FooPivot."); + } + + if (model.foo == null) { + throw new FormatException("Missing required field 'foo' on FooPivot."); + } + return { 'weird_join': WeirdJoinSerializer.toMap(model.weirdJoin), 'foo': FooSerializer.toMap(model.foo) diff --git a/angel_orm_generator/test/models/user.g.dart b/angel_orm_generator/test/models/user.g.dart index 5663ebe3..09637f0d 100644 --- a/angel_orm_generator/test/models/user.g.dart +++ b/angel_orm_generator/test/models/user.g.dart @@ -21,7 +21,7 @@ class UserMigration extends Migration { @override down(Schema schema) { - schema.drop('users'); + schema.drop('users', cascade: true); } } @@ -53,7 +53,7 @@ class RoleMigration extends Migration { @override down(Schema schema) { - schema.drop('roles'); + schema.drop('roles', cascade: true); } } @@ -570,10 +570,10 @@ class RoleQueryValues extends MapQueryValues { class User extends _User { User( {this.id, - this.username, - this.password, - this.email, - List<_Role> roles, + @required this.username, + @required this.password, + @required this.email, + @required List<_Role> roles, this.createdAt, this.updatedAt}) : this.roles = new List.unmodifiable(roles ?? []); @@ -642,7 +642,7 @@ class User extends _User { @generatedSerializable class RoleUser implements _RoleUser { - const RoleUser({this.role, this.user}); + const RoleUser({@required this.role, @required this.user}); @override final _Role role; @@ -670,7 +670,12 @@ class RoleUser implements _RoleUser { @generatedSerializable class Role extends _Role { - Role({this.id, this.name, List<_User> users, this.createdAt, this.updatedAt}) + Role( + {this.id, + @required this.name, + @required List<_User> users, + this.createdAt, + this.updatedAt}) : this.users = new List.unmodifiable(users ?? []); @override @@ -728,6 +733,22 @@ class Role extends _Role { abstract class UserSerializer { static User fromMap(Map map) { + if (map['username'] == null) { + throw new FormatException("Missing required field 'username' on User."); + } + + if (map['password'] == null) { + throw new FormatException("Missing required field 'password' on User."); + } + + if (map['email'] == null) { + throw new FormatException("Missing required field 'email' on User."); + } + + if (map['roles'] == null) { + throw new FormatException("Missing required field 'roles' on User."); + } + return new User( id: map['id'] as String, username: map['username'] as String, @@ -755,6 +776,22 @@ abstract class UserSerializer { if (model == null) { return null; } + if (model.username == null) { + throw new FormatException("Missing required field 'username' on User."); + } + + if (model.password == null) { + throw new FormatException("Missing required field 'password' on User."); + } + + if (model.email == null) { + throw new FormatException("Missing required field 'email' on User."); + } + + if (model.roles == null) { + throw new FormatException("Missing required field 'roles' on User."); + } + return { 'id': model.id, 'username': model.username, @@ -795,6 +832,14 @@ abstract class UserFields { abstract class RoleUserSerializer { static RoleUser fromMap(Map map) { + if (map['role'] == null) { + throw new FormatException("Missing required field 'role' on RoleUser."); + } + + if (map['user'] == null) { + throw new FormatException("Missing required field 'user' on RoleUser."); + } + return new RoleUser( role: map['role'] != null ? RoleSerializer.fromMap(map['role'] as Map) @@ -808,6 +853,14 @@ abstract class RoleUserSerializer { if (model == null) { return null; } + if (model.role == null) { + throw new FormatException("Missing required field 'role' on RoleUser."); + } + + if (model.user == null) { + throw new FormatException("Missing required field 'user' on RoleUser."); + } + return { 'role': RoleSerializer.toMap(model.role), 'user': UserSerializer.toMap(model.user) @@ -825,6 +878,14 @@ abstract class RoleUserFields { abstract class RoleSerializer { static Role fromMap(Map map) { + if (map['name'] == null) { + throw new FormatException("Missing required field 'name' on Role."); + } + + if (map['users'] == null) { + throw new FormatException("Missing required field 'users' on Role."); + } + return new Role( id: map['id'] as String, name: map['name'] as String, @@ -850,6 +911,14 @@ abstract class RoleSerializer { if (model == null) { return null; } + if (model.name == null) { + throw new FormatException("Missing required field 'name' on Role."); + } + + if (model.users == null) { + throw new FormatException("Missing required field 'users' on Role."); + } + return { 'id': model.id, 'name': model.name,