quicktype-core 23.2.3 → 23.2.5
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/RendererOptions/index.js +8 -9
- package/dist/RendererOptions/types.d.ts +12 -4
- package/dist/language/CSharp/CSharpRenderer.d.ts +1 -0
- package/dist/language/CSharp/CSharpRenderer.js +12 -0
- package/dist/language/CSharp/NewtonSoftCSharpRenderer.js +3 -2
- package/dist/language/CSharp/SystemTextJsonCSharpRenderer.js +3 -2
- package/package.json +1 -1
|
@@ -67,7 +67,7 @@ class BooleanOption extends Option {
|
|
|
67
67
|
super({
|
|
68
68
|
name,
|
|
69
69
|
kind,
|
|
70
|
-
|
|
70
|
+
optionType: "boolean",
|
|
71
71
|
description,
|
|
72
72
|
defaultValue,
|
|
73
73
|
});
|
|
@@ -110,29 +110,28 @@ class BooleanOption extends Option {
|
|
|
110
110
|
exports.BooleanOption = BooleanOption;
|
|
111
111
|
class StringOption extends Option {
|
|
112
112
|
constructor(name, description, typeLabel, defaultValue, kind = "primary") {
|
|
113
|
-
|
|
113
|
+
super({
|
|
114
114
|
name,
|
|
115
115
|
kind,
|
|
116
|
-
|
|
116
|
+
optionType: "string",
|
|
117
117
|
description,
|
|
118
118
|
typeLabel,
|
|
119
119
|
defaultValue,
|
|
120
|
-
};
|
|
121
|
-
super(definition);
|
|
120
|
+
});
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
exports.StringOption = StringOption;
|
|
125
124
|
class EnumOption extends Option {
|
|
126
125
|
constructor(name, description, values, defaultValue, kind = "primary") {
|
|
127
|
-
|
|
126
|
+
super({
|
|
128
127
|
name,
|
|
129
128
|
kind,
|
|
130
|
-
|
|
129
|
+
optionType: "enum",
|
|
131
130
|
description,
|
|
132
131
|
typeLabel: Object.keys(values).join("|"),
|
|
133
132
|
defaultValue,
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
values,
|
|
134
|
+
});
|
|
136
135
|
this._values = values;
|
|
137
136
|
}
|
|
138
137
|
getEnumValue(name) {
|
|
@@ -6,14 +6,22 @@ import type { EnumOption, Option } from "./index";
|
|
|
6
6
|
*/
|
|
7
7
|
export type OptionKind = "primary" | "secondary" | "cli";
|
|
8
8
|
export interface OptionDefinition<Name extends string = string, T = unknown> {
|
|
9
|
+
/** Option Name */
|
|
10
|
+
name: Name;
|
|
11
|
+
/** Option Alias for CLI */
|
|
9
12
|
alias?: string;
|
|
10
|
-
|
|
11
|
-
defaultValue?: T;
|
|
13
|
+
/** Option Description */
|
|
12
14
|
description: string;
|
|
15
|
+
/** Category of Option */
|
|
16
|
+
optionType: "string" | "boolean" | "enum";
|
|
17
|
+
/** Default Value for Option */
|
|
18
|
+
defaultValue?: T;
|
|
19
|
+
/** Enum only, map of possible keys and values */
|
|
20
|
+
values?: Record<string, unknown>;
|
|
21
|
+
/** Primary, Secondary, or CLI */
|
|
13
22
|
kind?: OptionKind;
|
|
23
|
+
/** Whether multiple CLI inputs are allowed for this option */
|
|
14
24
|
multiple?: boolean;
|
|
15
|
-
name: Name;
|
|
16
|
-
type: StringConstructor | BooleanConstructor;
|
|
17
25
|
typeLabel?: string;
|
|
18
26
|
}
|
|
19
27
|
export type OptionName<O> = O extends Option<infer Name, unknown> ? Name : never;
|
|
@@ -333,5 +333,17 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
333
333
|
}
|
|
334
334
|
this.emitDefaultFollowingComments();
|
|
335
335
|
}
|
|
336
|
+
emitDependencyUsings() {
|
|
337
|
+
let genericEmited = false;
|
|
338
|
+
let ensureGenericOnce = () => {
|
|
339
|
+
if (!genericEmited) {
|
|
340
|
+
this.emitUsing("System.Collections.Generic");
|
|
341
|
+
genericEmited = true;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
this.typeGraph.allTypesUnordered().forEach(_ => {
|
|
345
|
+
(0, TypeUtils_1.matchCompoundType)(_, _arrayType => this._csOptions.useList ? ensureGenericOnce() : undefined, _classType => { }, _mapType => ensureGenericOnce(), _objectType => { }, _unionType => { });
|
|
346
|
+
});
|
|
347
|
+
}
|
|
336
348
|
}
|
|
337
349
|
exports.CSharpRenderer = CSharpRenderer;
|
|
@@ -67,9 +67,10 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer_1.CSharpRenderer {
|
|
|
67
67
|
return [extensionsName];
|
|
68
68
|
}
|
|
69
69
|
emitUsings() {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (!this._needAttributes && !this._needHelpers) {
|
|
71
|
+
this.emitDependencyUsings();
|
|
72
72
|
return;
|
|
73
|
+
}
|
|
73
74
|
super.emitUsings();
|
|
74
75
|
this.ensureBlankLine();
|
|
75
76
|
for (const ns of [
|
|
@@ -68,9 +68,10 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer_1.CSharpRenderer {
|
|
|
68
68
|
return [extensionsName];
|
|
69
69
|
}
|
|
70
70
|
emitUsings() {
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (!this._needAttributes && !this._needHelpers) {
|
|
72
|
+
this.emitDependencyUsings();
|
|
73
73
|
return;
|
|
74
|
+
}
|
|
74
75
|
super.emitUsings();
|
|
75
76
|
this.ensureBlankLine();
|
|
76
77
|
for (const ns of [
|