typia 6.7.2 → 6.8.0-dev.20240811
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/internal/application_bigint.d.ts +1 -0
- package/lib/programmers/internal/application_bigint.js +14 -0
- package/lib/programmers/internal/application_bigint.js.map +1 -0
- package/lib/programmers/internal/application_v30_schema.js +10 -12
- package/lib/programmers/internal/application_v30_schema.js.map +1 -1
- package/lib/programmers/internal/application_v31_constant.js +3 -1
- package/lib/programmers/internal/application_v31_constant.js.map +1 -1
- package/lib/programmers/internal/application_v31_schema.js +10 -12
- package/lib/programmers/internal/application_v31_schema.js.map +1 -1
- package/lib/tags/Constant.d.ts +2 -2
- package/lib/tags/Default.d.ts +5 -1
- package/lib/tags/ExclusiveMaximum.d.ts +9 -5
- package/lib/tags/ExclusiveMinimum.d.ts +9 -5
- package/lib/tags/JsonSchemaPlugin.d.ts +1 -1
- package/lib/tags/Maximum.d.ts +8 -5
- package/lib/tags/Minimum.d.ts +8 -5
- package/lib/tags/MultipleOf.d.ts +7 -4
- package/package.json +2 -2
- package/src/factories/CommentFactory.ts +79 -79
- package/src/factories/MetadataCollection.ts +274 -274
- package/src/factories/MetadataFactory.ts +272 -272
- package/src/factories/StatementFactory.ts +74 -74
- package/src/factories/TypeFactory.ts +118 -118
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +42 -42
- package/src/factories/internal/metadata/emplace_metadata_object.ts +176 -176
- package/src/factories/internal/metadata/iterate_metadata.ts +94 -94
- package/src/factories/internal/metadata/iterate_metadata_array.ts +63 -63
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +76 -76
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +213 -213
- package/src/factories/internal/metadata/iterate_metadata_map.ts +50 -50
- package/src/factories/internal/metadata/iterate_metadata_native.ts +220 -220
- package/src/factories/internal/metadata/iterate_metadata_object.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_set.ts +41 -41
- package/src/factories/internal/metadata/iterate_metadata_template.ts +44 -44
- package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
- package/src/programmers/internal/application_bigint.ts +25 -0
- package/src/programmers/internal/application_v30_alias.ts +52 -52
- package/src/programmers/internal/application_v30_object.ts +149 -149
- package/src/programmers/internal/application_v30_schema.ts +162 -159
- package/src/programmers/internal/application_v30_tuple.ts +33 -33
- package/src/programmers/internal/application_v31_constant.ts +4 -1
- package/src/programmers/internal/application_v31_schema.ts +159 -157
- package/src/programmers/json/JsonApplicationProgrammer.ts +82 -82
- package/src/schemas/metadata/IMetadataConstantValue.ts +11 -11
- package/src/schemas/metadata/IMetadataTemplate.ts +7 -7
- package/src/tags/Constant.ts +2 -2
- package/src/tags/Default.ts +7 -3
- package/src/tags/ExclusiveMaximum.ts +12 -6
- package/src/tags/ExclusiveMinimum.ts +12 -6
- package/src/tags/JsonSchemaPlugin.ts +1 -1
- package/src/tags/Maximum.ts +9 -8
- package/src/tags/Minimum.ts +9 -8
- package/src/tags/MultipleOf.ts +9 -8
- package/src/tags/Type.ts +32 -32
- package/src/transformers/FileTransformer.ts +91 -91
- package/src/transformers/features/CreateRandomTransformer.ts +40 -40
- package/src/transformers/features/RandomTransformer.ts +44 -44
- package/src/transformers/features/json/JsonApplicationTransformer.ts +124 -124
- package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
- package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
- package/src/transformers/features/reflect/ReflectMetadataTransformer.ts +62 -62
|
@@ -1,157 +1,159 @@
|
|
|
1
|
-
import { OpenApi } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
|
|
5
|
-
|
|
6
|
-
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
7
|
-
import { application_array } from "./application_array";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
(
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (a.type === "bigint")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
|
|
5
|
+
|
|
6
|
+
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
7
|
+
import { application_array } from "./application_array";
|
|
8
|
+
import { application_bigint } from "./application_bigint";
|
|
9
|
+
import { application_boolean } from "./application_boolean";
|
|
10
|
+
import { application_escaped } from "./application_escaped";
|
|
11
|
+
import { application_number } from "./application_number";
|
|
12
|
+
import { application_string } from "./application_string";
|
|
13
|
+
import { application_templates } from "./application_templates";
|
|
14
|
+
import { application_union_discriminator } from "./application_union_discriminator";
|
|
15
|
+
import { application_v31_alias } from "./application_v31_alias";
|
|
16
|
+
import { application_v31_constant } from "./application_v31_constant";
|
|
17
|
+
import { application_v31_native } from "./application_v31_native";
|
|
18
|
+
import { application_v31_object } from "./application_v31_object";
|
|
19
|
+
import { application_v31_tuple } from "./application_v31_tuple";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const application_v31_schema =
|
|
25
|
+
<BlockNever extends boolean>(blockNever: BlockNever) =>
|
|
26
|
+
(components: OpenApi.IComponents) =>
|
|
27
|
+
(attribute: OpenApi.IJsonSchema.__IAttribute) =>
|
|
28
|
+
(
|
|
29
|
+
meta: Metadata,
|
|
30
|
+
): BlockNever extends true
|
|
31
|
+
? OpenApi.IJsonSchema | null
|
|
32
|
+
: OpenApi.IJsonSchema => {
|
|
33
|
+
if (meta.any === true)
|
|
34
|
+
return {
|
|
35
|
+
...attribute,
|
|
36
|
+
type: undefined,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//----
|
|
40
|
+
// GATHER UNION SCHEMAS
|
|
41
|
+
//----
|
|
42
|
+
const union: OpenApi.IJsonSchema[] = [];
|
|
43
|
+
const insert = (schema: OpenApi.IJsonSchema) => union.push(schema);
|
|
44
|
+
|
|
45
|
+
// NULLABLE
|
|
46
|
+
if (meta.nullable === true)
|
|
47
|
+
insert({
|
|
48
|
+
type: "null",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// toJSON() METHOD
|
|
52
|
+
if (meta.escaped !== null)
|
|
53
|
+
application_escaped(application_v31_schema(false)(components)({}))(
|
|
54
|
+
meta.escaped,
|
|
55
|
+
).forEach(insert as any);
|
|
56
|
+
|
|
57
|
+
// ATOMIC TYPES
|
|
58
|
+
if (meta.templates.length && AtomicPredicator.template(meta))
|
|
59
|
+
application_templates(meta).map(insert as any);
|
|
60
|
+
for (const constant of meta.constants)
|
|
61
|
+
if (AtomicPredicator.constant(meta)(constant.type) === false) continue;
|
|
62
|
+
else application_v31_constant(constant).map(insert);
|
|
63
|
+
for (const a of meta.atomics)
|
|
64
|
+
if (a.type === "boolean") application_boolean(a).forEach(insert as any);
|
|
65
|
+
else if (a.type === "bigint")
|
|
66
|
+
application_bigint(a).forEach(insert as any);
|
|
67
|
+
else if (a.type === "number")
|
|
68
|
+
application_number(a).forEach(insert as any);
|
|
69
|
+
else if (a.type === "string")
|
|
70
|
+
application_string(a).forEach(insert as any);
|
|
71
|
+
|
|
72
|
+
// ARRAY
|
|
73
|
+
for (const array of meta.arrays)
|
|
74
|
+
application_array(application_v31_schema(false)(components)({}))(
|
|
75
|
+
components,
|
|
76
|
+
)(array).forEach(insert as any);
|
|
77
|
+
|
|
78
|
+
// TUPLE
|
|
79
|
+
for (const tuple of meta.tuples)
|
|
80
|
+
insert(
|
|
81
|
+
application_v31_tuple(application_v31_schema(false)(components)({}))(
|
|
82
|
+
tuple,
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// NATIVES
|
|
87
|
+
for (const native of meta.natives)
|
|
88
|
+
if (AtomicPredicator.native(native)) {
|
|
89
|
+
const type: string = native.toLowerCase();
|
|
90
|
+
if (meta.atomics.some((a) => a.type === type)) continue;
|
|
91
|
+
else if (type === "boolean")
|
|
92
|
+
insert(
|
|
93
|
+
application_boolean(
|
|
94
|
+
MetadataAtomic.create({
|
|
95
|
+
type: "boolean",
|
|
96
|
+
tags: [],
|
|
97
|
+
}),
|
|
98
|
+
)[0]! as any,
|
|
99
|
+
);
|
|
100
|
+
else if (type === "bigint")
|
|
101
|
+
insert(
|
|
102
|
+
application_bigint(
|
|
103
|
+
MetadataAtomic.create({
|
|
104
|
+
type: "bigint",
|
|
105
|
+
tags: [],
|
|
106
|
+
}),
|
|
107
|
+
)[0]! as any,
|
|
108
|
+
);
|
|
109
|
+
else if (type === "number")
|
|
110
|
+
insert(
|
|
111
|
+
application_number(
|
|
112
|
+
MetadataAtomic.create({
|
|
113
|
+
type: "number",
|
|
114
|
+
tags: [],
|
|
115
|
+
}),
|
|
116
|
+
)[0]! as any,
|
|
117
|
+
);
|
|
118
|
+
else if (type === "string")
|
|
119
|
+
insert(
|
|
120
|
+
application_string(
|
|
121
|
+
MetadataAtomic.create({
|
|
122
|
+
type: "string",
|
|
123
|
+
tags: [],
|
|
124
|
+
}),
|
|
125
|
+
)[0]! as any,
|
|
126
|
+
);
|
|
127
|
+
} else insert(application_v31_native(components)(native));
|
|
128
|
+
if (meta.sets.length) insert(application_v31_native(components)(`Set`));
|
|
129
|
+
if (meta.maps.length) insert(application_v31_native(components)(`Map`));
|
|
130
|
+
|
|
131
|
+
// OBJECT
|
|
132
|
+
for (const obj of meta.objects)
|
|
133
|
+
insert(application_v31_object(components)(obj));
|
|
134
|
+
|
|
135
|
+
// ALIASES
|
|
136
|
+
for (const alias of meta.aliases)
|
|
137
|
+
insert(application_v31_alias(blockNever)(components)(alias));
|
|
138
|
+
|
|
139
|
+
//----
|
|
140
|
+
// RETURNS
|
|
141
|
+
//----
|
|
142
|
+
if (union.length === 0 && blockNever === true) return null!;
|
|
143
|
+
const schema: OpenApi.IJsonSchema =
|
|
144
|
+
union.length === 0
|
|
145
|
+
? { type: undefined }
|
|
146
|
+
: union.length === 1
|
|
147
|
+
? union[0]!
|
|
148
|
+
: {
|
|
149
|
+
oneOf: union,
|
|
150
|
+
discriminator: application_union_discriminator(meta),
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
...schema,
|
|
154
|
+
...attribute,
|
|
155
|
+
title: attribute.title ?? schema.title,
|
|
156
|
+
description: attribute.description ?? schema.description,
|
|
157
|
+
deprecated: attribute.deprecated ?? schema.deprecated,
|
|
158
|
+
};
|
|
159
|
+
};
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { OpenApi, OpenApiV3 } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { IJsonApplication } from "../../schemas/json/IJsonApplication";
|
|
4
|
-
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
5
|
-
|
|
6
|
-
import { TransformerError } from "../../transformers/TransformerError";
|
|
7
|
-
|
|
8
|
-
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
9
|
-
import { application_v30_schema } from "../internal/application_v30_schema";
|
|
10
|
-
import { application_v31_schema } from "../internal/application_v31_schema";
|
|
11
|
-
|
|
12
|
-
export namespace JsonApplicationProgrammer {
|
|
13
|
-
export const validate = (meta: Metadata) => {
|
|
14
|
-
const output: string[] = [];
|
|
15
|
-
if (
|
|
16
|
-
meta.atomics.some((a) => a.type === "bigint") ||
|
|
17
|
-
meta.constants.some((c) => c.type === "bigint")
|
|
18
|
-
)
|
|
19
|
-
output.push("JSON schema does not support bigint type.");
|
|
20
|
-
if (
|
|
21
|
-
meta.tuples.some((t) =>
|
|
22
|
-
t.type.elements.some((e) => e.isRequired() === false),
|
|
23
|
-
) ||
|
|
24
|
-
meta.arrays.some((a) => a.type.value.isRequired() === false)
|
|
25
|
-
)
|
|
26
|
-
output.push("JSON schema does not support undefined type in array.");
|
|
27
|
-
if (meta.maps.length) output.push("JSON schema does not support Map type.");
|
|
28
|
-
if (meta.sets.length) output.push("JSON schema does not support Set type.");
|
|
29
|
-
for (const native of meta.natives)
|
|
30
|
-
if (
|
|
31
|
-
AtomicPredicator.native(native) === false &&
|
|
32
|
-
native !== "Date" &&
|
|
33
|
-
native !== "Blob" &&
|
|
34
|
-
native !== "File"
|
|
35
|
-
)
|
|
36
|
-
output.push(`JSON schema does not support ${native} type.`);
|
|
37
|
-
return output;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const write = <Version extends "3.0" | "3.1">(version: Version) =>
|
|
41
|
-
version === "3.0" ? v30 : v31;
|
|
42
|
-
|
|
43
|
-
const v30 = (metadatas: Array<Metadata>): IJsonApplication<"3.0"> => {
|
|
44
|
-
const components: OpenApiV3.IComponents = {};
|
|
45
|
-
const generator = (meta: Metadata): OpenApiV3.IJsonSchema | null =>
|
|
46
|
-
application_v30_schema(true)(components)({})(meta);
|
|
47
|
-
return {
|
|
48
|
-
version: "3.0",
|
|
49
|
-
components,
|
|
50
|
-
schemas: metadatas.map((meta, i) => {
|
|
51
|
-
const schema: OpenApiV3.IJsonSchema | null = generator(meta);
|
|
52
|
-
if (schema === null)
|
|
53
|
-
throw new TransformerError({
|
|
54
|
-
code: "typia.json.application",
|
|
55
|
-
message: `invalid type on argument - (${meta.getName()}, ${i})`,
|
|
56
|
-
});
|
|
57
|
-
return schema;
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const v31 = (metadatas: Array<Metadata>): IJsonApplication<"3.1"> => {
|
|
63
|
-
const components: OpenApi.IComponents = {
|
|
64
|
-
schemas: {},
|
|
65
|
-
};
|
|
66
|
-
const generator = (meta: Metadata): OpenApi.IJsonSchema | null =>
|
|
67
|
-
application_v31_schema(true)(components)({})(meta);
|
|
68
|
-
return {
|
|
69
|
-
version: "3.1",
|
|
70
|
-
components,
|
|
71
|
-
schemas: metadatas.map((meta, i) => {
|
|
72
|
-
const schema: OpenApi.IJsonSchema | null = generator(meta);
|
|
73
|
-
if (schema === null)
|
|
74
|
-
throw new TransformerError({
|
|
75
|
-
code: "typia.json.application",
|
|
76
|
-
message: `invalid type on argument - (${meta.getName()}, ${i})`,
|
|
77
|
-
});
|
|
78
|
-
return schema;
|
|
79
|
-
}),
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
}
|
|
1
|
+
import { OpenApi, OpenApiV3 } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { IJsonApplication } from "../../schemas/json/IJsonApplication";
|
|
4
|
+
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
5
|
+
|
|
6
|
+
import { TransformerError } from "../../transformers/TransformerError";
|
|
7
|
+
|
|
8
|
+
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
9
|
+
import { application_v30_schema } from "../internal/application_v30_schema";
|
|
10
|
+
import { application_v31_schema } from "../internal/application_v31_schema";
|
|
11
|
+
|
|
12
|
+
export namespace JsonApplicationProgrammer {
|
|
13
|
+
export const validate = (meta: Metadata) => {
|
|
14
|
+
const output: string[] = [];
|
|
15
|
+
if (
|
|
16
|
+
meta.atomics.some((a) => a.type === "bigint") ||
|
|
17
|
+
meta.constants.some((c) => c.type === "bigint")
|
|
18
|
+
)
|
|
19
|
+
output.push("JSON schema does not support bigint type.");
|
|
20
|
+
if (
|
|
21
|
+
meta.tuples.some((t) =>
|
|
22
|
+
t.type.elements.some((e) => e.isRequired() === false),
|
|
23
|
+
) ||
|
|
24
|
+
meta.arrays.some((a) => a.type.value.isRequired() === false)
|
|
25
|
+
)
|
|
26
|
+
output.push("JSON schema does not support undefined type in array.");
|
|
27
|
+
if (meta.maps.length) output.push("JSON schema does not support Map type.");
|
|
28
|
+
if (meta.sets.length) output.push("JSON schema does not support Set type.");
|
|
29
|
+
for (const native of meta.natives)
|
|
30
|
+
if (
|
|
31
|
+
AtomicPredicator.native(native) === false &&
|
|
32
|
+
native !== "Date" &&
|
|
33
|
+
native !== "Blob" &&
|
|
34
|
+
native !== "File"
|
|
35
|
+
)
|
|
36
|
+
output.push(`JSON schema does not support ${native} type.`);
|
|
37
|
+
return output;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const write = <Version extends "3.0" | "3.1">(version: Version) =>
|
|
41
|
+
version === "3.0" ? v30 : v31;
|
|
42
|
+
|
|
43
|
+
const v30 = (metadatas: Array<Metadata>): IJsonApplication<"3.0"> => {
|
|
44
|
+
const components: OpenApiV3.IComponents = {};
|
|
45
|
+
const generator = (meta: Metadata): OpenApiV3.IJsonSchema | null =>
|
|
46
|
+
application_v30_schema(true)(components)({})(meta);
|
|
47
|
+
return {
|
|
48
|
+
version: "3.0",
|
|
49
|
+
components,
|
|
50
|
+
schemas: metadatas.map((meta, i) => {
|
|
51
|
+
const schema: OpenApiV3.IJsonSchema | null = generator(meta);
|
|
52
|
+
if (schema === null)
|
|
53
|
+
throw new TransformerError({
|
|
54
|
+
code: "typia.json.application",
|
|
55
|
+
message: `invalid type on argument - (${meta.getName()}, ${i})`,
|
|
56
|
+
});
|
|
57
|
+
return schema;
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const v31 = (metadatas: Array<Metadata>): IJsonApplication<"3.1"> => {
|
|
63
|
+
const components: OpenApi.IComponents = {
|
|
64
|
+
schemas: {},
|
|
65
|
+
};
|
|
66
|
+
const generator = (meta: Metadata): OpenApi.IJsonSchema | null =>
|
|
67
|
+
application_v31_schema(true)(components)({})(meta);
|
|
68
|
+
return {
|
|
69
|
+
version: "3.1",
|
|
70
|
+
components,
|
|
71
|
+
schemas: metadatas.map((meta, i) => {
|
|
72
|
+
const schema: OpenApi.IJsonSchema | null = generator(meta);
|
|
73
|
+
if (schema === null)
|
|
74
|
+
throw new TransformerError({
|
|
75
|
+
code: "typia.json.application",
|
|
76
|
+
message: `invalid type on argument - (${meta.getName()}, ${i})`,
|
|
77
|
+
});
|
|
78
|
+
return schema;
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Atomic } from "../../typings/Atomic";
|
|
2
|
-
|
|
3
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
-
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
5
|
-
|
|
6
|
-
export interface IMetadataConstantValue<T extends Atomic.Type> {
|
|
7
|
-
value: T;
|
|
8
|
-
tags?: IMetadataTypeTag[][] | undefined;
|
|
9
|
-
description?: string | null;
|
|
10
|
-
jsDocTags?: IJsDocTagInfo[];
|
|
11
|
-
}
|
|
1
|
+
import { Atomic } from "../../typings/Atomic";
|
|
2
|
+
|
|
3
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
+
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
5
|
+
|
|
6
|
+
export interface IMetadataConstantValue<T extends Atomic.Type> {
|
|
7
|
+
value: T;
|
|
8
|
+
tags?: IMetadataTypeTag[][] | undefined;
|
|
9
|
+
description?: string | null;
|
|
10
|
+
jsDocTags?: IJsDocTagInfo[];
|
|
11
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IMetadata } from "./IMetadata";
|
|
2
|
-
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
3
|
-
|
|
4
|
-
export interface IMetadataTemplate {
|
|
5
|
-
row: IMetadata[];
|
|
6
|
-
tags?: IMetadataTypeTag[][] | undefined;
|
|
7
|
-
}
|
|
1
|
+
import { IMetadata } from "./IMetadata";
|
|
2
|
+
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
3
|
+
|
|
4
|
+
export interface IMetadataTemplate {
|
|
5
|
+
row: IMetadata[];
|
|
6
|
+
tags?: IMetadataTypeTag[][] | undefined;
|
|
7
|
+
}
|
package/src/tags/Constant.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { TagBase } from "./TagBase";
|
|
2
2
|
|
|
3
3
|
export type Constant<
|
|
4
|
-
Value extends boolean | number | string,
|
|
4
|
+
Value extends boolean | number | string | bigint,
|
|
5
5
|
Content extends {
|
|
6
6
|
title?: string | undefined;
|
|
7
7
|
description?: string | undefined;
|
|
8
8
|
},
|
|
9
9
|
> = Value &
|
|
10
10
|
TagBase<{
|
|
11
|
-
target: "string" | "boolean" | "number";
|
|
11
|
+
target: "string" | "boolean" | "number" | "bigint";
|
|
12
12
|
kind: "constant";
|
|
13
13
|
value: undefined;
|
|
14
14
|
schema: Content;
|
package/src/tags/Default.ts
CHANGED
|
@@ -12,7 +12,11 @@ export type Default<Value extends boolean | bigint | number | string> =
|
|
|
12
12
|
kind: "default";
|
|
13
13
|
value: Value;
|
|
14
14
|
exclusive: true;
|
|
15
|
-
schema:
|
|
16
|
-
default: Value
|
|
17
|
-
|
|
15
|
+
schema: Value extends bigint
|
|
16
|
+
? { default: Numeric<Value> }
|
|
17
|
+
: { default: Value };
|
|
18
18
|
}>;
|
|
19
|
+
|
|
20
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
21
|
+
? N
|
|
22
|
+
: never;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { TagBase } from "./TagBase";
|
|
2
2
|
|
|
3
3
|
export type ExclusiveMaximum<Value extends number | bigint> = TagBase<{
|
|
4
|
-
target: Value extends
|
|
4
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
5
5
|
kind: "exclusiveMaximum";
|
|
6
6
|
value: Value;
|
|
7
|
-
validate: `$input < ${
|
|
7
|
+
validate: `$input < ${Cast<Value>}`;
|
|
8
8
|
exclusive: ["exclusiveMaximum", "maximum"];
|
|
9
|
-
schema: Value extends
|
|
9
|
+
schema: Value extends bigint
|
|
10
10
|
? {
|
|
11
11
|
exclusiveMaximum: true;
|
|
12
|
-
maximum: Value
|
|
12
|
+
maximum: Numeric<Value>;
|
|
13
13
|
}
|
|
14
|
-
:
|
|
14
|
+
: {
|
|
15
|
+
exclusiveMaximum: true;
|
|
16
|
+
maximum: Value;
|
|
17
|
+
};
|
|
15
18
|
}>;
|
|
16
19
|
|
|
17
|
-
type
|
|
20
|
+
type Cast<Value extends number | bigint> = Value extends number
|
|
18
21
|
? Value
|
|
19
22
|
: `BigInt(${Value})`;
|
|
23
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
24
|
+
? N
|
|
25
|
+
: never;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { TagBase } from "./TagBase";
|
|
2
2
|
|
|
3
3
|
export type ExclusiveMinimum<Value extends number | bigint> = TagBase<{
|
|
4
|
-
target: Value extends
|
|
4
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
5
5
|
kind: "exclusiveMinimum";
|
|
6
6
|
value: Value;
|
|
7
|
-
validate: `${
|
|
7
|
+
validate: `${Cast<Value>} < $input`;
|
|
8
8
|
exclusive: ["exclusiveMinimum", "minimum"];
|
|
9
|
-
schema: Value extends
|
|
9
|
+
schema: Value extends bigint
|
|
10
10
|
? {
|
|
11
11
|
exclusiveMinimum: true;
|
|
12
|
-
minimum: Value
|
|
12
|
+
minimum: Numeric<Value>;
|
|
13
13
|
}
|
|
14
|
-
:
|
|
14
|
+
: {
|
|
15
|
+
exclusiveMinimum: true;
|
|
16
|
+
minimum: Value;
|
|
17
|
+
};
|
|
15
18
|
}>;
|
|
16
19
|
|
|
17
|
-
type
|
|
20
|
+
type Cast<Value extends number | bigint> = Value extends number
|
|
18
21
|
? Value
|
|
19
22
|
: `BigInt(${Value})`;
|
|
23
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
24
|
+
? N
|
|
25
|
+
: never;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TagBase } from "./TagBase";
|
|
2
2
|
|
|
3
3
|
export type JsonSchemaPlugin<Schema extends object> = TagBase<{
|
|
4
|
-
target: "string" | "boolean" | "number" | "array";
|
|
4
|
+
target: "string" | "boolean" | "bigint" | "number" | "array";
|
|
5
5
|
kind: "jsonPlugin";
|
|
6
6
|
value: undefined;
|
|
7
7
|
schema: Schema;
|