quicktype 16.0.38 → 16.0.40
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/cli/index.js +1 -4
- package/dist/quicktype-core/Transformers.js +1 -3
- package/dist/quicktype-core/input/JSONSchemaInput.js +2 -8
- package/dist/quicktype-core/language/All.js +1 -1
- package/dist/quicktype-core/language/CPlusPlus.js +134 -53
- package/dist/quicktype-core/language/CSharp.js +37 -30
- package/dist/quicktype-core/language/Elm.js +4 -1
- package/dist/quicktype-core/language/Golang.js +12 -8
- package/dist/quicktype-core/language/Haskell.js +15 -15
- package/dist/quicktype-core/language/Java.js +51 -54
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +11 -11
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +65 -1196
- package/dist/quicktype-core/language/Kotlin.js +20 -5
- package/dist/quicktype-core/language/Pike.js +9 -2
- package/dist/quicktype-core/language/Rust.js +11 -11
- package/dist/quicktype-core/language/TypeScriptFlow.js +1 -1
- package/package.json +1 -2
|
@@ -20,7 +20,12 @@ var Framework;
|
|
|
20
20
|
Framework[Framework["KotlinX"] = 3] = "KotlinX";
|
|
21
21
|
})(Framework = exports.Framework || (exports.Framework = {}));
|
|
22
22
|
exports.kotlinOptions = {
|
|
23
|
-
framework: new RendererOptions_1.EnumOption("framework", "Serialization framework", [
|
|
23
|
+
framework: new RendererOptions_1.EnumOption("framework", "Serialization framework", [
|
|
24
|
+
["just-types", Framework.None],
|
|
25
|
+
["jackson", Framework.Jackson],
|
|
26
|
+
["klaxon", Framework.Klaxon],
|
|
27
|
+
["kotlinx", Framework.KotlinX]
|
|
28
|
+
], "klaxon"),
|
|
24
29
|
acronymStyle: Acronyms_1.acronymOption(Acronyms_1.AcronymStyleOptions.Pascal),
|
|
25
30
|
packageName: new RendererOptions_1.StringOption("package", "Package", "PACKAGE", "quicktype")
|
|
26
31
|
};
|
|
@@ -292,10 +297,16 @@ class KotlinRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
292
297
|
{
|
|
293
298
|
let table = [];
|
|
294
299
|
this.forEachUnionMember(u, nonNulls, "none", null, (name, t) => {
|
|
295
|
-
table.push([
|
|
300
|
+
table.push([
|
|
301
|
+
["class ", name, "(val value: ", this.kotlinType(t), ")"],
|
|
302
|
+
[" : ", unionName, "()"]
|
|
303
|
+
]);
|
|
296
304
|
});
|
|
297
305
|
if (maybeNull !== null) {
|
|
298
|
-
table.push([
|
|
306
|
+
table.push([
|
|
307
|
+
["class ", this.nameForUnionMember(u, maybeNull), "()"],
|
|
308
|
+
[" : ", unionName, "()"]
|
|
309
|
+
]);
|
|
299
310
|
}
|
|
300
311
|
this.emitTable(table);
|
|
301
312
|
}
|
|
@@ -772,7 +783,11 @@ class KotlinXRenderer extends KotlinRenderer {
|
|
|
772
783
|
const table = [];
|
|
773
784
|
table.push(["// val ", "json", " = Json { allowStructuredMapKeys = true }"]);
|
|
774
785
|
this.forEachTopLevel("none", (_, name) => {
|
|
775
|
-
table.push([
|
|
786
|
+
table.push([
|
|
787
|
+
"// val ",
|
|
788
|
+
Source_1.modifySource(Strings_1.camelCase, name),
|
|
789
|
+
` = json.parse(${this.sourcelikeToString(name)}.serializer(), jsonString)`
|
|
790
|
+
]);
|
|
776
791
|
});
|
|
777
792
|
this.emitTable(table);
|
|
778
793
|
}
|
|
@@ -796,7 +811,7 @@ class KotlinXRenderer extends KotlinRenderer {
|
|
|
796
811
|
const escapedName = stringEscape(jsonName);
|
|
797
812
|
const namesDiffer = this.sourcelikeToString(propName) !== escapedName;
|
|
798
813
|
if (namesDiffer) {
|
|
799
|
-
return [
|
|
814
|
+
return ['@SerialName("', escapedName, '")'];
|
|
800
815
|
}
|
|
801
816
|
return undefined;
|
|
802
817
|
}
|
|
@@ -151,7 +151,10 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
151
151
|
this.emitBlock([e.kind, " ", enumName], () => {
|
|
152
152
|
let table = [];
|
|
153
153
|
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
154
|
-
table.push([
|
|
154
|
+
table.push([
|
|
155
|
+
[name, ' = "', Strings_1.stringEscape(jsonName), '", '],
|
|
156
|
+
['// json: "', jsonName, '"']
|
|
157
|
+
]);
|
|
155
158
|
});
|
|
156
159
|
this.emitTable(table);
|
|
157
160
|
});
|
|
@@ -192,7 +195,11 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
192
195
|
let table = [];
|
|
193
196
|
this.forEachClassProperty(c, "none", (name, jsonName, p) => {
|
|
194
197
|
const pikeType = this.sourceFor(p.type).source;
|
|
195
|
-
table.push([
|
|
198
|
+
table.push([
|
|
199
|
+
[pikeType, " "],
|
|
200
|
+
[name, "; "],
|
|
201
|
+
['// json: "', jsonName, '"']
|
|
202
|
+
]);
|
|
196
203
|
});
|
|
197
204
|
this.emitTable(table);
|
|
198
205
|
}
|
|
@@ -271,17 +271,17 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
const topLevelName = Support_1.defined(collection_utils_1.mapFirst(this.topLevels)).getCombinedName();
|
|
274
|
-
this.emitMultiline(`// Example code that deserializes and serializes the model.
|
|
275
|
-
// extern crate serde;
|
|
276
|
-
// #[macro_use]
|
|
277
|
-
// extern crate serde_derive;
|
|
278
|
-
// extern crate serde_json;
|
|
279
|
-
//
|
|
280
|
-
// use generated_module::${topLevelName};
|
|
281
|
-
//
|
|
282
|
-
// fn main() {
|
|
283
|
-
// let json = r#"{"answer": 42}"#;
|
|
284
|
-
// let model: ${topLevelName} = serde_json::from_str(&json).unwrap();
|
|
274
|
+
this.emitMultiline(`// Example code that deserializes and serializes the model.
|
|
275
|
+
// extern crate serde;
|
|
276
|
+
// #[macro_use]
|
|
277
|
+
// extern crate serde_derive;
|
|
278
|
+
// extern crate serde_json;
|
|
279
|
+
//
|
|
280
|
+
// use generated_module::${topLevelName};
|
|
281
|
+
//
|
|
282
|
+
// fn main() {
|
|
283
|
+
// let json = r#"{"answer": 42}"#;
|
|
284
|
+
// let model: ${topLevelName} = serde_json::from_str(&json).unwrap();
|
|
285
285
|
// }`);
|
|
286
286
|
}
|
|
287
287
|
emitSourceStructure() {
|
|
@@ -215,7 +215,7 @@ class TypeScriptRenderer extends TypeScriptFlowBaseRenderer {
|
|
|
215
215
|
this.emitDescription(this.descriptionForType(e));
|
|
216
216
|
if (this._tsFlowOptions.preferUnions) {
|
|
217
217
|
let items = "";
|
|
218
|
-
e.cases.forEach(
|
|
218
|
+
e.cases.forEach(item => {
|
|
219
219
|
if (items === "") {
|
|
220
220
|
items += `"${Strings_1.utf16StringEscape(item)}"`;
|
|
221
221
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quicktype",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.40",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/cli/index.js",
|
|
6
6
|
"types": "dist/cli/index.d.ts",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"test": "script/test",
|
|
13
13
|
"start": "script/watch",
|
|
14
14
|
"pkg": "script/make-pkgs.sh",
|
|
15
|
-
"format": "prettier --write **/*.ts",
|
|
16
15
|
"tslint": "tslint --project src/cli --exclude 'src/__tests__/**' --exclude 'src/quicktype-core/input/io/get-stream/**'",
|
|
17
16
|
"clean": "rm -rf dist node_modules *~",
|
|
18
17
|
"publish": "script/publish.sh"
|