@@ -66,6 +66,50 @@ TestModel:
66
66
expect (simpleDateTime.type, isA <DateTimeType >());
67
67
expect (simpleDateTime.isRequired, false );
68
68
});
69
+
70
+ test ('Test required not definable anymore' , () {
71
+ final models = YmlGeneratorConfig (
72
+ PubspecConfig ("name: test" ),
73
+ """
74
+ TestModel:
75
+ properties:
76
+ optionalString1:
77
+ type: String?
78
+ required: true
79
+ optionalString2:
80
+ type: String?
81
+ requiredString1:
82
+ type: String
83
+ required: false
84
+ requiredString2:
85
+ type: String
86
+ """ ,
87
+ '' )
88
+ .models;
89
+
90
+ expect (models.length, 1 );
91
+ final model = models.first;
92
+ expect (model is ObjectModel , true );
93
+ model as ObjectModel ;
94
+
95
+ final optionalString1 = model.fields.getByName ("optionalString1" );
96
+ final requiredString1 = model.fields.getByName ("requiredString1" );
97
+ final optionalString2 = model.fields.getByName ("optionalString2" );
98
+ final requiredString2 = model.fields.getByName ("requiredString2" );
99
+
100
+ expect (optionalString1.type, isA <StringType >());
101
+ expect (optionalString1.isRequired, false );
102
+
103
+ expect (requiredString1.type, isA <StringType >());
104
+ expect (requiredString1.isRequired, true );
105
+
106
+ expect (optionalString2.type, isA <StringType >());
107
+ expect (optionalString2.isRequired, false );
108
+
109
+ expect (requiredString2.type, isA <StringType >());
110
+ expect (requiredString2.isRequired, true );
111
+ });
112
+
69
113
test ('Test simple generic fields' , () {
70
114
final models = YmlGeneratorConfig (
71
115
PubspecConfig ("name: test" ),
0 commit comments