quicktype-core 23.0.102 → 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.
|
@@ -54,7 +54,14 @@ class StringTypes {
|
|
|
54
54
|
else if (other.cases !== undefined) {
|
|
55
55
|
const thisCases = cases;
|
|
56
56
|
const otherCases = other.cases;
|
|
57
|
-
|
|
57
|
+
const intersects = (0, collection_utils_1.setIntersect)(thisCases.keys(), new Set(otherCases.keys()));
|
|
58
|
+
const entries = intersects.size > 0 ? intersects.entries() : new Set(thisCases.keys()).entries();
|
|
59
|
+
cases = (0, collection_utils_1.mapMap)(entries, k => {
|
|
60
|
+
var _a;
|
|
61
|
+
const thisValue = (0, Support_1.defined)(thisCases.get(k));
|
|
62
|
+
const otherValue = (_a = otherCases.get(k)) !== null && _a !== void 0 ? _a : Math.min();
|
|
63
|
+
return Math.min(thisValue, otherValue);
|
|
64
|
+
});
|
|
58
65
|
}
|
|
59
66
|
transformations = (0, collection_utils_1.setIntersect)(transformations, other.transformations);
|
|
60
67
|
}
|
package/dist/language/Golang.js
CHANGED
|
@@ -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",
|
|
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
|
|
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(",")
|