quicktype-core 23.0.170 → 23.0.172
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/Run.d.ts +4 -4
- package/dist/Type.d.ts +1 -1
- package/dist/input/io/NodeIO.js +3 -5
- package/dist/language/Python/PythonRenderer.js +9 -4
- package/dist/language/Python/language.d.ts +1 -0
- package/dist/language/Python/language.js +8 -2
- package/dist/language/Ruby/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/Run.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const inferenceFlagsObject: {
|
|
|
35
35
|
description: string;
|
|
36
36
|
negationDescription: string;
|
|
37
37
|
explanation: string;
|
|
38
|
-
stringType: "
|
|
38
|
+
stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
|
|
39
39
|
order: number;
|
|
40
40
|
};
|
|
41
41
|
/** Whether to assume that JSON strings that look like dates are dates */
|
|
@@ -43,7 +43,7 @@ export declare const inferenceFlagsObject: {
|
|
|
43
43
|
description: string;
|
|
44
44
|
negationDescription: string;
|
|
45
45
|
explanation: string;
|
|
46
|
-
stringType: "
|
|
46
|
+
stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
|
|
47
47
|
order: number;
|
|
48
48
|
};
|
|
49
49
|
/** Whether to convert stringified integers to integers */
|
|
@@ -51,7 +51,7 @@ export declare const inferenceFlagsObject: {
|
|
|
51
51
|
description: string;
|
|
52
52
|
negationDescription: string;
|
|
53
53
|
explanation: string;
|
|
54
|
-
stringType: "
|
|
54
|
+
stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
|
|
55
55
|
order: number;
|
|
56
56
|
};
|
|
57
57
|
/** Whether to convert stringified booleans to boolean values */
|
|
@@ -59,7 +59,7 @@ export declare const inferenceFlagsObject: {
|
|
|
59
59
|
description: string;
|
|
60
60
|
negationDescription: string;
|
|
61
61
|
explanation: string;
|
|
62
|
-
stringType: "
|
|
62
|
+
stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
|
|
63
63
|
order: number;
|
|
64
64
|
};
|
|
65
65
|
/** Combine similar classes. This doesn't apply to classes from a schema, only from inference. */
|
package/dist/Type.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export type PrimitiveTypeKind = PrimitiveNonStringTypeKind | PrimitiveStringType
|
|
|
55
55
|
export type NamedTypeKind = "class" | "enum" | "union";
|
|
56
56
|
export type TypeKind = PrimitiveTypeKind | NamedTypeKind | "array" | "object" | "map" | "intersection";
|
|
57
57
|
export type ObjectTypeKind = "object" | "map" | "class";
|
|
58
|
-
export declare const transformedStringTypeKinds: ReadonlySet<"
|
|
58
|
+
export declare const transformedStringTypeKinds: ReadonlySet<"date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string">;
|
|
59
59
|
export declare function isPrimitiveStringTypeKind(kind: string): kind is PrimitiveStringTypeKind;
|
|
60
60
|
export declare function targetTypeKindForTransformedStringTypeKind(kind: PrimitiveStringTypeKind): PrimitiveNonStringTypeKind | undefined;
|
|
61
61
|
export declare function isNumberTypeKind(kind: TypeKind): kind is "integer" | "double";
|
package/dist/input/io/NodeIO.js
CHANGED
|
@@ -40,15 +40,13 @@ exports.readFromFileOrURL = exports.readableFromFileOrURL = void 0;
|
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
41
|
const ts_necessities_1 = require("@glideapps/ts-necessities");
|
|
42
42
|
const browser_or_node_1 = require("browser-or-node");
|
|
43
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
44
43
|
const is_url_1 = __importDefault(require("is-url"));
|
|
45
44
|
const Messages_1 = require("../../Messages");
|
|
46
45
|
const Support_1 = require("../../support/Support");
|
|
47
46
|
const get_stream_1 = require("./get-stream");
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
const fetch = process.env.CI ? cross_fetch_1.default : (_a = global.fetch) !== null && _a !== void 0 ? _a : cross_fetch_1.default;
|
|
47
|
+
// We need to use cross-fetch in CI or if fetch is not available in the global scope
|
|
48
|
+
// We use a dynamic import to avoid punycode deprecated dependency warning on node > 20
|
|
49
|
+
const fetch = process.env.CI ? require("cross-fetch").default : (_a = global.fetch) !== null && _a !== void 0 ? _a : require("cross-fetch").default;
|
|
52
50
|
function parseHeaders(httpHeaders) {
|
|
53
51
|
if (!Array.isArray(httpHeaders)) {
|
|
54
52
|
return {};
|
|
@@ -99,7 +99,9 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
99
99
|
const memberTypes = Array.from(nonNulls).map(m => this.pythonType(m));
|
|
100
100
|
if (hasNull !== null) {
|
|
101
101
|
let rest = [];
|
|
102
|
-
if (!this.getAlphabetizeProperties() &&
|
|
102
|
+
if (!this.getAlphabetizeProperties() &&
|
|
103
|
+
(this.pyOptions.features.dataClasses || this.pyOptions.pydanticBaseModel) &&
|
|
104
|
+
_isRootTypeDef) {
|
|
103
105
|
// Only push "= None" if this is a root level type def
|
|
104
106
|
// otherwise we may get type defs like List[Optional[int] = None]
|
|
105
107
|
// which are invalid
|
|
@@ -134,6 +136,9 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
134
136
|
}
|
|
135
137
|
declarationLine(t) {
|
|
136
138
|
if (t instanceof Type_1.ClassType) {
|
|
139
|
+
if (this.pyOptions.pydanticBaseModel) {
|
|
140
|
+
return ["class ", this.nameForNamedType(t), "(", this.withImport("pydantic", "BaseModel"), "):"];
|
|
141
|
+
}
|
|
137
142
|
return ["class ", this.nameForNamedType(t), ":"];
|
|
138
143
|
}
|
|
139
144
|
if (t instanceof Type_1.EnumType) {
|
|
@@ -149,7 +154,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
149
154
|
this.declaredTypes.add(t);
|
|
150
155
|
}
|
|
151
156
|
emitClassMembers(t) {
|
|
152
|
-
if (this.pyOptions.features.dataClasses)
|
|
157
|
+
if (this.pyOptions.features.dataClasses || this.pyOptions.pydanticBaseModel)
|
|
153
158
|
return;
|
|
154
159
|
const args = [];
|
|
155
160
|
this.forEachClassProperty(t, "none", (name, _, cp) => {
|
|
@@ -179,7 +184,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
179
184
|
return this.typeHint(" -> ", this.withTyping(type));
|
|
180
185
|
}
|
|
181
186
|
sortClassProperties(properties, propertyNames) {
|
|
182
|
-
if (this.pyOptions.features.dataClasses) {
|
|
187
|
+
if (this.pyOptions.features.dataClasses || this.pyOptions.pydanticBaseModel) {
|
|
183
188
|
return (0, collection_utils_1.mapSortBy)(properties, (p) => {
|
|
184
189
|
return (p.type instanceof Type_1.UnionType && (0, TypeUtils_1.nullableFromUnion)(p.type) != null) || p.isOptional ? 1 : 0;
|
|
185
190
|
});
|
|
@@ -189,7 +194,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
196
|
emitClass(t) {
|
|
192
|
-
if (this.pyOptions.features.dataClasses) {
|
|
197
|
+
if (this.pyOptions.features.dataClasses && !this.pyOptions.pydanticBaseModel) {
|
|
193
198
|
this.emitLine("@", this.withImport("dataclasses", "dataclass"));
|
|
194
199
|
}
|
|
195
200
|
this.declareType(t, () => {
|
|
@@ -13,6 +13,7 @@ export declare const pythonOptions: {
|
|
|
13
13
|
features: EnumOption<PythonFeatures>;
|
|
14
14
|
justTypes: BooleanOption;
|
|
15
15
|
nicePropertyNames: BooleanOption;
|
|
16
|
+
pydanticBaseModel: BooleanOption;
|
|
16
17
|
};
|
|
17
18
|
export declare class PythonTargetLanguage extends TargetLanguage {
|
|
18
19
|
protected getOptions(): Array<Option<FixMeOptionsAnyType>>;
|
|
@@ -14,11 +14,17 @@ exports.pythonOptions = {
|
|
|
14
14
|
["3.7", { typeHints: true, dataClasses: true }]
|
|
15
15
|
], "3.6"),
|
|
16
16
|
justTypes: new RendererOptions_1.BooleanOption("just-types", "Classes only", false),
|
|
17
|
-
nicePropertyNames: new RendererOptions_1.BooleanOption("nice-property-names", "Transform property names to be Pythonic", true)
|
|
17
|
+
nicePropertyNames: new RendererOptions_1.BooleanOption("nice-property-names", "Transform property names to be Pythonic", true),
|
|
18
|
+
pydanticBaseModel: new RendererOptions_1.BooleanOption("pydantic-base-model", "Uses pydantic BaseModel", false)
|
|
18
19
|
};
|
|
19
20
|
class PythonTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
20
21
|
getOptions() {
|
|
21
|
-
return [
|
|
22
|
+
return [
|
|
23
|
+
exports.pythonOptions.features,
|
|
24
|
+
exports.pythonOptions.justTypes,
|
|
25
|
+
exports.pythonOptions.nicePropertyNames,
|
|
26
|
+
exports.pythonOptions.pydanticBaseModel
|
|
27
|
+
];
|
|
22
28
|
}
|
|
23
29
|
get stringTypeMapping() {
|
|
24
30
|
const mapping = new Map();
|
|
@@ -3,7 +3,7 @@ export declare enum Strictness {
|
|
|
3
3
|
Coercible = "Coercible::",
|
|
4
4
|
None = "Types::"
|
|
5
5
|
}
|
|
6
|
-
export declare const forbiddenForObjectProperties: ("
|
|
6
|
+
export declare const forbiddenForObjectProperties: ("default" | "false" | "next" | "alias" | "type" | "clone" | "then" | "class" | "enum" | "true" | "end" | "and" | "break" | "case" | "do" | "else" | "for" | "if" | "module" | "not" | "or" | "return" | "try" | "while" | "optional" | "begin" | "def" | "elsif" | "ensure" | "extend" | "in" | "nil" | "rescue" | "self" | "super" | "unless" | "until" | "when" | "with" | "yield" | "method" | "options" | "hash" | "__ENCODING__" | "__FILE__" | "__LINE__" | "BEGIN" | "defined?" | "END" | "redo" | "retry" | "undef" | "__id__" | "__send__" | "define_singleton_method" | "display" | "dup" | "enum_for" | "freeze" | "inspect" | "instance_eval" | "instance_exec" | "instance_variable_defined?" | "instance_variable_get" | "instance_variable_set" | "instance_variables" | "itself" | "methods" | "object_id" | "private_methods" | "protected_methods" | "public_method" | "public_methods" | "public_send" | "remove_instance_variable" | "send" | "singleton_class" | "singleton_method" | "singleton_methods" | "taint" | "tap" | "to_enum" | "to_s" | "trust" | "untaint" | "untrust" | "call" | "constrained_type" | "constrained?" | "constrained" | "constructor" | "gem" | "meta" | "pristine" | "rule" | "safe" | "to_ast" | "to_json")[];
|
|
7
7
|
export declare const stringEscape: (s: string) => string;
|
|
8
8
|
export declare function simpleNameStyle(original: string, uppercase: boolean): string;
|
|
9
9
|
export declare function memberNameStyle(original: string): string;
|