@typia/interface 12.0.0-dev.20260309 → 12.0.0-dev.20260310
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/http/IHttpLlmController.d.ts +5 -5
- package/lib/schema/IJsonParseResult.d.ts +1 -3
- package/lib/schema/ILlmController.d.ts +2 -5
- package/package.json +1 -1
- package/src/http/IHttpConnection.ts +200 -200
- package/src/http/IHttpLlmApplication.ts +72 -72
- package/src/http/IHttpLlmController.ts +96 -96
- package/src/http/IHttpLlmFunction.ts +34 -34
- package/src/http/IHttpMigrateApplication.ts +48 -48
- package/src/http/IHttpMigrateRoute.ts +165 -165
- package/src/http/IHttpResponse.ts +42 -42
- package/src/http/index.ts +7 -7
- package/src/index.ts +9 -9
- package/src/metadata/IJsDocTagInfo.ts +25 -25
- package/src/metadata/IMetadataComponents.ts +24 -24
- package/src/metadata/IMetadataSchema.ts +293 -293
- package/src/metadata/IMetadataSchemaCollection.ts +20 -20
- package/src/metadata/IMetadataSchemaUnit.ts +20 -20
- package/src/metadata/IMetadataTypeTag.ts +39 -39
- package/src/metadata/index.ts +6 -6
- package/src/openapi/OpenApi.ts +643 -643
- package/src/openapi/OpenApiV3.ts +655 -655
- package/src/openapi/OpenApiV3_1.ts +735 -735
- package/src/openapi/SwaggerV2.ts +559 -559
- package/src/openapi/index.ts +4 -4
- package/src/protobuf/ProtobufWire.ts +51 -51
- package/src/protobuf/index.ts +1 -1
- package/src/schema/IJsonParseResult.ts +134 -136
- package/src/schema/IJsonSchemaApplication.ts +274 -274
- package/src/schema/IJsonSchemaAttribute.ts +158 -158
- package/src/schema/IJsonSchemaCollection.ts +123 -123
- package/src/schema/IJsonSchemaTransformError.ts +86 -86
- package/src/schema/IJsonSchemaUnit.ts +120 -120
- package/src/schema/ILlmApplication.ts +99 -99
- package/src/schema/ILlmController.ts +54 -57
- package/src/schema/ILlmFunction.ts +145 -145
- package/src/schema/ILlmSchema.ts +484 -484
- package/src/schema/IResult.ts +84 -84
- package/src/schema/IValidation.ts +134 -134
- package/src/schema/index.ts +14 -14
- package/src/tags/Constant.ts +49 -49
- package/src/tags/ContentMediaType.ts +40 -40
- package/src/tags/Default.ts +50 -50
- package/src/tags/Example.ts +48 -48
- package/src/tags/Examples.ts +50 -50
- package/src/tags/ExclusiveMaximum.ts +46 -46
- package/src/tags/ExclusiveMinimum.ts +46 -46
- package/src/tags/Format.ts +76 -76
- package/src/tags/JsonSchemaPlugin.ts +45 -45
- package/src/tags/MaxItems.ts +39 -39
- package/src/tags/MaxLength.ts +37 -37
- package/src/tags/Maximum.ts +44 -44
- package/src/tags/MinItems.ts +39 -39
- package/src/tags/MinLength.ts +37 -37
- package/src/tags/Minimum.ts +44 -44
- package/src/tags/MultipleOf.ts +54 -54
- package/src/tags/Pattern.ts +59 -59
- package/src/tags/Sequence.ts +43 -43
- package/src/tags/TagBase.ts +131 -131
- package/src/tags/Type.ts +70 -70
- package/src/tags/UniqueItems.ts +44 -44
- package/src/tags/index.ts +21 -21
- package/src/typings/AssertionGuard.ts +12 -12
- package/src/typings/Atomic.ts +21 -21
- package/src/typings/CamelCase.ts +75 -75
- package/src/typings/ClassProperties.ts +15 -15
- package/src/typings/DeepPartial.ts +39 -39
- package/src/typings/OmitNever.ts +12 -12
- package/src/typings/PascalCase.ts +71 -71
- package/src/typings/Primitive.ts +71 -71
- package/src/typings/ProtobufAtomic.ts +30 -30
- package/src/typings/Resolved.ts +58 -58
- package/src/typings/SnakeCase.ts +126 -126
- package/src/typings/SpecialFields.ts +13 -13
- package/src/typings/ValidationPipe.ts +20 -20
- package/src/typings/index.ts +14 -14
- package/src/typings/internal/Equal.ts +14 -14
- package/src/typings/internal/IsTuple.ts +17 -17
- package/src/typings/internal/NativeClass.ts +31 -31
- package/src/typings/internal/ValueOf.ts +29 -29
- package/src/utils/IRandomGenerator.ts +105 -105
- package/src/utils/IReadableURLSearchParams.ts +25 -25
- package/src/utils/index.ts +2 -2
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common attributes shared by all JSON schema types.
|
|
3
|
-
*
|
|
4
|
-
* `IJsonSchemaAttribute` defines the base set of metadata properties that can
|
|
5
|
-
* be attached to any JSON schema type. These attributes provide documentation,
|
|
6
|
-
* deprecation status, examples, and access control information.
|
|
7
|
-
*
|
|
8
|
-
* This interface serves as the foundation for all schema types in typia's JSON
|
|
9
|
-
* Schema generation. The namespace contains type-specific variants (e.g.,
|
|
10
|
-
* {@link IBoolean}, {@link IString}) that add a `type` discriminator while
|
|
11
|
-
* inheriting all base attributes.
|
|
12
|
-
*
|
|
13
|
-
* These attributes are populated from JSDoc comments during schema generation:
|
|
14
|
-
*
|
|
15
|
-
* - `@title` tag → {@link title}
|
|
16
|
-
* - Main comment body → {@link description}
|
|
17
|
-
* - `@deprecated` tag → {@link deprecated}
|
|
18
|
-
* - `@example` tag → {@link example}
|
|
19
|
-
*
|
|
20
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
21
|
-
*/
|
|
22
|
-
export interface IJsonSchemaAttribute {
|
|
23
|
-
/**
|
|
24
|
-
* Short title for the schema.
|
|
25
|
-
*
|
|
26
|
-
* A brief, human-readable name for the type. Typically extracted from the
|
|
27
|
-
* first line of a JSDoc comment or the `@title` tag.
|
|
28
|
-
*/
|
|
29
|
-
title?: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Detailed description of the schema.
|
|
33
|
-
*
|
|
34
|
-
* Full documentation for the type, explaining its purpose, constraints, and
|
|
35
|
-
* usage. Extracted from JSDoc comment body. Supports markdown formatting in
|
|
36
|
-
* many JSON Schema consumers.
|
|
37
|
-
*/
|
|
38
|
-
description?: string;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Whether this type is deprecated.
|
|
42
|
-
*
|
|
43
|
-
* When `true`, indicates the type should no longer be used and may be removed
|
|
44
|
-
* in future versions. Set via the `@deprecated` JSDoc tag.
|
|
45
|
-
*/
|
|
46
|
-
deprecated?: boolean;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Single example value for the schema.
|
|
50
|
-
*
|
|
51
|
-
* A representative value that conforms to the schema, useful for
|
|
52
|
-
* documentation and testing. Set via the `@example` JSDoc tag.
|
|
53
|
-
*/
|
|
54
|
-
example?: any;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Named example values for the schema.
|
|
58
|
-
*
|
|
59
|
-
* Multiple examples as key-value pairs, where keys are example names and
|
|
60
|
-
* values are conforming data. Useful for showing different valid states or
|
|
61
|
-
* edge cases.
|
|
62
|
-
*/
|
|
63
|
-
examples?: Record<string, any>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Whether the property is read-only.
|
|
67
|
-
*
|
|
68
|
-
* When `true`, the property should not be modified by clients and is
|
|
69
|
-
* typically set by the server. Useful for generated IDs, timestamps, etc.
|
|
70
|
-
*/
|
|
71
|
-
readOnly?: boolean;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Whether the property is write-only.
|
|
75
|
-
*
|
|
76
|
-
* When `true`, the property is accepted on input but never returned in
|
|
77
|
-
* responses. Common for sensitive data like passwords.
|
|
78
|
-
*/
|
|
79
|
-
writeOnly?: boolean;
|
|
80
|
-
}
|
|
81
|
-
export namespace IJsonSchemaAttribute {
|
|
82
|
-
/**
|
|
83
|
-
* Attribute interface for boolean schema types.
|
|
84
|
-
*
|
|
85
|
-
* Extends base attributes with `type: "boolean"` discriminator.
|
|
86
|
-
*/
|
|
87
|
-
export interface IBoolean extends ISignificant<"boolean"> {}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Attribute interface for integer schema types.
|
|
91
|
-
*
|
|
92
|
-
* Extends base attributes with `type: "integer"` discriminator. Note: JSON
|
|
93
|
-
* Schema uses "integer" for whole numbers, distinct from "number".
|
|
94
|
-
*/
|
|
95
|
-
export interface IInteger extends ISignificant<"integer"> {}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Attribute interface for number schema types.
|
|
99
|
-
*
|
|
100
|
-
* Extends base attributes with `type: "number"` discriminator. Represents
|
|
101
|
-
* floating-point numbers in JSON Schema.
|
|
102
|
-
*/
|
|
103
|
-
export interface INumber extends ISignificant<"number"> {}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Attribute interface for string schema types.
|
|
107
|
-
*
|
|
108
|
-
* Extends base attributes with `type: "string"` discriminator.
|
|
109
|
-
*/
|
|
110
|
-
export interface IString extends ISignificant<"string"> {}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Attribute interface for object schema types.
|
|
114
|
-
*
|
|
115
|
-
* Extends base attributes with `type: "object"` discriminator. Used for
|
|
116
|
-
* structured data with named properties.
|
|
117
|
-
*/
|
|
118
|
-
export interface IObject extends ISignificant<"object"> {}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Attribute interface for array schema types.
|
|
122
|
-
*
|
|
123
|
-
* Extends base attributes with `type: "array"` discriminator. Represents
|
|
124
|
-
* ordered collections of items.
|
|
125
|
-
*/
|
|
126
|
-
export interface IArray extends ISignificant<"array"> {}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Attribute interface for null schema types.
|
|
130
|
-
*
|
|
131
|
-
* Extends base attributes with `type: "null"` discriminator. Represents the
|
|
132
|
-
* JSON null value.
|
|
133
|
-
*/
|
|
134
|
-
export interface INull extends ISignificant<"null"> {}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Attribute interface for unknown/untyped schemas.
|
|
138
|
-
*
|
|
139
|
-
* Used when the schema type is not specified or cannot be determined. The
|
|
140
|
-
* `type` property is explicitly undefined to indicate no type constraint.
|
|
141
|
-
*/
|
|
142
|
-
export interface IUnknown extends IJsonSchemaAttribute {
|
|
143
|
-
type?: undefined;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Base interface for type-discriminated schema attributes.
|
|
148
|
-
*
|
|
149
|
-
* Internal helper that combines base attributes with a type discriminator.
|
|
150
|
-
* Each specific type interface (IBoolean, IString, etc.) extends this with
|
|
151
|
-
* its corresponding type literal.
|
|
152
|
-
*
|
|
153
|
-
* @template Type - The JSON Schema type string literal
|
|
154
|
-
*/
|
|
155
|
-
interface ISignificant<Type extends string> extends IJsonSchemaAttribute {
|
|
156
|
-
type: Type;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Common attributes shared by all JSON schema types.
|
|
3
|
+
*
|
|
4
|
+
* `IJsonSchemaAttribute` defines the base set of metadata properties that can
|
|
5
|
+
* be attached to any JSON schema type. These attributes provide documentation,
|
|
6
|
+
* deprecation status, examples, and access control information.
|
|
7
|
+
*
|
|
8
|
+
* This interface serves as the foundation for all schema types in typia's JSON
|
|
9
|
+
* Schema generation. The namespace contains type-specific variants (e.g.,
|
|
10
|
+
* {@link IBoolean}, {@link IString}) that add a `type` discriminator while
|
|
11
|
+
* inheriting all base attributes.
|
|
12
|
+
*
|
|
13
|
+
* These attributes are populated from JSDoc comments during schema generation:
|
|
14
|
+
*
|
|
15
|
+
* - `@title` tag → {@link title}
|
|
16
|
+
* - Main comment body → {@link description}
|
|
17
|
+
* - `@deprecated` tag → {@link deprecated}
|
|
18
|
+
* - `@example` tag → {@link example}
|
|
19
|
+
*
|
|
20
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
21
|
+
*/
|
|
22
|
+
export interface IJsonSchemaAttribute {
|
|
23
|
+
/**
|
|
24
|
+
* Short title for the schema.
|
|
25
|
+
*
|
|
26
|
+
* A brief, human-readable name for the type. Typically extracted from the
|
|
27
|
+
* first line of a JSDoc comment or the `@title` tag.
|
|
28
|
+
*/
|
|
29
|
+
title?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Detailed description of the schema.
|
|
33
|
+
*
|
|
34
|
+
* Full documentation for the type, explaining its purpose, constraints, and
|
|
35
|
+
* usage. Extracted from JSDoc comment body. Supports markdown formatting in
|
|
36
|
+
* many JSON Schema consumers.
|
|
37
|
+
*/
|
|
38
|
+
description?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether this type is deprecated.
|
|
42
|
+
*
|
|
43
|
+
* When `true`, indicates the type should no longer be used and may be removed
|
|
44
|
+
* in future versions. Set via the `@deprecated` JSDoc tag.
|
|
45
|
+
*/
|
|
46
|
+
deprecated?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Single example value for the schema.
|
|
50
|
+
*
|
|
51
|
+
* A representative value that conforms to the schema, useful for
|
|
52
|
+
* documentation and testing. Set via the `@example` JSDoc tag.
|
|
53
|
+
*/
|
|
54
|
+
example?: any;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Named example values for the schema.
|
|
58
|
+
*
|
|
59
|
+
* Multiple examples as key-value pairs, where keys are example names and
|
|
60
|
+
* values are conforming data. Useful for showing different valid states or
|
|
61
|
+
* edge cases.
|
|
62
|
+
*/
|
|
63
|
+
examples?: Record<string, any>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Whether the property is read-only.
|
|
67
|
+
*
|
|
68
|
+
* When `true`, the property should not be modified by clients and is
|
|
69
|
+
* typically set by the server. Useful for generated IDs, timestamps, etc.
|
|
70
|
+
*/
|
|
71
|
+
readOnly?: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether the property is write-only.
|
|
75
|
+
*
|
|
76
|
+
* When `true`, the property is accepted on input but never returned in
|
|
77
|
+
* responses. Common for sensitive data like passwords.
|
|
78
|
+
*/
|
|
79
|
+
writeOnly?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export namespace IJsonSchemaAttribute {
|
|
82
|
+
/**
|
|
83
|
+
* Attribute interface for boolean schema types.
|
|
84
|
+
*
|
|
85
|
+
* Extends base attributes with `type: "boolean"` discriminator.
|
|
86
|
+
*/
|
|
87
|
+
export interface IBoolean extends ISignificant<"boolean"> {}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Attribute interface for integer schema types.
|
|
91
|
+
*
|
|
92
|
+
* Extends base attributes with `type: "integer"` discriminator. Note: JSON
|
|
93
|
+
* Schema uses "integer" for whole numbers, distinct from "number".
|
|
94
|
+
*/
|
|
95
|
+
export interface IInteger extends ISignificant<"integer"> {}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Attribute interface for number schema types.
|
|
99
|
+
*
|
|
100
|
+
* Extends base attributes with `type: "number"` discriminator. Represents
|
|
101
|
+
* floating-point numbers in JSON Schema.
|
|
102
|
+
*/
|
|
103
|
+
export interface INumber extends ISignificant<"number"> {}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Attribute interface for string schema types.
|
|
107
|
+
*
|
|
108
|
+
* Extends base attributes with `type: "string"` discriminator.
|
|
109
|
+
*/
|
|
110
|
+
export interface IString extends ISignificant<"string"> {}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Attribute interface for object schema types.
|
|
114
|
+
*
|
|
115
|
+
* Extends base attributes with `type: "object"` discriminator. Used for
|
|
116
|
+
* structured data with named properties.
|
|
117
|
+
*/
|
|
118
|
+
export interface IObject extends ISignificant<"object"> {}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Attribute interface for array schema types.
|
|
122
|
+
*
|
|
123
|
+
* Extends base attributes with `type: "array"` discriminator. Represents
|
|
124
|
+
* ordered collections of items.
|
|
125
|
+
*/
|
|
126
|
+
export interface IArray extends ISignificant<"array"> {}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Attribute interface for null schema types.
|
|
130
|
+
*
|
|
131
|
+
* Extends base attributes with `type: "null"` discriminator. Represents the
|
|
132
|
+
* JSON null value.
|
|
133
|
+
*/
|
|
134
|
+
export interface INull extends ISignificant<"null"> {}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Attribute interface for unknown/untyped schemas.
|
|
138
|
+
*
|
|
139
|
+
* Used when the schema type is not specified or cannot be determined. The
|
|
140
|
+
* `type` property is explicitly undefined to indicate no type constraint.
|
|
141
|
+
*/
|
|
142
|
+
export interface IUnknown extends IJsonSchemaAttribute {
|
|
143
|
+
type?: undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Base interface for type-discriminated schema attributes.
|
|
148
|
+
*
|
|
149
|
+
* Internal helper that combines base attributes with a type discriminator.
|
|
150
|
+
* Each specific type interface (IBoolean, IString, etc.) extends this with
|
|
151
|
+
* its corresponding type literal.
|
|
152
|
+
*
|
|
153
|
+
* @template Type - The JSON Schema type string literal
|
|
154
|
+
*/
|
|
155
|
+
interface ISignificant<Type extends string> extends IJsonSchemaAttribute {
|
|
156
|
+
type: Type;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { OpenApi } from "../openapi/OpenApi";
|
|
2
|
-
import { OpenApiV3 } from "../openapi/OpenApiV3";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Collection of JSON schemas generated from multiple TypeScript types.
|
|
6
|
-
*
|
|
7
|
-
* `IJsonSchemaCollection` holds JSON schemas for multiple TypeScript types
|
|
8
|
-
* generated at compile time by `typia.json.schemas<[T1, T2, ...]>()`. The
|
|
9
|
-
* schemas share a common components pool to avoid duplication when types
|
|
10
|
-
* reference each other.
|
|
11
|
-
*
|
|
12
|
-
* This is useful when you need schemas for multiple related types and want to
|
|
13
|
-
* share component definitions between them. For single types, use
|
|
14
|
-
* {@link IJsonSchemaUnit} instead. For function schemas, see
|
|
15
|
-
* {@link IJsonSchemaApplication}.
|
|
16
|
-
*
|
|
17
|
-
* The collection contains:
|
|
18
|
-
*
|
|
19
|
-
* - {@link IV3_1.schemas | schemas}: Array of schemas, one per input type
|
|
20
|
-
* - {@link IV3_1.components | components}: Shared `$ref` definitions
|
|
21
|
-
* - {@link IV3_1.__types | __types}: Phantom property for type inference
|
|
22
|
-
*
|
|
23
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
24
|
-
* @template Version OpenAPI version ("3.0" or "3.1")
|
|
25
|
-
* @template Types Tuple of original TypeScript types
|
|
26
|
-
*/
|
|
27
|
-
export type IJsonSchemaCollection<
|
|
28
|
-
Version extends "3.0" | "3.1" = "3.1",
|
|
29
|
-
Types = unknown[],
|
|
30
|
-
> = Version extends "3.0"
|
|
31
|
-
? IJsonSchemaCollection.IV3_0<Types>
|
|
32
|
-
: IJsonSchemaCollection.IV3_1<Types>;
|
|
33
|
-
|
|
34
|
-
export namespace IJsonSchemaCollection {
|
|
35
|
-
/**
|
|
36
|
-
* JSON Schema collection for OpenAPI v3.0 specification.
|
|
37
|
-
*
|
|
38
|
-
* Uses OpenAPI v3.0 compatible JSON Schema format. In v3.0, nullable types
|
|
39
|
-
* are expressed with `nullable: true` rather than v3.1's `type` arrays.
|
|
40
|
-
*
|
|
41
|
-
* @template Types Tuple of original TypeScript types for phantom type
|
|
42
|
-
* preservation
|
|
43
|
-
*/
|
|
44
|
-
export interface IV3_0<Types = unknown[]> {
|
|
45
|
-
/**
|
|
46
|
-
* OpenAPI specification version.
|
|
47
|
-
*
|
|
48
|
-
* Always `"3.0"` for this variant. Use this discriminator to determine
|
|
49
|
-
* which schema format is in use.
|
|
50
|
-
*/
|
|
51
|
-
version: "3.0";
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Generated JSON schemas, one per input type.
|
|
55
|
-
*
|
|
56
|
-
* Array of schemas in the same order as the input type tuple. Each schema
|
|
57
|
-
* may reference definitions in {@link components}.
|
|
58
|
-
*/
|
|
59
|
-
schemas: OpenApiV3.IJsonSchema[];
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Shared schema definitions for `$ref` references.
|
|
63
|
-
*
|
|
64
|
-
* Contains named schemas used across multiple types in the collection.
|
|
65
|
-
* Reduces duplication when types share common structures.
|
|
66
|
-
*/
|
|
67
|
-
components: OpenApiV3.IComponents;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Phantom property for TypeScript generic type preservation.
|
|
71
|
-
*
|
|
72
|
-
* This property exists only in the type system to preserve the `Types`
|
|
73
|
-
* generic parameter. It is always `undefined` at runtime and should not be
|
|
74
|
-
* accessed or used in application code.
|
|
75
|
-
*/
|
|
76
|
-
__types?: Types | undefined;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* JSON Schema collection for OpenAPI v3.1 specification.
|
|
81
|
-
*
|
|
82
|
-
* Uses OpenAPI v3.1 compatible JSON Schema format. v3.1 aligns more closely
|
|
83
|
-
* with JSON Schema draft 2020-12, supporting features like `type` arrays for
|
|
84
|
-
* nullable types and `const` values.
|
|
85
|
-
*
|
|
86
|
-
* @template Types Tuple of original TypeScript types for phantom type
|
|
87
|
-
* preservation
|
|
88
|
-
*/
|
|
89
|
-
export interface IV3_1<Types = unknown[]> {
|
|
90
|
-
/**
|
|
91
|
-
* OpenAPI specification version.
|
|
92
|
-
*
|
|
93
|
-
* Always `"3.1"` for this variant. Use this discriminator to determine
|
|
94
|
-
* which schema format is in use.
|
|
95
|
-
*/
|
|
96
|
-
version: "3.1";
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Shared schema definitions for `$ref` references.
|
|
100
|
-
*
|
|
101
|
-
* Contains named schemas used across multiple types in the collection.
|
|
102
|
-
* Reduces duplication when types share common structures.
|
|
103
|
-
*/
|
|
104
|
-
components: OpenApi.IComponents;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Generated JSON schemas, one per input type.
|
|
108
|
-
*
|
|
109
|
-
* Array of schemas in the same order as the input type tuple. Each schema
|
|
110
|
-
* may reference definitions in {@link components}.
|
|
111
|
-
*/
|
|
112
|
-
schemas: OpenApi.IJsonSchema[];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Phantom property for TypeScript generic type preservation.
|
|
116
|
-
*
|
|
117
|
-
* This property exists only in the type system to preserve the `Types`
|
|
118
|
-
* generic parameter. It is always `undefined` at runtime and should not be
|
|
119
|
-
* accessed or used in application code.
|
|
120
|
-
*/
|
|
121
|
-
__types?: Types | undefined;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
import { OpenApi } from "../openapi/OpenApi";
|
|
2
|
+
import { OpenApiV3 } from "../openapi/OpenApiV3";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Collection of JSON schemas generated from multiple TypeScript types.
|
|
6
|
+
*
|
|
7
|
+
* `IJsonSchemaCollection` holds JSON schemas for multiple TypeScript types
|
|
8
|
+
* generated at compile time by `typia.json.schemas<[T1, T2, ...]>()`. The
|
|
9
|
+
* schemas share a common components pool to avoid duplication when types
|
|
10
|
+
* reference each other.
|
|
11
|
+
*
|
|
12
|
+
* This is useful when you need schemas for multiple related types and want to
|
|
13
|
+
* share component definitions between them. For single types, use
|
|
14
|
+
* {@link IJsonSchemaUnit} instead. For function schemas, see
|
|
15
|
+
* {@link IJsonSchemaApplication}.
|
|
16
|
+
*
|
|
17
|
+
* The collection contains:
|
|
18
|
+
*
|
|
19
|
+
* - {@link IV3_1.schemas | schemas}: Array of schemas, one per input type
|
|
20
|
+
* - {@link IV3_1.components | components}: Shared `$ref` definitions
|
|
21
|
+
* - {@link IV3_1.__types | __types}: Phantom property for type inference
|
|
22
|
+
*
|
|
23
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
24
|
+
* @template Version OpenAPI version ("3.0" or "3.1")
|
|
25
|
+
* @template Types Tuple of original TypeScript types
|
|
26
|
+
*/
|
|
27
|
+
export type IJsonSchemaCollection<
|
|
28
|
+
Version extends "3.0" | "3.1" = "3.1",
|
|
29
|
+
Types = unknown[],
|
|
30
|
+
> = Version extends "3.0"
|
|
31
|
+
? IJsonSchemaCollection.IV3_0<Types>
|
|
32
|
+
: IJsonSchemaCollection.IV3_1<Types>;
|
|
33
|
+
|
|
34
|
+
export namespace IJsonSchemaCollection {
|
|
35
|
+
/**
|
|
36
|
+
* JSON Schema collection for OpenAPI v3.0 specification.
|
|
37
|
+
*
|
|
38
|
+
* Uses OpenAPI v3.0 compatible JSON Schema format. In v3.0, nullable types
|
|
39
|
+
* are expressed with `nullable: true` rather than v3.1's `type` arrays.
|
|
40
|
+
*
|
|
41
|
+
* @template Types Tuple of original TypeScript types for phantom type
|
|
42
|
+
* preservation
|
|
43
|
+
*/
|
|
44
|
+
export interface IV3_0<Types = unknown[]> {
|
|
45
|
+
/**
|
|
46
|
+
* OpenAPI specification version.
|
|
47
|
+
*
|
|
48
|
+
* Always `"3.0"` for this variant. Use this discriminator to determine
|
|
49
|
+
* which schema format is in use.
|
|
50
|
+
*/
|
|
51
|
+
version: "3.0";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generated JSON schemas, one per input type.
|
|
55
|
+
*
|
|
56
|
+
* Array of schemas in the same order as the input type tuple. Each schema
|
|
57
|
+
* may reference definitions in {@link components}.
|
|
58
|
+
*/
|
|
59
|
+
schemas: OpenApiV3.IJsonSchema[];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Shared schema definitions for `$ref` references.
|
|
63
|
+
*
|
|
64
|
+
* Contains named schemas used across multiple types in the collection.
|
|
65
|
+
* Reduces duplication when types share common structures.
|
|
66
|
+
*/
|
|
67
|
+
components: OpenApiV3.IComponents;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Phantom property for TypeScript generic type preservation.
|
|
71
|
+
*
|
|
72
|
+
* This property exists only in the type system to preserve the `Types`
|
|
73
|
+
* generic parameter. It is always `undefined` at runtime and should not be
|
|
74
|
+
* accessed or used in application code.
|
|
75
|
+
*/
|
|
76
|
+
__types?: Types | undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* JSON Schema collection for OpenAPI v3.1 specification.
|
|
81
|
+
*
|
|
82
|
+
* Uses OpenAPI v3.1 compatible JSON Schema format. v3.1 aligns more closely
|
|
83
|
+
* with JSON Schema draft 2020-12, supporting features like `type` arrays for
|
|
84
|
+
* nullable types and `const` values.
|
|
85
|
+
*
|
|
86
|
+
* @template Types Tuple of original TypeScript types for phantom type
|
|
87
|
+
* preservation
|
|
88
|
+
*/
|
|
89
|
+
export interface IV3_1<Types = unknown[]> {
|
|
90
|
+
/**
|
|
91
|
+
* OpenAPI specification version.
|
|
92
|
+
*
|
|
93
|
+
* Always `"3.1"` for this variant. Use this discriminator to determine
|
|
94
|
+
* which schema format is in use.
|
|
95
|
+
*/
|
|
96
|
+
version: "3.1";
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Shared schema definitions for `$ref` references.
|
|
100
|
+
*
|
|
101
|
+
* Contains named schemas used across multiple types in the collection.
|
|
102
|
+
* Reduces duplication when types share common structures.
|
|
103
|
+
*/
|
|
104
|
+
components: OpenApi.IComponents;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Generated JSON schemas, one per input type.
|
|
108
|
+
*
|
|
109
|
+
* Array of schemas in the same order as the input type tuple. Each schema
|
|
110
|
+
* may reference definitions in {@link components}.
|
|
111
|
+
*/
|
|
112
|
+
schemas: OpenApi.IJsonSchema[];
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Phantom property for TypeScript generic type preservation.
|
|
116
|
+
*
|
|
117
|
+
* This property exists only in the type system to preserve the `Types`
|
|
118
|
+
* generic parameter. It is always `undefined` at runtime and should not be
|
|
119
|
+
* accessed or used in application code.
|
|
120
|
+
*/
|
|
121
|
+
__types?: Types | undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|