typia 3.8.3 → 3.8.4
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/functional/$dictionary.js +3 -2
- package/lib/functional/$dictionary.js.map +1 -1
- package/package.json +1 -1
- package/src/Primitive.ts +123 -123
- package/src/factories/MetadataFactory.ts +62 -62
- package/src/factories/internal/metadata/emplace_metadata_object.ts +143 -143
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +48 -48
- package/src/functional/$dictionary.ts +7 -2
- package/src/metadata/IMetadata.ts +26 -26
- package/src/metadata/Metadata.ts +539 -539
- package/src/programmers/CheckerProgrammer.ts +901 -901
- package/src/programmers/internal/application_object.ts +155 -155
- package/src/programmers/internal/application_tuple.ts +31 -31
- package/src/schemas/IJsonSchema.ts +130 -130
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
import { CommentFactory } from "../../factories/CommentFactory";
|
|
2
|
-
|
|
3
|
-
import { IJsDocTagInfo } from "../../metadata/IJsDocTagInfo";
|
|
4
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
5
|
-
import { MetadataObject } from "../../metadata/MetadataObject";
|
|
6
|
-
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
7
|
-
|
|
8
|
-
import { PatternUtil } from "../../utils/PatternUtil";
|
|
9
|
-
|
|
10
|
-
import { IJsonSchema } from "../../module";
|
|
11
|
-
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
12
|
-
import { application_schema } from "./application_schema";
|
|
13
|
-
import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export const application_object =
|
|
19
|
-
(options: ApplicationProgrammer.IOptions) =>
|
|
20
|
-
(components: IJsonComponents) =>
|
|
21
|
-
(obj: MetadataObject) =>
|
|
22
|
-
(props: { key: string; nullable: boolean }): void => {
|
|
23
|
-
// TEMPORARY ASSIGNMENT
|
|
24
|
-
if (components.schemas[props.key] !== undefined) return;
|
|
25
|
-
components.schemas[props.key] = {} as any;
|
|
26
|
-
|
|
27
|
-
// ITERATE PROPERTIES
|
|
28
|
-
const properties: Record<string, any> = {};
|
|
29
|
-
const extraMeta: ISuperfluous = {
|
|
30
|
-
patternProperties: {},
|
|
31
|
-
additionalProperties: undefined,
|
|
32
|
-
};
|
|
33
|
-
const required: string[] = [];
|
|
34
|
-
|
|
35
|
-
for (const property of obj.properties) {
|
|
36
|
-
if (
|
|
37
|
-
property.value.functional === true &&
|
|
38
|
-
property.value.nullable === false &&
|
|
39
|
-
property.value.required === true &&
|
|
40
|
-
property.value.size() === 0
|
|
41
|
-
)
|
|
42
|
-
continue;
|
|
43
|
-
|
|
44
|
-
const key: string | null = property.key.getSoleLiteral();
|
|
45
|
-
const schema: IJsonSchema | null = application_schema(options)(
|
|
46
|
-
true,
|
|
47
|
-
)(components)(property.value)({
|
|
48
|
-
deprecated:
|
|
49
|
-
!!property.jsDocTags.find(
|
|
50
|
-
(tag) => tag.name === "deprecated",
|
|
51
|
-
) || undefined,
|
|
52
|
-
title: (() => {
|
|
53
|
-
const info: IJsDocTagInfo | undefined =
|
|
54
|
-
property.jsDocTags.find((tag) => tag.name === "title");
|
|
55
|
-
return info?.text?.length
|
|
56
|
-
? CommentFactory.string(info.text)
|
|
57
|
-
: undefined;
|
|
58
|
-
})(),
|
|
59
|
-
description: property.description,
|
|
60
|
-
"x-typia-metaTags": property.tags.length
|
|
61
|
-
? property.tags
|
|
62
|
-
: undefined,
|
|
63
|
-
"x-typia-jsDocTags": property.jsDocTags.length
|
|
64
|
-
? property.jsDocTags
|
|
65
|
-
: undefined,
|
|
66
|
-
"x-typia-required": property.value.required,
|
|
67
|
-
"x-typia-optional": property.value.optional,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (schema === null) continue;
|
|
71
|
-
else if (key !== null) {
|
|
72
|
-
properties[key] = schema;
|
|
73
|
-
if (property.value.required === true) required.push(key);
|
|
74
|
-
} else {
|
|
75
|
-
const pattern: string = metadata_to_pattern(true)(property.key);
|
|
76
|
-
if (pattern === PatternUtil.STRING)
|
|
77
|
-
extraMeta.additionalProperties = [property.value, schema];
|
|
78
|
-
else
|
|
79
|
-
extraMeta.patternProperties[pattern] = [
|
|
80
|
-
property.value,
|
|
81
|
-
schema,
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const extraProps = {
|
|
87
|
-
additionalProperties: extraMeta.additionalProperties?.[1],
|
|
88
|
-
patternProperties: (() => {
|
|
89
|
-
if (Object.keys(extraMeta.patternProperties).length === 0)
|
|
90
|
-
return undefined;
|
|
91
|
-
const output: Record<string, IJsonSchema> = {};
|
|
92
|
-
for (const [key, value] of Object.entries(
|
|
93
|
-
extraMeta.patternProperties,
|
|
94
|
-
))
|
|
95
|
-
output[key] = value[1];
|
|
96
|
-
return output;
|
|
97
|
-
})(),
|
|
98
|
-
};
|
|
99
|
-
const schema: IJsonComponents.IObject = {
|
|
100
|
-
$id:
|
|
101
|
-
options.purpose === "ajv"
|
|
102
|
-
? options.prefix + "/" + props.key
|
|
103
|
-
: undefined,
|
|
104
|
-
$recursiveAnchor:
|
|
105
|
-
(options.purpose === "ajv" && obj.recursive) || undefined,
|
|
106
|
-
type: "object",
|
|
107
|
-
properties,
|
|
108
|
-
nullable: props.nullable,
|
|
109
|
-
required: required.length ? required : undefined,
|
|
110
|
-
description: obj.description,
|
|
111
|
-
"x-typia-jsDocTags": obj.jsDocTags,
|
|
112
|
-
...(options.purpose === "ajv"
|
|
113
|
-
? extraProps
|
|
114
|
-
: {
|
|
115
|
-
// swagger can't express patternProperties
|
|
116
|
-
"x-typia-additionalProperties":
|
|
117
|
-
extraProps.additionalProperties,
|
|
118
|
-
"x-typia-patternProperties": extraProps.patternProperties,
|
|
119
|
-
additionalProperties:
|
|
120
|
-
join(options)(components)(extraMeta),
|
|
121
|
-
}),
|
|
122
|
-
};
|
|
123
|
-
components.schemas[props.key] = schema;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const join =
|
|
127
|
-
(options: ApplicationProgrammer.IOptions) =>
|
|
128
|
-
(components: IJsonComponents) =>
|
|
129
|
-
(extra: ISuperfluous): IJsonSchema | undefined => {
|
|
130
|
-
// LIST UP METADATA
|
|
131
|
-
const elements: [Metadata, IJsonSchema][] = Object.values(
|
|
132
|
-
extra.patternProperties || {},
|
|
133
|
-
);
|
|
134
|
-
if (extra.additionalProperties)
|
|
135
|
-
elements.push(extra.additionalProperties);
|
|
136
|
-
|
|
137
|
-
// SHORT RETURN
|
|
138
|
-
if (elements.length === 0) return undefined;
|
|
139
|
-
else if (elements.length === 1) return elements[0]![1]!;
|
|
140
|
-
|
|
141
|
-
// MERGE METADATA AND GENERATE VULNERABLE SCHEMA
|
|
142
|
-
const meta: Metadata = elements
|
|
143
|
-
.map((tuple) => tuple[0])
|
|
144
|
-
.reduce((x, y) => Metadata.merge(x, y));
|
|
145
|
-
return (
|
|
146
|
-
application_schema(options)(true)(components)(meta)({
|
|
147
|
-
"x-typia-required": false,
|
|
148
|
-
}) ?? undefined
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
interface ISuperfluous {
|
|
153
|
-
additionalProperties?: [Metadata, IJsonSchema];
|
|
154
|
-
patternProperties: Record<string, [Metadata, IJsonSchema]>;
|
|
155
|
-
}
|
|
1
|
+
import { CommentFactory } from "../../factories/CommentFactory";
|
|
2
|
+
|
|
3
|
+
import { IJsDocTagInfo } from "../../metadata/IJsDocTagInfo";
|
|
4
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
5
|
+
import { MetadataObject } from "../../metadata/MetadataObject";
|
|
6
|
+
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
7
|
+
|
|
8
|
+
import { PatternUtil } from "../../utils/PatternUtil";
|
|
9
|
+
|
|
10
|
+
import { IJsonSchema } from "../../module";
|
|
11
|
+
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
12
|
+
import { application_schema } from "./application_schema";
|
|
13
|
+
import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export const application_object =
|
|
19
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
20
|
+
(components: IJsonComponents) =>
|
|
21
|
+
(obj: MetadataObject) =>
|
|
22
|
+
(props: { key: string; nullable: boolean }): void => {
|
|
23
|
+
// TEMPORARY ASSIGNMENT
|
|
24
|
+
if (components.schemas[props.key] !== undefined) return;
|
|
25
|
+
components.schemas[props.key] = {} as any;
|
|
26
|
+
|
|
27
|
+
// ITERATE PROPERTIES
|
|
28
|
+
const properties: Record<string, any> = {};
|
|
29
|
+
const extraMeta: ISuperfluous = {
|
|
30
|
+
patternProperties: {},
|
|
31
|
+
additionalProperties: undefined,
|
|
32
|
+
};
|
|
33
|
+
const required: string[] = [];
|
|
34
|
+
|
|
35
|
+
for (const property of obj.properties) {
|
|
36
|
+
if (
|
|
37
|
+
property.value.functional === true &&
|
|
38
|
+
property.value.nullable === false &&
|
|
39
|
+
property.value.required === true &&
|
|
40
|
+
property.value.size() === 0
|
|
41
|
+
)
|
|
42
|
+
continue;
|
|
43
|
+
|
|
44
|
+
const key: string | null = property.key.getSoleLiteral();
|
|
45
|
+
const schema: IJsonSchema | null = application_schema(options)(
|
|
46
|
+
true,
|
|
47
|
+
)(components)(property.value)({
|
|
48
|
+
deprecated:
|
|
49
|
+
!!property.jsDocTags.find(
|
|
50
|
+
(tag) => tag.name === "deprecated",
|
|
51
|
+
) || undefined,
|
|
52
|
+
title: (() => {
|
|
53
|
+
const info: IJsDocTagInfo | undefined =
|
|
54
|
+
property.jsDocTags.find((tag) => tag.name === "title");
|
|
55
|
+
return info?.text?.length
|
|
56
|
+
? CommentFactory.string(info.text)
|
|
57
|
+
: undefined;
|
|
58
|
+
})(),
|
|
59
|
+
description: property.description,
|
|
60
|
+
"x-typia-metaTags": property.tags.length
|
|
61
|
+
? property.tags
|
|
62
|
+
: undefined,
|
|
63
|
+
"x-typia-jsDocTags": property.jsDocTags.length
|
|
64
|
+
? property.jsDocTags
|
|
65
|
+
: undefined,
|
|
66
|
+
"x-typia-required": property.value.required,
|
|
67
|
+
"x-typia-optional": property.value.optional,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (schema === null) continue;
|
|
71
|
+
else if (key !== null) {
|
|
72
|
+
properties[key] = schema;
|
|
73
|
+
if (property.value.required === true) required.push(key);
|
|
74
|
+
} else {
|
|
75
|
+
const pattern: string = metadata_to_pattern(true)(property.key);
|
|
76
|
+
if (pattern === PatternUtil.STRING)
|
|
77
|
+
extraMeta.additionalProperties = [property.value, schema];
|
|
78
|
+
else
|
|
79
|
+
extraMeta.patternProperties[pattern] = [
|
|
80
|
+
property.value,
|
|
81
|
+
schema,
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const extraProps = {
|
|
87
|
+
additionalProperties: extraMeta.additionalProperties?.[1],
|
|
88
|
+
patternProperties: (() => {
|
|
89
|
+
if (Object.keys(extraMeta.patternProperties).length === 0)
|
|
90
|
+
return undefined;
|
|
91
|
+
const output: Record<string, IJsonSchema> = {};
|
|
92
|
+
for (const [key, value] of Object.entries(
|
|
93
|
+
extraMeta.patternProperties,
|
|
94
|
+
))
|
|
95
|
+
output[key] = value[1];
|
|
96
|
+
return output;
|
|
97
|
+
})(),
|
|
98
|
+
};
|
|
99
|
+
const schema: IJsonComponents.IObject = {
|
|
100
|
+
$id:
|
|
101
|
+
options.purpose === "ajv"
|
|
102
|
+
? options.prefix + "/" + props.key
|
|
103
|
+
: undefined,
|
|
104
|
+
$recursiveAnchor:
|
|
105
|
+
(options.purpose === "ajv" && obj.recursive) || undefined,
|
|
106
|
+
type: "object",
|
|
107
|
+
properties,
|
|
108
|
+
nullable: props.nullable,
|
|
109
|
+
required: required.length ? required : undefined,
|
|
110
|
+
description: obj.description,
|
|
111
|
+
"x-typia-jsDocTags": obj.jsDocTags,
|
|
112
|
+
...(options.purpose === "ajv"
|
|
113
|
+
? extraProps
|
|
114
|
+
: {
|
|
115
|
+
// swagger can't express patternProperties
|
|
116
|
+
"x-typia-additionalProperties":
|
|
117
|
+
extraProps.additionalProperties,
|
|
118
|
+
"x-typia-patternProperties": extraProps.patternProperties,
|
|
119
|
+
additionalProperties:
|
|
120
|
+
join(options)(components)(extraMeta),
|
|
121
|
+
}),
|
|
122
|
+
};
|
|
123
|
+
components.schemas[props.key] = schema;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const join =
|
|
127
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
128
|
+
(components: IJsonComponents) =>
|
|
129
|
+
(extra: ISuperfluous): IJsonSchema | undefined => {
|
|
130
|
+
// LIST UP METADATA
|
|
131
|
+
const elements: [Metadata, IJsonSchema][] = Object.values(
|
|
132
|
+
extra.patternProperties || {},
|
|
133
|
+
);
|
|
134
|
+
if (extra.additionalProperties)
|
|
135
|
+
elements.push(extra.additionalProperties);
|
|
136
|
+
|
|
137
|
+
// SHORT RETURN
|
|
138
|
+
if (elements.length === 0) return undefined;
|
|
139
|
+
else if (elements.length === 1) return elements[0]![1]!;
|
|
140
|
+
|
|
141
|
+
// MERGE METADATA AND GENERATE VULNERABLE SCHEMA
|
|
142
|
+
const meta: Metadata = elements
|
|
143
|
+
.map((tuple) => tuple[0])
|
|
144
|
+
.reduce((x, y) => Metadata.merge(x, y));
|
|
145
|
+
return (
|
|
146
|
+
application_schema(options)(true)(components)(meta)({
|
|
147
|
+
"x-typia-required": false,
|
|
148
|
+
}) ?? undefined
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
interface ISuperfluous {
|
|
153
|
+
additionalProperties?: [Metadata, IJsonSchema];
|
|
154
|
+
patternProperties: Record<string, [Metadata, IJsonSchema]>;
|
|
155
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
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 { application_schema } from "./application_schema";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export const application_tuple =
|
|
12
|
-
(options: ApplicationProgrammer.IOptions) =>
|
|
13
|
-
(components: IJsonComponents) =>
|
|
14
|
-
(items: Array<Metadata>) =>
|
|
15
|
-
(props: {
|
|
16
|
-
nullable: boolean;
|
|
17
|
-
attribute: IJsonSchema.IAttribute;
|
|
18
|
-
}): IJsonSchema.ITuple => ({
|
|
19
|
-
type: "array",
|
|
20
|
-
items: items.map((meta, i) =>
|
|
21
|
-
application_schema(options)(false)(components)(meta.rest ?? meta)({
|
|
22
|
-
...props.attribute,
|
|
23
|
-
"x-typia-rest":
|
|
24
|
-
i === items.length - 1 ? meta.rest !== null : undefined,
|
|
25
|
-
"x-typia-required": meta.required,
|
|
26
|
-
"x-typia-optional": meta.optional,
|
|
27
|
-
}),
|
|
28
|
-
),
|
|
29
|
-
nullable: props.nullable,
|
|
30
|
-
...props.attribute,
|
|
31
|
-
});
|
|
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 { application_schema } from "./application_schema";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export const application_tuple =
|
|
12
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
13
|
+
(components: IJsonComponents) =>
|
|
14
|
+
(items: Array<Metadata>) =>
|
|
15
|
+
(props: {
|
|
16
|
+
nullable: boolean;
|
|
17
|
+
attribute: IJsonSchema.IAttribute;
|
|
18
|
+
}): IJsonSchema.ITuple => ({
|
|
19
|
+
type: "array",
|
|
20
|
+
items: items.map((meta, i) =>
|
|
21
|
+
application_schema(options)(false)(components)(meta.rest ?? meta)({
|
|
22
|
+
...props.attribute,
|
|
23
|
+
"x-typia-rest":
|
|
24
|
+
i === items.length - 1 ? meta.rest !== null : undefined,
|
|
25
|
+
"x-typia-required": meta.required,
|
|
26
|
+
"x-typia-optional": meta.optional,
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
nullable: props.nullable,
|
|
30
|
+
...props.attribute,
|
|
31
|
+
});
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
|
|
2
|
-
import { IMetadataTag } from "../metadata/IMetadataTag";
|
|
3
|
-
|
|
4
|
-
import { Atomic } from "../typings/Atomic";
|
|
5
|
-
|
|
6
|
-
export type IJsonSchema = IJsonSchema.Known | IJsonSchema.IUnknown;
|
|
7
|
-
export namespace IJsonSchema {
|
|
8
|
-
export type Known =
|
|
9
|
-
| IEnumeration<"boolean">
|
|
10
|
-
| IEnumeration<"number">
|
|
11
|
-
| IEnumeration<"string">
|
|
12
|
-
| IBoolean
|
|
13
|
-
| IInteger
|
|
14
|
-
| INumber
|
|
15
|
-
| IString
|
|
16
|
-
| IArray
|
|
17
|
-
| ITuple
|
|
18
|
-
| IOneOf
|
|
19
|
-
| IReference
|
|
20
|
-
| IRecursiveReference
|
|
21
|
-
| INullOnly;
|
|
22
|
-
|
|
23
|
-
export interface IUnknown extends IAttribute {
|
|
24
|
-
type: undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated Use {@link Known} type instead.
|
|
29
|
-
*/
|
|
30
|
-
export type NotUnknown = Known;
|
|
31
|
-
|
|
32
|
-
/* -----------------------------------------------------------
|
|
33
|
-
ATOMICS
|
|
34
|
-
----------------------------------------------------------- */
|
|
35
|
-
export interface IEnumeration<
|
|
36
|
-
Literal extends Exclude<Atomic.Literal, "bigint">,
|
|
37
|
-
> extends IAtomic<Literal> {
|
|
38
|
-
enum: Array<Atomic.Mapper[Literal]>;
|
|
39
|
-
}
|
|
40
|
-
export interface IAtomic<Literal extends Exclude<Atomic.Literal, "bigint">>
|
|
41
|
-
extends ISignificant<Literal> {
|
|
42
|
-
default?: Atomic.Mapper[Literal];
|
|
43
|
-
}
|
|
44
|
-
export interface IString extends IAtomic<"string"> {
|
|
45
|
-
/**
|
|
46
|
-
* @type uint
|
|
47
|
-
*/
|
|
48
|
-
minLength?: number;
|
|
49
|
-
/**
|
|
50
|
-
* @type uint
|
|
51
|
-
*/
|
|
52
|
-
maxLength?: number;
|
|
53
|
-
pattern?: string;
|
|
54
|
-
format?: string;
|
|
55
|
-
}
|
|
56
|
-
export interface INumber extends IAtomic<"number"> {
|
|
57
|
-
minimum?: number;
|
|
58
|
-
maximum?: number;
|
|
59
|
-
exclusiveMinimum?: boolean;
|
|
60
|
-
exclusiveMaximum?: boolean;
|
|
61
|
-
multipleOf?: number;
|
|
62
|
-
}
|
|
63
|
-
export interface IInteger extends IAtomic<"integer"> {
|
|
64
|
-
/**
|
|
65
|
-
* @type int
|
|
66
|
-
*/
|
|
67
|
-
minimum?: number;
|
|
68
|
-
/**
|
|
69
|
-
* @type int
|
|
70
|
-
*/
|
|
71
|
-
maximum?: number;
|
|
72
|
-
exclusiveMinimum?: boolean;
|
|
73
|
-
exclusiveMaximum?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* @type int
|
|
76
|
-
*/
|
|
77
|
-
multipleOf?: number;
|
|
78
|
-
}
|
|
79
|
-
export interface IBoolean extends IAtomic<"boolean"> {}
|
|
80
|
-
|
|
81
|
-
/* -----------------------------------------------------------
|
|
82
|
-
OBJECTS
|
|
83
|
-
----------------------------------------------------------- */
|
|
84
|
-
export interface IArray extends ISignificant<"array"> {
|
|
85
|
-
items: IJsonSchema;
|
|
86
|
-
/**
|
|
87
|
-
* @type uint
|
|
88
|
-
*/
|
|
89
|
-
minItems?: number;
|
|
90
|
-
/**
|
|
91
|
-
* @type uint
|
|
92
|
-
*/
|
|
93
|
-
maxItems?: number;
|
|
94
|
-
"x-typia-tuple"?: ITuple;
|
|
95
|
-
}
|
|
96
|
-
export interface ITuple extends ISignificant<"array"> {
|
|
97
|
-
items: IJsonSchema[];
|
|
98
|
-
}
|
|
99
|
-
export interface IReference extends IAttribute {
|
|
100
|
-
$ref: string;
|
|
101
|
-
}
|
|
102
|
-
export interface IRecursiveReference extends IAttribute {
|
|
103
|
-
$recursiveRef: string;
|
|
104
|
-
}
|
|
105
|
-
export interface INullOnly extends IAttribute {
|
|
106
|
-
type: "null";
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/* -----------------------------------------------------------
|
|
110
|
-
MISCELLANEOUS
|
|
111
|
-
----------------------------------------------------------- */
|
|
112
|
-
export interface IOneOf extends IAttribute {
|
|
113
|
-
oneOf: IJsonSchema[];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface ISignificant<Literal extends string> extends IAttribute {
|
|
117
|
-
type: Literal;
|
|
118
|
-
nullable: boolean;
|
|
119
|
-
}
|
|
120
|
-
export interface IAttribute {
|
|
121
|
-
deprecated?: boolean;
|
|
122
|
-
title?: string;
|
|
123
|
-
description?: string;
|
|
124
|
-
"x-typia-metaTags"?: IMetadataTag[];
|
|
125
|
-
"x-typia-jsDocTags"?: IJsDocTagInfo[];
|
|
126
|
-
"x-typia-required"?: boolean;
|
|
127
|
-
"x-typia-optional"?: boolean;
|
|
128
|
-
"x-typia-rest"?: boolean;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
1
|
+
import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
|
|
2
|
+
import { IMetadataTag } from "../metadata/IMetadataTag";
|
|
3
|
+
|
|
4
|
+
import { Atomic } from "../typings/Atomic";
|
|
5
|
+
|
|
6
|
+
export type IJsonSchema = IJsonSchema.Known | IJsonSchema.IUnknown;
|
|
7
|
+
export namespace IJsonSchema {
|
|
8
|
+
export type Known =
|
|
9
|
+
| IEnumeration<"boolean">
|
|
10
|
+
| IEnumeration<"number">
|
|
11
|
+
| IEnumeration<"string">
|
|
12
|
+
| IBoolean
|
|
13
|
+
| IInteger
|
|
14
|
+
| INumber
|
|
15
|
+
| IString
|
|
16
|
+
| IArray
|
|
17
|
+
| ITuple
|
|
18
|
+
| IOneOf
|
|
19
|
+
| IReference
|
|
20
|
+
| IRecursiveReference
|
|
21
|
+
| INullOnly;
|
|
22
|
+
|
|
23
|
+
export interface IUnknown extends IAttribute {
|
|
24
|
+
type: undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use {@link Known} type instead.
|
|
29
|
+
*/
|
|
30
|
+
export type NotUnknown = Known;
|
|
31
|
+
|
|
32
|
+
/* -----------------------------------------------------------
|
|
33
|
+
ATOMICS
|
|
34
|
+
----------------------------------------------------------- */
|
|
35
|
+
export interface IEnumeration<
|
|
36
|
+
Literal extends Exclude<Atomic.Literal, "bigint">,
|
|
37
|
+
> extends IAtomic<Literal> {
|
|
38
|
+
enum: Array<Atomic.Mapper[Literal]>;
|
|
39
|
+
}
|
|
40
|
+
export interface IAtomic<Literal extends Exclude<Atomic.Literal, "bigint">>
|
|
41
|
+
extends ISignificant<Literal> {
|
|
42
|
+
default?: Atomic.Mapper[Literal];
|
|
43
|
+
}
|
|
44
|
+
export interface IString extends IAtomic<"string"> {
|
|
45
|
+
/**
|
|
46
|
+
* @type uint
|
|
47
|
+
*/
|
|
48
|
+
minLength?: number;
|
|
49
|
+
/**
|
|
50
|
+
* @type uint
|
|
51
|
+
*/
|
|
52
|
+
maxLength?: number;
|
|
53
|
+
pattern?: string;
|
|
54
|
+
format?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface INumber extends IAtomic<"number"> {
|
|
57
|
+
minimum?: number;
|
|
58
|
+
maximum?: number;
|
|
59
|
+
exclusiveMinimum?: boolean;
|
|
60
|
+
exclusiveMaximum?: boolean;
|
|
61
|
+
multipleOf?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface IInteger extends IAtomic<"integer"> {
|
|
64
|
+
/**
|
|
65
|
+
* @type int
|
|
66
|
+
*/
|
|
67
|
+
minimum?: number;
|
|
68
|
+
/**
|
|
69
|
+
* @type int
|
|
70
|
+
*/
|
|
71
|
+
maximum?: number;
|
|
72
|
+
exclusiveMinimum?: boolean;
|
|
73
|
+
exclusiveMaximum?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* @type int
|
|
76
|
+
*/
|
|
77
|
+
multipleOf?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface IBoolean extends IAtomic<"boolean"> {}
|
|
80
|
+
|
|
81
|
+
/* -----------------------------------------------------------
|
|
82
|
+
OBJECTS
|
|
83
|
+
----------------------------------------------------------- */
|
|
84
|
+
export interface IArray extends ISignificant<"array"> {
|
|
85
|
+
items: IJsonSchema;
|
|
86
|
+
/**
|
|
87
|
+
* @type uint
|
|
88
|
+
*/
|
|
89
|
+
minItems?: number;
|
|
90
|
+
/**
|
|
91
|
+
* @type uint
|
|
92
|
+
*/
|
|
93
|
+
maxItems?: number;
|
|
94
|
+
"x-typia-tuple"?: ITuple;
|
|
95
|
+
}
|
|
96
|
+
export interface ITuple extends ISignificant<"array"> {
|
|
97
|
+
items: IJsonSchema[];
|
|
98
|
+
}
|
|
99
|
+
export interface IReference extends IAttribute {
|
|
100
|
+
$ref: string;
|
|
101
|
+
}
|
|
102
|
+
export interface IRecursiveReference extends IAttribute {
|
|
103
|
+
$recursiveRef: string;
|
|
104
|
+
}
|
|
105
|
+
export interface INullOnly extends IAttribute {
|
|
106
|
+
type: "null";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* -----------------------------------------------------------
|
|
110
|
+
MISCELLANEOUS
|
|
111
|
+
----------------------------------------------------------- */
|
|
112
|
+
export interface IOneOf extends IAttribute {
|
|
113
|
+
oneOf: IJsonSchema[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ISignificant<Literal extends string> extends IAttribute {
|
|
117
|
+
type: Literal;
|
|
118
|
+
nullable: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface IAttribute {
|
|
121
|
+
deprecated?: boolean;
|
|
122
|
+
title?: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
"x-typia-metaTags"?: IMetadataTag[];
|
|
125
|
+
"x-typia-jsDocTags"?: IJsDocTagInfo[];
|
|
126
|
+
"x-typia-required"?: boolean;
|
|
127
|
+
"x-typia-optional"?: boolean;
|
|
128
|
+
"x-typia-rest"?: boolean;
|
|
129
|
+
}
|
|
130
|
+
}
|