quicktype-core 23.0.61 → 23.0.63

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.
@@ -11,7 +11,6 @@ const TargetLanguage_1 = require("../TargetLanguage");
11
11
  const RendererOptions_1 = require("../RendererOptions");
12
12
  const Annotation_1 = require("../Annotation");
13
13
  const Support_1 = require("../support/Support");
14
- const collection_utils_1 = require("collection-utils");
15
14
  exports.dartOptions = {
16
15
  nullSafety: new RendererOptions_1.BooleanOption("null-safety", "Null Safety", true),
17
16
  justTypes: new RendererOptions_1.BooleanOption("just-types", "Types only", false),
@@ -551,9 +550,18 @@ class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
551
550
  });
552
551
  }
553
552
  emitEnumDefinition(e, enumName) {
554
- const caseNames = Array.from(e.cases).map(c => this.nameForEnumCase(e, c));
555
553
  this.emitDescription(this.descriptionForType(e));
556
- this.emitLine("enum ", enumName, " { ", (0, collection_utils_1.arrayIntercalate)(", ", caseNames), " }");
554
+ this.emitLine("enum ", enumName, " {");
555
+ this.indent(() => {
556
+ this.forEachEnumCase(e, "none", (name, jsonName, pos) => {
557
+ const comma = pos === "first" || pos === "middle" ? "," : [];
558
+ if (this._options.useJsonAnnotation) {
559
+ this.emitLine('@JsonValue("', stringEscape(jsonName), '")');
560
+ }
561
+ this.emitLine(name, comma);
562
+ });
563
+ });
564
+ this.emitLine("}");
557
565
  if (this._options.justTypes)
558
566
  return;
559
567
  this.ensureBlankLine();
@@ -19,6 +19,7 @@ export declare const rustOptions: {
19
19
  visibility: EnumOption<Visibility>;
20
20
  deriveDebug: BooleanOption;
21
21
  deriveClone: BooleanOption;
22
+ derivePartialEq: BooleanOption;
22
23
  edition2018: BooleanOption;
23
24
  leadingComments: BooleanOption;
24
25
  };
@@ -34,6 +34,7 @@ exports.rustOptions = {
34
34
  ]),
35
35
  deriveDebug: new RendererOptions_1.BooleanOption("derive-debug", "Derive Debug impl", false),
36
36
  deriveClone: new RendererOptions_1.BooleanOption("derive-clone", "Derive Clone impl", false),
37
+ derivePartialEq: new RendererOptions_1.BooleanOption("derive-partial-eq", "Derive PartialEq impl", false),
37
38
  edition2018: new RendererOptions_1.BooleanOption("edition-2018", "Edition 2018", true),
38
39
  leadingComments: new RendererOptions_1.BooleanOption("leading-comments", "Leading Comments", true)
39
40
  };
@@ -94,6 +95,7 @@ class RustTargetLanguage extends TargetLanguage_1.TargetLanguage {
94
95
  exports.rustOptions.visibility,
95
96
  exports.rustOptions.deriveDebug,
96
97
  exports.rustOptions.deriveClone,
98
+ exports.rustOptions.derivePartialEq,
97
99
  exports.rustOptions.edition2018,
98
100
  exports.rustOptions.leadingComments
99
101
  ];
@@ -275,7 +277,7 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
275
277
  }
276
278
  emitStructDefinition(c, className) {
277
279
  this.emitDescription(this.descriptionForType(c));
278
- this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", this._options.deriveClone ? "Clone, " : "", "Serialize, Deserialize)]");
280
+ this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", this._options.deriveClone ? "Clone, " : "", this._options.derivePartialEq ? "PartialEq, " : "", "Serialize, Deserialize)]");
279
281
  // List the possible naming styles for every class property
280
282
  const propertiesNamingStyles = {};
281
283
  this.forEachClassProperty(c, "none", (_name, jsonName, _prop) => {
@@ -306,7 +308,7 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
306
308
  return;
307
309
  }
308
310
  this.emitDescription(this.descriptionForType(u));
309
- this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", this._options.deriveClone ? "Clone, " : "", "Serialize, Deserialize)]");
311
+ this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", this._options.deriveClone ? "Clone, " : "", this._options.derivePartialEq ? "PartialEq, " : "", "Serialize, Deserialize)]");
310
312
  this.emitLine("#[serde(untagged)]");
311
313
  const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
312
314
  const blankLines = this._options.density === Density.Dense ? "none" : "interposing";
@@ -317,7 +319,7 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
317
319
  }
318
320
  emitEnumDefinition(e, enumName) {
319
321
  this.emitDescription(this.descriptionForType(e));
320
- this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", this._options.deriveClone ? "Clone, " : "", "Serialize, Deserialize)]");
322
+ this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", this._options.deriveClone ? "Clone, " : "", this._options.derivePartialEq ? "PartialEq, " : "", "Serialize, Deserialize)]");
321
323
  // List the possible naming styles for every enum case
322
324
  const enumCasesNamingStyles = {};
323
325
  this.forEachEnumCase(e, "none", (_name, jsonName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.0.61",
3
+ "version": "23.0.63",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",