typia 4.0.0 → 4.0.1-dev.20230604
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/lib/programmers/ApplicationProgrammer.js +1 -1
- package/lib/programmers/internal/application_array.js +19 -41
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_definition.d.ts +1 -1
- package/lib/programmers/internal/application_definition.js +8 -8
- package/lib/programmers/internal/application_definition.js.map +1 -1
- package/lib/programmers/internal/application_native.js +3 -3
- package/lib/programmers/internal/application_object.js +4 -4
- package/lib/programmers/internal/application_schema.js +3 -3
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_tuple.js +8 -30
- package/lib/programmers/internal/application_tuple.js.map +1 -1
- package/lib/schemas/IJsonComponents.d.ts +1 -12
- package/lib/schemas/IJsonSchema.d.ts +1 -1
- package/package.json +1 -1
- package/src/IRandomGenerator.ts +34 -34
- package/src/factories/IdentifierFactory.ts +65 -65
- package/src/factories/MetadataCollection.ts +254 -254
- package/src/factories/MetadataFactory.ts +40 -40
- package/src/factories/MetadataTagFactory.ts +300 -300
- package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
- package/src/factories/internal/metadata/emplace_metadata_definition.ts +35 -35
- package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
- package/src/factories/internal/metadata/explore_metadata.ts +66 -66
- package/src/factories/internal/metadata/iterate_metadata.ts +77 -77
- package/src/factories/internal/metadata/iterate_metadata_array.ts +25 -25
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +130 -130
- package/src/factories/internal/metadata/iterate_metadata_definition.ts +30 -30
- package/src/factories/internal/metadata/iterate_metadata_object.ts +49 -49
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +68 -68
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
- package/src/factories/internal/metadata/iterate_metadata_union.ts +68 -68
- package/src/metadata/IMetadata.ts +27 -27
- package/src/metadata/IMetadataAlias.ts +12 -12
- package/src/metadata/IMetadataApplication.ts +7 -7
- package/src/metadata/IMetadataArray.ts +10 -10
- package/src/metadata/IMetadataCollection.ts +11 -11
- package/src/metadata/IMetadataDictionary.ts +14 -14
- package/src/metadata/IMetadataObject.ts +18 -18
- package/src/metadata/IMetadataProperty.ts +11 -11
- package/src/metadata/IMetadataTuple.ts +10 -10
- package/src/metadata/Metadata.ts +585 -585
- package/src/metadata/MetadataAlias.ts +61 -61
- package/src/metadata/MetadataArray.ts +52 -52
- package/src/metadata/MetadataObject.ts +114 -114
- package/src/metadata/MetadataProperty.ts +64 -64
- package/src/metadata/MetadataTuple.ts +53 -53
- package/src/programmers/ApplicationProgrammer.ts +55 -55
- package/src/programmers/AssertProgrammer.ts +291 -291
- package/src/programmers/CheckerProgrammer.ts +1182 -1182
- package/src/programmers/CloneProgrammer.ts +595 -595
- package/src/programmers/FeatureProgrammer.ts +495 -495
- package/src/programmers/IsProgrammer.ts +250 -250
- package/src/programmers/LiteralsProgrammer.ts +66 -66
- package/src/programmers/PruneProgrammer.ts +550 -550
- package/src/programmers/RandomProgrammer.ts +589 -589
- package/src/programmers/StringifyProgrammer.ts +990 -990
- package/src/programmers/ValidateProgrammer.ts +313 -313
- package/src/programmers/helpers/FunctionImporeter.ts +78 -78
- package/src/programmers/helpers/RandomJoiner.ts +173 -173
- package/src/programmers/helpers/UnionExplorer.ts +301 -301
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/helpers/disable_function_importer_declare.ts +26 -26
- package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
- package/src/programmers/internal/application_array.ts +30 -64
- package/src/programmers/internal/application_boolean.ts +15 -15
- package/src/programmers/internal/application_constant.ts +26 -26
- package/src/programmers/internal/application_default.ts +17 -17
- package/src/programmers/internal/application_definition.ts +45 -45
- package/src/programmers/internal/application_native.ts +39 -39
- package/src/programmers/internal/application_number.ts +74 -74
- package/src/programmers/internal/application_object.ts +167 -167
- package/src/programmers/internal/application_schema.ts +156 -164
- package/src/programmers/internal/application_tuple.ts +47 -77
- package/src/programmers/internal/check_union_array_like.ts +329 -329
- package/src/programmers/internal/feature_object_entries.ts +63 -63
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
- package/src/schemas/IJsonApplication.ts +8 -8
- package/src/schemas/IJsonComponents.ts +34 -45
- package/src/schemas/IJsonSchema.ts +134 -134
- package/src/transformers/CallExpressionTransformer.ts +179 -179
- package/src/transformers/FileTransformer.ts +47 -47
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +104 -104
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +53 -53
- package/src/utils/ArrayUtil.ts +45 -45
- package/src/utils/RandomGenerator.ts +81 -81
|
@@ -1,164 +1,156 @@
|
|
|
1
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
-
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
|
-
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
|
-
|
|
5
|
-
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
6
|
-
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
7
|
-
import { application_array } from "./application_array";
|
|
8
|
-
import { application_boolean } from "./application_boolean";
|
|
9
|
-
import { application_constant } from "./application_constant";
|
|
10
|
-
import {
|
|
11
|
-
import { application_native } from "./application_native";
|
|
12
|
-
import { application_number } from "./application_number";
|
|
13
|
-
import { application_object } from "./application_object";
|
|
14
|
-
import { application_string } from "./application_string";
|
|
15
|
-
import { application_templates } from "./application_templates";
|
|
16
|
-
import { application_tuple } from "./application_tuple";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
export const application_schema =
|
|
22
|
-
(options: ApplicationProgrammer.IOptions) =>
|
|
23
|
-
<BlockNever extends boolean>(blockNever: BlockNever) =>
|
|
24
|
-
(components: IJsonComponents) =>
|
|
25
|
-
(meta: Metadata) =>
|
|
26
|
-
(
|
|
27
|
-
attribute: IJsonSchema.IAttribute,
|
|
28
|
-
): BlockNever extends true ? IJsonSchema | null : IJsonSchema => {
|
|
29
|
-
// VULNERABLE CASE
|
|
30
|
-
if (meta.any === true)
|
|
31
|
-
return {
|
|
32
|
-
...attribute,
|
|
33
|
-
type: undefined,
|
|
34
|
-
};
|
|
35
|
-
else if (meta.nullable && meta.empty())
|
|
36
|
-
return { type: "null", ...attribute };
|
|
37
|
-
|
|
38
|
-
//----
|
|
39
|
-
// GATHER UNION SCHEMAS
|
|
40
|
-
//----
|
|
41
|
-
const union: IJsonSchema[] = [];
|
|
42
|
-
if (meta.nullable && options.purpose !== "swagger")
|
|
43
|
-
union.push({
|
|
44
|
-
...attribute,
|
|
45
|
-
type: "null",
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const insert =
|
|
49
|
-
meta.nullable && options.purpose === "swagger"
|
|
50
|
-
? (s: IJsonSchema) =>
|
|
51
|
-
union.push({
|
|
52
|
-
...s,
|
|
53
|
-
nullable: (s as IJsonSchema.ISignificant<any>).type
|
|
54
|
-
? true
|
|
55
|
-
: undefined,
|
|
56
|
-
} as IJsonSchema)
|
|
57
|
-
: (schema: IJsonSchema) => union.push(schema);
|
|
58
|
-
|
|
59
|
-
// toJSON() METHOD
|
|
60
|
-
if (meta.resolved !== null) {
|
|
61
|
-
const resolved = application_schema(options)(blockNever)(
|
|
62
|
-
components,
|
|
63
|
-
)(meta.resolved)(attribute);
|
|
64
|
-
if (resolved !== null) union.push(resolved);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ATOMIC TYPES
|
|
68
|
-
if (meta.templates.length && AtomicPredicator.template(meta))
|
|
69
|
-
insert(application_templates(meta)(attribute));
|
|
70
|
-
for (const constant of meta.constants)
|
|
71
|
-
if (constant.type === "bigint") throw new Error(NO_BIGINT);
|
|
72
|
-
else if (
|
|
73
|
-
(constant.type === "string" && meta.templates.length) ||
|
|
74
|
-
AtomicPredicator.constant(meta)(constant.type) === false
|
|
75
|
-
)
|
|
76
|
-
continue;
|
|
77
|
-
else insert(application_constant(constant)(attribute));
|
|
78
|
-
for (const type of meta.atomics)
|
|
79
|
-
if (type === "bigint") throw new Error(NO_BIGINT);
|
|
80
|
-
else if (AtomicPredicator.atomic(meta)(type) === false) continue;
|
|
81
|
-
else
|
|
82
|
-
insert(
|
|
83
|
-
type === "string"
|
|
84
|
-
? application_string(meta)(attribute)
|
|
85
|
-
: type === "boolean"
|
|
86
|
-
? application_boolean(attribute)
|
|
87
|
-
: application_number(attribute),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// ARRAY
|
|
91
|
-
for (const array of meta.arrays)
|
|
92
|
-
insert(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
for (const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
insert(
|
|
110
|
-
native
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
...attribute,
|
|
158
|
-
type: undefined,
|
|
159
|
-
};
|
|
160
|
-
else if (union.length === 1) return union[0]!;
|
|
161
|
-
return { oneOf: union, ...attribute };
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
|
|
1
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
+
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
|
+
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
|
+
|
|
5
|
+
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
6
|
+
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
7
|
+
import { application_array } from "./application_array";
|
|
8
|
+
import { application_boolean } from "./application_boolean";
|
|
9
|
+
import { application_constant } from "./application_constant";
|
|
10
|
+
import { application_alias } from "./application_definition";
|
|
11
|
+
import { application_native } from "./application_native";
|
|
12
|
+
import { application_number } from "./application_number";
|
|
13
|
+
import { application_object } from "./application_object";
|
|
14
|
+
import { application_string } from "./application_string";
|
|
15
|
+
import { application_templates } from "./application_templates";
|
|
16
|
+
import { application_tuple } from "./application_tuple";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export const application_schema =
|
|
22
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
23
|
+
<BlockNever extends boolean>(blockNever: BlockNever) =>
|
|
24
|
+
(components: IJsonComponents) =>
|
|
25
|
+
(meta: Metadata) =>
|
|
26
|
+
(
|
|
27
|
+
attribute: IJsonSchema.IAttribute,
|
|
28
|
+
): BlockNever extends true ? IJsonSchema | null : IJsonSchema => {
|
|
29
|
+
// VULNERABLE CASE
|
|
30
|
+
if (meta.any === true)
|
|
31
|
+
return {
|
|
32
|
+
...attribute,
|
|
33
|
+
type: undefined,
|
|
34
|
+
};
|
|
35
|
+
else if (meta.nullable && meta.empty())
|
|
36
|
+
return { type: "null", ...attribute };
|
|
37
|
+
|
|
38
|
+
//----
|
|
39
|
+
// GATHER UNION SCHEMAS
|
|
40
|
+
//----
|
|
41
|
+
const union: IJsonSchema[] = [];
|
|
42
|
+
if (meta.nullable && options.purpose !== "swagger")
|
|
43
|
+
union.push({
|
|
44
|
+
...attribute,
|
|
45
|
+
type: "null",
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const insert =
|
|
49
|
+
meta.nullable && options.purpose === "swagger"
|
|
50
|
+
? (s: IJsonSchema) =>
|
|
51
|
+
union.push({
|
|
52
|
+
...s,
|
|
53
|
+
nullable: (s as IJsonSchema.ISignificant<any>).type
|
|
54
|
+
? true
|
|
55
|
+
: undefined,
|
|
56
|
+
} as IJsonSchema)
|
|
57
|
+
: (schema: IJsonSchema) => union.push(schema);
|
|
58
|
+
|
|
59
|
+
// toJSON() METHOD
|
|
60
|
+
if (meta.resolved !== null) {
|
|
61
|
+
const resolved = application_schema(options)(blockNever)(
|
|
62
|
+
components,
|
|
63
|
+
)(meta.resolved)(attribute);
|
|
64
|
+
if (resolved !== null) union.push(resolved);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ATOMIC TYPES
|
|
68
|
+
if (meta.templates.length && AtomicPredicator.template(meta))
|
|
69
|
+
insert(application_templates(meta)(attribute));
|
|
70
|
+
for (const constant of meta.constants)
|
|
71
|
+
if (constant.type === "bigint") throw new Error(NO_BIGINT);
|
|
72
|
+
else if (
|
|
73
|
+
(constant.type === "string" && meta.templates.length) ||
|
|
74
|
+
AtomicPredicator.constant(meta)(constant.type) === false
|
|
75
|
+
)
|
|
76
|
+
continue;
|
|
77
|
+
else insert(application_constant(constant)(attribute));
|
|
78
|
+
for (const type of meta.atomics)
|
|
79
|
+
if (type === "bigint") throw new Error(NO_BIGINT);
|
|
80
|
+
else if (AtomicPredicator.atomic(meta)(type) === false) continue;
|
|
81
|
+
else
|
|
82
|
+
insert(
|
|
83
|
+
type === "string"
|
|
84
|
+
? application_string(meta)(attribute)
|
|
85
|
+
: type === "boolean"
|
|
86
|
+
? application_boolean(attribute)
|
|
87
|
+
: application_number(attribute),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// ARRAY
|
|
91
|
+
for (const array of meta.arrays)
|
|
92
|
+
insert(application_array(options)(components)(array)(attribute));
|
|
93
|
+
|
|
94
|
+
// TUPLE
|
|
95
|
+
for (const tuple of meta.tuples)
|
|
96
|
+
insert(application_tuple(options)(components)(tuple)(attribute));
|
|
97
|
+
|
|
98
|
+
// NATIVES
|
|
99
|
+
for (const native of meta.natives)
|
|
100
|
+
if (AtomicPredicator.native(native))
|
|
101
|
+
insert(
|
|
102
|
+
native === "String"
|
|
103
|
+
? application_string(meta)(attribute)
|
|
104
|
+
: native === "Boolean"
|
|
105
|
+
? application_boolean(attribute)
|
|
106
|
+
: application_number(attribute),
|
|
107
|
+
);
|
|
108
|
+
else
|
|
109
|
+
insert(
|
|
110
|
+
application_native(options)(components)(native)({
|
|
111
|
+
nullable: meta.nullable,
|
|
112
|
+
attribute,
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
if (meta.sets.length)
|
|
116
|
+
insert(
|
|
117
|
+
application_native(options)(components)(`Set`)({
|
|
118
|
+
nullable: meta.nullable,
|
|
119
|
+
attribute,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
if (meta.maps.length)
|
|
123
|
+
insert(
|
|
124
|
+
application_native(options)(components)(`Map`)({
|
|
125
|
+
nullable: meta.nullable,
|
|
126
|
+
attribute,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// OBJECT
|
|
131
|
+
for (const obj of meta.objects)
|
|
132
|
+
insert(application_object(options)(components)(obj)(meta.nullable));
|
|
133
|
+
|
|
134
|
+
// ALIASES
|
|
135
|
+
for (const alias of meta.aliases)
|
|
136
|
+
insert(
|
|
137
|
+
application_alias(options)(blockNever)(components)(alias)(
|
|
138
|
+
meta.nullable,
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
//----
|
|
143
|
+
// RETURNS
|
|
144
|
+
//----
|
|
145
|
+
if (union.length === 0)
|
|
146
|
+
return blockNever === true
|
|
147
|
+
? null!
|
|
148
|
+
: {
|
|
149
|
+
...attribute,
|
|
150
|
+
type: undefined,
|
|
151
|
+
};
|
|
152
|
+
else if (union.length === 1) return union[0]!;
|
|
153
|
+
return { oneOf: union, ...attribute };
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
|
|
@@ -1,77 +1,47 @@
|
|
|
1
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
-
import { MetadataTuple } from "../../metadata/MetadataTuple";
|
|
3
|
-
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
4
|
-
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
5
|
-
|
|
6
|
-
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
(
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"x-typia-tuple": schema,
|
|
49
|
-
};
|
|
50
|
-
return wrapper;
|
|
51
|
-
};
|
|
52
|
-
if (tuple.recursive === false) return generator();
|
|
53
|
-
|
|
54
|
-
// KEY
|
|
55
|
-
const key: string =
|
|
56
|
-
options.purpose === "ajv"
|
|
57
|
-
? tuple.name
|
|
58
|
-
: `${tuple.name}${nullable ? ".Nullable" : ""}`;
|
|
59
|
-
const $id: string = `${JSON_COMPONENTS_PREFIX}/tuples/${key}`;
|
|
60
|
-
|
|
61
|
-
// REFERENCE
|
|
62
|
-
if (components.tuples?.[key] === undefined) {
|
|
63
|
-
components.tuples ??= {};
|
|
64
|
-
components.tuples[key] = {} as any;
|
|
65
|
-
|
|
66
|
-
const repeated: IJsonComponents.IArray | IJsonComponents.ITuple = {
|
|
67
|
-
...generator(),
|
|
68
|
-
$id: options.purpose === "ajv" ? $id : undefined,
|
|
69
|
-
$recursiveAnchor: options.purpose === "ajv" || undefined,
|
|
70
|
-
};
|
|
71
|
-
components.tuples ??= {};
|
|
72
|
-
components.tuples[key] = repeated;
|
|
73
|
-
}
|
|
74
|
-
return options.purpose === "ajv" && tuple.recursive
|
|
75
|
-
? { ...attribute, $recursiveRef: $id }
|
|
76
|
-
: { ...attribute, $ref: $id };
|
|
77
|
-
};
|
|
1
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
+
import { MetadataTuple } from "../../metadata/MetadataTuple";
|
|
3
|
+
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
4
|
+
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
5
|
+
|
|
6
|
+
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
7
|
+
import { application_schema } from "./application_schema";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const application_tuple =
|
|
13
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
14
|
+
(components: IJsonComponents) =>
|
|
15
|
+
(tuple: MetadataTuple) =>
|
|
16
|
+
(
|
|
17
|
+
attribute: IJsonSchema.IAttribute,
|
|
18
|
+
): IJsonSchema.ITuple | IJsonSchema.IArray => {
|
|
19
|
+
const schema: IJsonSchema.ITuple = {
|
|
20
|
+
type: "array",
|
|
21
|
+
items: tuple.elements.map((meta, i) =>
|
|
22
|
+
application_schema(options)(false)(components)(
|
|
23
|
+
meta.rest ?? meta,
|
|
24
|
+
)({
|
|
25
|
+
...attribute,
|
|
26
|
+
"x-typia-rest":
|
|
27
|
+
i === tuple.elements.length - 1 && meta.rest !== null,
|
|
28
|
+
"x-typia-required": meta.required,
|
|
29
|
+
"x-typia-optional": meta.optional,
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
...attribute,
|
|
33
|
+
};
|
|
34
|
+
if (options.purpose === "ajv") return schema;
|
|
35
|
+
|
|
36
|
+
const wrapper: IJsonSchema.IArray = {
|
|
37
|
+
...schema,
|
|
38
|
+
items: application_schema(options)(false)(components)(
|
|
39
|
+
tuple.elements.reduce(
|
|
40
|
+
(x, y) => Metadata.merge(x.rest ?? x, y.rest ?? y),
|
|
41
|
+
Metadata.initialize(),
|
|
42
|
+
),
|
|
43
|
+
)(tuple.recursive ? {} : attribute),
|
|
44
|
+
"x-typia-tuple": schema,
|
|
45
|
+
};
|
|
46
|
+
return wrapper;
|
|
47
|
+
};
|