quicktype-core 6.0.71 → 6.1.0
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.
|
@@ -5,6 +5,7 @@ import { Sourcelike } from "../Source";
|
|
|
5
5
|
import { TargetLanguage } from "../TargetLanguage";
|
|
6
6
|
import { ArrayType, ClassType, EnumType, MapType, ObjectType, PrimitiveType, Type, UnionType } from "../Type";
|
|
7
7
|
import { RenderContext } from "../Renderer";
|
|
8
|
+
import { AcronymStyleOptions } from "../support/Acronyms";
|
|
8
9
|
export declare enum Framework {
|
|
9
10
|
None = 0,
|
|
10
11
|
Jackson = 1,
|
|
@@ -13,6 +14,7 @@ export declare enum Framework {
|
|
|
13
14
|
}
|
|
14
15
|
export declare const kotlinOptions: {
|
|
15
16
|
framework: EnumOption<Framework>;
|
|
17
|
+
acronymStyle: EnumOption<AcronymStyleOptions>;
|
|
16
18
|
packageName: StringOption;
|
|
17
19
|
};
|
|
18
20
|
export declare class KotlinTargetLanguage extends TargetLanguage {
|
package/dist/language/Kotlin.js
CHANGED
|
@@ -11,6 +11,7 @@ const Support_1 = require("../support/Support");
|
|
|
11
11
|
const TargetLanguage_1 = require("../TargetLanguage");
|
|
12
12
|
const Type_1 = require("../Type");
|
|
13
13
|
const TypeUtils_1 = require("../TypeUtils");
|
|
14
|
+
const Acronyms_1 = require("../support/Acronyms");
|
|
14
15
|
var Framework;
|
|
15
16
|
(function (Framework) {
|
|
16
17
|
Framework[Framework["None"] = 0] = "None";
|
|
@@ -20,6 +21,7 @@ var Framework;
|
|
|
20
21
|
})(Framework = exports.Framework || (exports.Framework = {}));
|
|
21
22
|
exports.kotlinOptions = {
|
|
22
23
|
framework: new RendererOptions_1.EnumOption("framework", "Serialization framework", [["just-types", Framework.None], ["jackson", Framework.Jackson], ["klaxon", Framework.Klaxon], ["kotlinx", Framework.KotlinX]], "klaxon"),
|
|
24
|
+
acronymStyle: Acronyms_1.acronymOption(Acronyms_1.AcronymStyleOptions.Pascal),
|
|
23
25
|
packageName: new RendererOptions_1.StringOption("package", "Package", "PACKAGE", "quicktype")
|
|
24
26
|
};
|
|
25
27
|
class KotlinTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
@@ -27,7 +29,7 @@ class KotlinTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
27
29
|
super("Kotlin", ["kotlin"], "kt");
|
|
28
30
|
}
|
|
29
31
|
getOptions() {
|
|
30
|
-
return [exports.kotlinOptions.framework, exports.kotlinOptions.packageName];
|
|
32
|
+
return [exports.kotlinOptions.framework, exports.kotlinOptions.acronymStyle, exports.kotlinOptions.packageName];
|
|
31
33
|
}
|
|
32
34
|
get supportsOptionalClassProperties() {
|
|
33
35
|
return true;
|
|
@@ -110,9 +112,9 @@ function isStartCharacter(codePoint) {
|
|
|
110
112
|
return isPartCharacter(codePoint) && !Strings_1.isDigit(codePoint);
|
|
111
113
|
}
|
|
112
114
|
const legalizeName = Strings_1.legalizeCharacters(isPartCharacter);
|
|
113
|
-
function kotlinNameStyle(isUpper, original) {
|
|
115
|
+
function kotlinNameStyle(isUpper, original, acronymsStyle = Strings_1.allUpperWordStyle) {
|
|
114
116
|
const words = Strings_1.splitIntoWords(original);
|
|
115
|
-
return Strings_1.combineWords(words, legalizeName, isUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, isUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle,
|
|
117
|
+
return Strings_1.combineWords(words, legalizeName, isUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, isUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, acronymsStyle, "", isStartCharacter);
|
|
116
118
|
}
|
|
117
119
|
function unicodeEscape(codePoint) {
|
|
118
120
|
return "\\u" + Strings_1.intToHex(codePoint, 4);
|
|
@@ -122,8 +124,6 @@ function stringEscape(s) {
|
|
|
122
124
|
// "$this" is a template string in Kotlin so we have to escape $
|
|
123
125
|
return _stringEscape(s).replace(/\$/g, "\\$");
|
|
124
126
|
}
|
|
125
|
-
const upperNamingFunction = Naming_1.funPrefixNamer("upper", s => kotlinNameStyle(true, s));
|
|
126
|
-
const lowerNamingFunction = Naming_1.funPrefixNamer("lower", s => kotlinNameStyle(false, s));
|
|
127
127
|
class KotlinRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
128
128
|
constructor(targetLanguage, renderContext, _kotlinOptions) {
|
|
129
129
|
super(targetLanguage, renderContext);
|
|
@@ -145,16 +145,16 @@ class KotlinRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
145
145
|
return kotlinNameStyle(true, rawName);
|
|
146
146
|
}
|
|
147
147
|
makeNamedTypeNamer() {
|
|
148
|
-
return
|
|
148
|
+
return Naming_1.funPrefixNamer("upper", s => kotlinNameStyle(true, s, Acronyms_1.acronymStyle(this._kotlinOptions.acronymStyle)));
|
|
149
149
|
}
|
|
150
150
|
namerForObjectProperty() {
|
|
151
|
-
return
|
|
151
|
+
return Naming_1.funPrefixNamer("lower", s => kotlinNameStyle(false, s, Acronyms_1.acronymStyle(this._kotlinOptions.acronymStyle)));
|
|
152
152
|
}
|
|
153
153
|
makeUnionMemberNamer() {
|
|
154
154
|
return Naming_1.funPrefixNamer("upper", s => kotlinNameStyle(true, s) + "Value");
|
|
155
155
|
}
|
|
156
156
|
makeEnumCaseNamer() {
|
|
157
|
-
return
|
|
157
|
+
return Naming_1.funPrefixNamer("upper", s => kotlinNameStyle(true, s, Acronyms_1.acronymStyle(this._kotlinOptions.acronymStyle)));
|
|
158
158
|
}
|
|
159
159
|
emitDescriptionBlock(lines) {
|
|
160
160
|
this.emitCommentLines(lines, " * ", "/**", " */");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quicktype-core",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "The quicktype engine as a library",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"fs": false
|
|
46
46
|
},
|
|
47
47
|
"config": {
|
|
48
|
-
"commit": "
|
|
48
|
+
"commit": "7c1db5f51ccd8f66319792238d3ad58c52fc3d8c"
|
|
49
49
|
}
|
|
50
50
|
}
|