quicktype-core 21.0.0 → 21.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -300,7 +300,16 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
300
300
  }
301
301
  mapClass(isNullable, classType, dynamic) {
302
302
  if (this._options.nullSafety && isNullable && !this._options.requiredProperties) {
303
- return [dynamic, " == null ? null : ", this.nameForNamedType(classType), ".", this.fromJson, "(", dynamic, ")"];
303
+ return [
304
+ dynamic,
305
+ " == null ? null : ",
306
+ this.nameForNamedType(classType),
307
+ ".",
308
+ this.fromJson,
309
+ "(",
310
+ dynamic,
311
+ ")"
312
+ ];
304
313
  }
305
314
  return [this.nameForNamedType(classType), ".", this.fromJson, "(", dynamic, ")"];
306
315
  }
@@ -311,7 +320,12 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
311
320
  return (0, TypeUtils_1.matchType)(t, _anyType => dynamic, _nullType => dynamic, // FIXME: check null
312
321
  // FIXME: check null
313
322
  _boolType => dynamic, _integerType => dynamic, _doubleType => [dynamic, this._options.nullSafety ? "?.toDouble()" : ".toDouble()"], _stringType => dynamic, arrayType => this.mapList(isNullable || arrayType.isNullable, this.dartType(arrayType.items), dynamic, this.fromDynamicExpression(arrayType.items.isNullable, arrayType.items, "x")), classType => this.mapClass(isNullable || classType.isNullable, classType, dynamic), mapType => this.mapMap(mapType.isNullable || isNullable, this.dartType(mapType.values), dynamic, this.fromDynamicExpression(mapType.values.isNullable, mapType.values, "v")), enumType => {
314
- return [(0, Support_1.defined)(this._enumValues.get(enumType)), ".map[", dynamic, this._options.nullSafety ? "]!" : "]"];
323
+ return [
324
+ (0, Support_1.defined)(this._enumValues.get(enumType)),
325
+ ".map[",
326
+ dynamic,
327
+ this._options.nullSafety ? "]!" : "]"
328
+ ];
315
329
  }, unionType => {
316
330
  const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
317
331
  if (maybeNullable === null) {
@@ -322,7 +336,9 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
322
336
  switch (transformedStringType.kind) {
323
337
  case "date-time":
324
338
  case "date":
325
- if ((transformedStringType.isNullable || isNullable) && !this._options.requiredProperties && this._options.nullSafety) {
339
+ if ((transformedStringType.isNullable || isNullable) &&
340
+ !this._options.requiredProperties &&
341
+ this._options.nullSafety) {
326
342
  return [dynamic, " == null ? null : ", "DateTime.parse(", dynamic, ")"];
327
343
  }
328
344
  return ["DateTime.parse(", dynamic, ")"];
@@ -336,7 +352,9 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
336
352
  //so add isNullable property
337
353
  toDynamicExpression(isNullable = false, t, ...dynamic) {
338
354
  return (0, TypeUtils_1.matchType)(t, _anyType => dynamic, _nullType => dynamic, _boolType => dynamic, _integerType => dynamic, _doubleType => dynamic, _stringType => dynamic, arrayType => this.mapList(arrayType.isNullable || isNullable, "dynamic", dynamic, this.toDynamicExpression(arrayType.items.isNullable, arrayType.items, "x")), _classType => {
339
- if (this._options.nullSafety && (_classType.isNullable || isNullable) && !this._options.requiredProperties) {
355
+ if (this._options.nullSafety &&
356
+ (_classType.isNullable || isNullable) &&
357
+ !this._options.requiredProperties) {
340
358
  return [dynamic, "?.", this.toJson, "()"];
341
359
  }
342
360
  return [dynamic, ".", this.toJson, "()"];
@@ -351,14 +369,18 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
351
369
  }, transformedStringType => {
352
370
  switch (transformedStringType.kind) {
353
371
  case "date-time":
354
- if (this._options.nullSafety && !this._options.requiredProperties && (transformedStringType.isNullable || isNullable)) {
372
+ if (this._options.nullSafety &&
373
+ !this._options.requiredProperties &&
374
+ (transformedStringType.isNullable || isNullable)) {
355
375
  return [dynamic, "?.toIso8601String()"];
356
376
  }
357
377
  return [dynamic, ".toIso8601String()"];
358
378
  case "date":
359
- if (this._options.nullSafety && !this._options.requiredProperties && (transformedStringType.isNullable || isNullable)) {
379
+ if (this._options.nullSafety &&
380
+ !this._options.requiredProperties &&
381
+ (transformedStringType.isNullable || isNullable)) {
360
382
  return [
361
- "\"${",
383
+ '"${',
362
384
  dynamic,
363
385
  "!.year.toString().padLeft(4, '0')",
364
386
  "}-${",
@@ -369,7 +391,7 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
369
391
  ];
370
392
  }
371
393
  return [
372
- "\"${",
394
+ '"${',
373
395
  dynamic,
374
396
  ".year.toString().padLeft(4, '0')",
375
397
  "}-${",
@@ -447,7 +469,7 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
447
469
  this.emitLine("factory ", className, ".", this.fromJson, "(Map<String, dynamic> json) => ", className, "(");
448
470
  this.indent(() => {
449
471
  this.forEachClassProperty(c, "none", (name, jsonName, property) => {
450
- this.emitLine(name, ": ", this.fromDynamicExpression(property.type.isNullable, property.type, "json[\"", stringEscape(jsonName), "\"]"), ",");
472
+ this.emitLine(name, ": ", this.fromDynamicExpression(property.type.isNullable, property.type, 'json["', stringEscape(jsonName), '"]'), ",");
451
473
  });
452
474
  });
453
475
  this.emitLine(");");
@@ -455,7 +477,7 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
455
477
  this.emitLine("Map<String, dynamic> ", this.toJson, "() => {");
456
478
  this.indent(() => {
457
479
  this.forEachClassProperty(c, "none", (name, jsonName, property) => {
458
- this.emitLine("\"", stringEscape(jsonName), "\": ", this.toDynamicExpression(property.type.isNullable, property.type, name), ",");
480
+ this.emitLine('"', stringEscape(jsonName), '": ', this.toDynamicExpression(property.type.isNullable, property.type, name), ",");
459
481
  });
460
482
  });
461
483
  this.emitLine("};");
@@ -496,7 +518,7 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
496
518
  this.indent(() => {
497
519
  this.forEachEnumCase(e, "none", (name, jsonName, pos) => {
498
520
  const comma = pos === "first" || pos === "middle" ? "," : [];
499
- this.emitLine("\"", stringEscape(jsonName), "\": ", enumName, ".", name, comma);
521
+ this.emitLine('"', stringEscape(jsonName), '": ', enumName, ".", name, comma);
500
522
  });
501
523
  });
502
524
  this.emitLine("});");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "21.0.0",
3
+ "version": "21.0.1",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",