@@ -180,8 +180,6 @@ class YmlGeneratorConfig {
180
180
Field getField (String name, YamlMap property,
181
181
{required bool disallowNullForDefaults}) {
182
182
try {
183
- final required =
184
- property.containsKey ('required' ) && property['required' ] == true ;
185
183
final ignored =
186
184
property.containsKey ('ignore' ) && property['ignore' ] == true ;
187
185
final includeFromJson = ! property.containsKey ('includeFromJson' ) ||
@@ -210,40 +208,15 @@ class YmlGeneratorConfig {
210
208
if (type == null ) {
211
209
throw Exception ('$name has no defined type' );
212
210
}
213
- final lowerType = type.toLowerCase ();
214
- if (lowerType == 'object' ||
215
- lowerType == 'dynamic' ||
216
- lowerType == 'any' ) {
217
- itemType = DynamicType ();
218
- } else if (type == 'bool' || lowerType == 'boolean' ) {
219
- itemType = BooleanType ();
220
- } else if (lowerType == 'string' ) {
221
- itemType = StringType ();
222
- } else if (lowerType == 'date' || lowerType == 'datetime' ) {
223
- itemType = DateTimeType ();
224
- } else if (lowerType == 'double' ) {
225
- itemType = DoubleType ();
226
- } else if (type == 'int' || type == 'integer' ) {
227
- itemType = IntegerType ();
228
- } else if (lowerType == 'array' ) {
229
- final items = property['items' ];
230
- final arrayType = items['type' ];
231
- itemType = ArrayType (_makeGenericName (arrayType));
232
- } else if (lowerType == 'map' ) {
233
- final items = property['items' ];
234
- final keyType = items['key' ];
235
- final valueType = items['value' ];
236
- itemType = MapType (
237
- key: _makeGenericName (keyType),
238
- valueName: _makeGenericName (valueType),
239
- );
240
- } else {
241
- itemType = ObjectType (type);
242
- }
211
+
212
+ final optional = type.endsWith ('?' );
213
+ final typeString = optional ? type.substring (0 , type.length - 1 ) : type;
214
+
215
+ itemType = _parseSimpleType (typeString);
243
216
return Field (
244
217
name: name,
245
218
type: itemType,
246
- isRequired: required ,
219
+ isRequired: ! optional ,
247
220
ignore: ignored,
248
221
includeFromJson: includeFromJson,
249
222
includeToJson: includeToJson,
0 commit comments