quicktype-core 23.0.86 → 23.0.88

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.
@@ -20,6 +20,7 @@ export declare const rustOptions: {
20
20
  deriveDebug: BooleanOption;
21
21
  deriveClone: BooleanOption;
22
22
  derivePartialEq: BooleanOption;
23
+ skipSerializingNone: BooleanOption;
23
24
  edition2018: BooleanOption;
24
25
  leadingComments: BooleanOption;
25
26
  };
@@ -47,6 +48,7 @@ export declare class RustRenderer extends ConvenienceRenderer {
47
48
  private rustType;
48
49
  private breakCycle;
49
50
  private emitRenameAttribute;
51
+ private emitSkipSerializeNone;
50
52
  private get visibility();
51
53
  protected emitStructDefinition(c: ClassType, className: Name): void;
52
54
  protected emitBlock(line: Sourcelike, f: () => void): void;
@@ -6,6 +6,7 @@ const TargetLanguage_1 = require("../TargetLanguage");
6
6
  const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
7
7
  const Strings_1 = require("../support/Strings");
8
8
  const Naming_1 = require("../Naming");
9
+ const Type_1 = require("../Type");
9
10
  const TypeUtils_1 = require("../TypeUtils");
10
11
  const Source_1 = require("../Source");
11
12
  const Annotation_1 = require("../Annotation");
@@ -35,6 +36,7 @@ exports.rustOptions = {
35
36
  deriveDebug: new RendererOptions_1.BooleanOption("derive-debug", "Derive Debug impl", false),
36
37
  deriveClone: new RendererOptions_1.BooleanOption("derive-clone", "Derive Clone impl", false),
37
38
  derivePartialEq: new RendererOptions_1.BooleanOption("derive-partial-eq", "Derive PartialEq impl", false),
39
+ skipSerializingNone: new RendererOptions_1.BooleanOption("skip-serializing-none", "Skip serializing empty Option fields", false),
38
40
  edition2018: new RendererOptions_1.BooleanOption("edition-2018", "Edition 2018", true),
39
41
  leadingComments: new RendererOptions_1.BooleanOption("leading-comments", "Leading Comments", true)
40
42
  };
@@ -97,7 +99,8 @@ class RustTargetLanguage extends TargetLanguage_1.TargetLanguage {
97
99
  exports.rustOptions.deriveClone,
98
100
  exports.rustOptions.derivePartialEq,
99
101
  exports.rustOptions.edition2018,
100
- exports.rustOptions.leadingComments
102
+ exports.rustOptions.leadingComments,
103
+ exports.rustOptions.skipSerializingNone,
101
104
  ];
102
105
  }
103
106
  }
@@ -269,6 +272,13 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
269
272
  this.emitLine('#[serde(rename = "', escapedName, '")]');
270
273
  }
271
274
  }
275
+ emitSkipSerializeNone(t) {
276
+ if (t instanceof Type_1.UnionType) {
277
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(t);
278
+ if (nullable !== null)
279
+ this.emitLine('#[serde(skip_serializing_if = "Option::is_none")]');
280
+ }
281
+ }
272
282
  get visibility() {
273
283
  if (this._options.visibility === Visibility.Crate) {
274
284
  return "pub(crate) ";
@@ -296,6 +306,7 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
296
306
  const structBody = () => this.forEachClassProperty(c, blankLines, (name, jsonName, prop) => {
297
307
  this.emitDescription(this.descriptionForClassProperty(c, jsonName));
298
308
  this.emitRenameAttribute(name, jsonName, defaultStyle, preferedNamingStyle);
309
+ this._options.skipSerializingNone && this.emitSkipSerializeNone(prop.type);
299
310
  this.emitLine(this.visibility, name, ": ", this.breakCycle(prop.type, true), ",");
300
311
  });
301
312
  this.emitBlock(["pub struct ", className], structBody);
@@ -692,7 +692,7 @@ class SwiftRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
692
692
  if (this._options.protocol.equatable) {
693
693
  protocols.push("Equatable");
694
694
  }
695
- if (this._options.sendable && !this._options.mutableProperties && !this._options.objcSupport) {
695
+ if (this._options.sendable && (!this._options.mutableProperties || !isClass) && !this._options.objcSupport) {
696
696
  protocols.push("Sendable");
697
697
  }
698
698
  return protocols;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.0.86",
3
+ "version": "23.0.88",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",