quicktype-core 23.0.103 → 23.0.104

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.
@@ -17,7 +17,7 @@ exports.goOptions = {
17
17
  packageName: new RendererOptions_1.StringOption("package", "Generated package name", "NAME", "main"),
18
18
  multiFileOutput: new RendererOptions_1.BooleanOption("multi-file-output", "Renders each top-level object in its own Go file", false),
19
19
  fieldTags: new RendererOptions_1.StringOption("field-tags", "list of tags which should be generated for fields", "TAGS", "json"),
20
- omitEmpty: new RendererOptions_1.BooleanOption("omit-empty", "If set, all non-required objects will be tagged with ,omitempty", false)
20
+ omitEmpty: new RendererOptions_1.BooleanOption("omit-empty", 'If set, all non-required objects will be tagged with ",omitempty"', false)
21
21
  };
22
22
  class GoTargetLanguage extends TargetLanguage_1.TargetLanguage {
23
23
  constructor() {
@@ -26,9 +26,9 @@ class GoTargetLanguage extends TargetLanguage_1.TargetLanguage {
26
26
  getOptions() {
27
27
  return [
28
28
  exports.goOptions.justTypes,
29
+ exports.goOptions.justTypesAndPackage,
29
30
  exports.goOptions.packageName,
30
31
  exports.goOptions.multiFileOutput,
31
- exports.goOptions.justTypesAndPackage,
32
32
  exports.goOptions.fieldTags,
33
33
  exports.goOptions.omitEmpty
34
34
  ];
@@ -64,9 +64,11 @@ function isValueType(t) {
64
64
  const kind = t.kind;
65
65
  return primitiveValueTypeKinds.indexOf(kind) >= 0 || kind === "class" || kind === "enum" || kind === "date-time";
66
66
  }
67
- function canOmitEmpty(cp) {
67
+ function canOmitEmpty(cp, omitEmptyOption) {
68
68
  if (!cp.isOptional)
69
69
  return false;
70
+ if (omitEmptyOption)
71
+ return true;
70
72
  const t = cp.type;
71
73
  return ["union", "null", "any"].indexOf(t.kind) < 0;
72
74
  }
@@ -206,7 +208,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
206
208
  const description = this.descriptionForClassProperty(c, jsonName);
207
209
  const docStrings = description !== undefined && description.length > 0 ? description.map(d => "// " + d) : [];
208
210
  const goType = this.propertyGoType(p);
209
- const omitEmpty = canOmitEmpty(p) || this._options.omitEmpty ? ",omitempty" : [];
211
+ const omitEmpty = canOmitEmpty(p, this._options.omitEmpty) ? ",omitempty" : [];
210
212
  docStrings.forEach(doc => columns.push([doc]));
211
213
  const tags = this._options.fieldTags
212
214
  .split(",")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.0.103",
3
+ "version": "23.0.104",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",