quicktype-core 23.0.42 → 23.0.43
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.
- package/dist/language/Golang.d.ts +1 -0
- package/dist/language/Golang.js +14 -3
- package/package.json +1 -1
package/dist/language/Golang.js
CHANGED
|
@@ -15,14 +15,21 @@ exports.goOptions = {
|
|
|
15
15
|
justTypes: new RendererOptions_1.BooleanOption("just-types", "Plain types only", false),
|
|
16
16
|
justTypesAndPackage: new RendererOptions_1.BooleanOption("just-types-and-package", "Plain types with package only", false),
|
|
17
17
|
packageName: new RendererOptions_1.StringOption("package", "Generated package name", "NAME", "main"),
|
|
18
|
-
multiFileOutput: new RendererOptions_1.BooleanOption("multi-file-output", "Renders each top-level object in its own Go file", false)
|
|
18
|
+
multiFileOutput: new RendererOptions_1.BooleanOption("multi-file-output", "Renders each top-level object in its own Go file", false),
|
|
19
|
+
fieldTags: new RendererOptions_1.StringOption("field-tags", "list of tags which should be generated for fields", "TAGS", "json")
|
|
19
20
|
};
|
|
20
21
|
class GoTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
21
22
|
constructor() {
|
|
22
23
|
super("Go", ["go", "golang"], "go");
|
|
23
24
|
}
|
|
24
25
|
getOptions() {
|
|
25
|
-
return [
|
|
26
|
+
return [
|
|
27
|
+
exports.goOptions.justTypes,
|
|
28
|
+
exports.goOptions.packageName,
|
|
29
|
+
exports.goOptions.multiFileOutput,
|
|
30
|
+
exports.goOptions.justTypesAndPackage,
|
|
31
|
+
exports.goOptions.fieldTags
|
|
32
|
+
];
|
|
26
33
|
}
|
|
27
34
|
get supportsUnionsWithBothNumberTypes() {
|
|
28
35
|
return true;
|
|
@@ -189,10 +196,14 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
189
196
|
const goType = this.propertyGoType(p);
|
|
190
197
|
const omitEmpty = canOmitEmpty(p) ? ",omitempty" : [];
|
|
191
198
|
docStrings.forEach(doc => columns.push([doc]));
|
|
199
|
+
const tags = this._options.fieldTags
|
|
200
|
+
.split(",")
|
|
201
|
+
.map(tag => tag + ':"' + (0, Strings_1.stringEscape)(jsonName) + omitEmpty + '"')
|
|
202
|
+
.join(" ");
|
|
192
203
|
columns.push([
|
|
193
204
|
[name, " "],
|
|
194
205
|
[goType, " "],
|
|
195
|
-
[
|
|
206
|
+
["`", tags, "`"]
|
|
196
207
|
]);
|
|
197
208
|
});
|
|
198
209
|
this.emitDescription(this.descriptionForType(c));
|