quicktype-core 23.3.10 → 23.3.12

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.
@@ -1258,7 +1258,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1258
1258
  onFirst = false;
1259
1259
  });
1260
1260
  }
1261
- this.emitLine('else { throw std::runtime_error("Input JSON does not conform to schema!"); }');
1261
+ this.emitLine('else { throw std::runtime_error("Cannot deserialize to enumeration \\"', enumName, '\\""); }');
1262
1262
  });
1263
1263
  this.ensureBlankLine();
1264
1264
  this.emitBlock([
@@ -251,7 +251,10 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
251
251
  (0, Support_1.defined)(this._enumValues.get(enumType)),
252
252
  ".map[",
253
253
  dynamic,
254
- this._options.nullSafety ? "]!" : "]",
254
+ this._options.nullSafety &&
255
+ (!isNullable || this._options.requiredProperties)
256
+ ? "]!"
257
+ : "]",
255
258
  ];
256
259
  }, (unionType) => {
257
260
  const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
@@ -221,14 +221,11 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
221
221
  });
222
222
  this.emitLine("}, ", ...args, ");");
223
223
  }, (_classType) => this.emitLine(...lhs, ...args, "->to(); ", "/*class*/"), (mapType) => {
224
- this.emitBlock(["function to($my): stdClass"], () => {
225
- this.emitLine("$out = new stdClass();");
226
- this.emitBlock(["foreach ($my as $k => $v)"], () => {
227
- this.phpToObjConvert(className, mapType.values, ["$my->$k = "], ["$v"]);
228
- });
229
- this.emitLine("return $out;");
224
+ this.emitLine("$out = new stdClass();");
225
+ this.emitBlock(["foreach (", ...args, " as $k => $v)"], () => {
226
+ this.phpToObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
230
227
  });
231
- this.emitLine("return to(", ...args, ");");
228
+ this.emitLine("return $out;");
232
229
  }, (enumType) => this.emitLine(...lhs, this.nameForNamedType(enumType), "::to(", ...args, "); ", "/*enum*/"), (unionType) => {
233
230
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
234
231
  if (nullable !== null) {
@@ -267,14 +264,11 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
267
264
  });
268
265
  this.emitLine("}, ", ...args, ");");
269
266
  }, (classType) => this.emitLine(...lhs, this.nameForNamedType(classType), "::from(", ...args, "); ", "/*class*/"), (mapType) => {
270
- this.emitBlock(["function from($my): stdClass"], () => {
271
- this.emitLine("$out = new stdClass();");
272
- this.emitBlock(["foreach ($my as $k => $v)"], () => {
273
- this.phpFromObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
274
- });
275
- this.emitLine("return $out;");
267
+ this.emitLine("$out = new stdClass();");
268
+ this.emitBlock(["foreach (", ...args, " as $k => $v)"], () => {
269
+ this.phpFromObjConvert(className, mapType.values, ["$out->$k = "], ["$v"]);
276
270
  });
277
- this.emitLine("return from(", ...args, ");");
271
+ this.emitLine("return $out;");
278
272
  }, (enumType) => this.emitLine(...lhs, this.nameForNamedType(enumType), "::from(", ...args, "); ", "/*enum*/"), (unionType) => {
279
273
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
280
274
  if (nullable !== null) {
@@ -308,12 +302,9 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
308
302
  });
309
303
  this.emitLine("); /* ", "" + idx, ":", args, "*/");
310
304
  }, (classType) => this.emitLine(...lhs, this.nameForNamedType(classType), "::sample()", suffix, " /*", "" + idx, ":", args, "*/"), (mapType) => {
311
- this.emitBlock(["function sample(): stdClass"], () => {
312
- this.emitLine("$out = new stdClass();");
313
- this.phpSampleConvert(className, mapType.values, ["$out->{'", className, "'} = "], args, idx, ";");
314
- this.emitLine("return $out;");
315
- });
316
- this.emitLine("return sample();");
305
+ this.emitLine("$out = new stdClass();");
306
+ this.phpSampleConvert(className, mapType.values, ["$out->{'", className, "'} = "], args, idx, ";");
307
+ this.emitLine("return $out;");
317
308
  }, (enumType) => this.emitLine(...lhs, this.nameForNamedType(enumType), "::sample()", suffix, " /*enum*/"), (unionType) => {
318
309
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
319
310
  if (nullable !== null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.3.10",
3
+ "version": "23.3.12",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",