@typia/utils 12.0.0-dev.20260309 → 12.0.0-dev.20260311

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.
Files changed (103) hide show
  1. package/lib/converters/LlmSchemaConverter.d.ts +0 -1
  2. package/lib/converters/LlmSchemaConverter.js +4 -31
  3. package/lib/converters/LlmSchemaConverter.js.map +1 -1
  4. package/lib/converters/LlmSchemaConverter.mjs +2 -32
  5. package/lib/converters/LlmSchemaConverter.mjs.map +1 -1
  6. package/lib/http/HttpLlm.js +4 -5
  7. package/lib/http/HttpLlm.js.map +1 -1
  8. package/lib/http/HttpLlm.mjs +0 -1
  9. package/lib/http/HttpLlm.mjs.map +1 -1
  10. package/lib/http/internal/HttpLlmApplicationComposer.js +3 -4
  11. package/lib/http/internal/HttpLlmApplicationComposer.js.map +1 -1
  12. package/lib/http/internal/HttpLlmApplicationComposer.mjs +5 -2
  13. package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -1
  14. package/lib/index.mjs +9 -9
  15. package/lib/utils/LlmJson.mjs +9 -2
  16. package/lib/utils/LlmJson.mjs.map +1 -1
  17. package/lib/utils/internal/stringifyValidationFailure.js +17 -15
  18. package/lib/utils/internal/stringifyValidationFailure.js.map +1 -1
  19. package/lib/utils/internal/stringifyValidationFailure.mjs +17 -15
  20. package/lib/utils/internal/stringifyValidationFailure.mjs.map +1 -1
  21. package/lib/validators/internal/OpenApiOneOfValidator.mjs +5 -1
  22. package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -1
  23. package/package.json +2 -2
  24. package/src/converters/LlmSchemaConverter.ts +617 -647
  25. package/src/converters/OpenApiConverter.ts +285 -285
  26. package/src/converters/index.ts +5 -5
  27. package/src/converters/internal/LlmDescriptionInverter.ts +178 -178
  28. package/src/converters/internal/LlmParametersComposer.ts +52 -52
  29. package/src/converters/internal/OpenApiConstraintShifter.ts +154 -154
  30. package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -46
  31. package/src/converters/internal/OpenApiV3Downgrader.ts +355 -355
  32. package/src/converters/internal/OpenApiV3Upgrader.ts +470 -470
  33. package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -685
  34. package/src/converters/internal/SwaggerV2Downgrader.ts +424 -424
  35. package/src/converters/internal/SwaggerV2Upgrader.ts +523 -523
  36. package/src/http/HttpError.ts +107 -107
  37. package/src/http/HttpLlm.ts +166 -167
  38. package/src/http/HttpMigration.ts +92 -92
  39. package/src/http/index.ts +3 -3
  40. package/src/http/internal/HttpLlmApplicationComposer.ts +360 -361
  41. package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -37
  42. package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -56
  43. package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -135
  44. package/src/http/internal/HttpMigrateRouteComposer.ts +505 -505
  45. package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -203
  46. package/src/index.ts +4 -4
  47. package/src/utils/ArrayUtil.ts +42 -42
  48. package/src/utils/LlmJson.ts +141 -141
  49. package/src/utils/MapUtil.ts +15 -15
  50. package/src/utils/NamingConvention.ts +205 -205
  51. package/src/utils/Singleton.ts +17 -17
  52. package/src/utils/StringUtil.ts +14 -14
  53. package/src/utils/dedent.ts +57 -57
  54. package/src/utils/index.ts +8 -8
  55. package/src/utils/internal/EndpointUtil.ts +44 -44
  56. package/src/utils/internal/JsonDescriptor.ts +70 -70
  57. package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -822
  58. package/src/utils/internal/coerceLlmArguments.ts +314 -314
  59. package/src/utils/internal/parseLenientJson.ts +894 -894
  60. package/src/utils/internal/stringifyValidationFailure.ts +415 -411
  61. package/src/validators/LlmTypeChecker.ts +402 -402
  62. package/src/validators/OpenApiTypeChecker.ts +297 -297
  63. package/src/validators/OpenApiV3TypeChecker.ts +70 -70
  64. package/src/validators/OpenApiV3_1TypeChecker.ts +86 -86
  65. package/src/validators/OpenApiValidator.ts +94 -94
  66. package/src/validators/SwaggerV2TypeChecker.ts +71 -71
  67. package/src/validators/functional/_isBigintString.ts +8 -8
  68. package/src/validators/functional/_isFormatByte.ts +7 -7
  69. package/src/validators/functional/_isFormatDate.ts +3 -3
  70. package/src/validators/functional/_isFormatDateTime.ts +4 -4
  71. package/src/validators/functional/_isFormatDuration.ts +4 -4
  72. package/src/validators/functional/_isFormatEmail.ts +4 -4
  73. package/src/validators/functional/_isFormatHostname.ts +4 -4
  74. package/src/validators/functional/_isFormatIdnEmail.ts +4 -4
  75. package/src/validators/functional/_isFormatIdnHostname.ts +4 -4
  76. package/src/validators/functional/_isFormatIpv4.ts +4 -4
  77. package/src/validators/functional/_isFormatIpv6.ts +4 -4
  78. package/src/validators/functional/_isFormatIri.ts +3 -3
  79. package/src/validators/functional/_isFormatIriReference.ts +4 -4
  80. package/src/validators/functional/_isFormatJsonPointer.ts +3 -3
  81. package/src/validators/functional/_isFormatPassword.ts +1 -1
  82. package/src/validators/functional/_isFormatRegex.ts +8 -8
  83. package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -4
  84. package/src/validators/functional/_isFormatTime.ts +4 -4
  85. package/src/validators/functional/_isFormatUri.ts +6 -6
  86. package/src/validators/functional/_isFormatUriReference.ts +5 -5
  87. package/src/validators/functional/_isFormatUriTemplate.ts +4 -4
  88. package/src/validators/functional/_isFormatUrl.ts +4 -4
  89. package/src/validators/functional/_isFormatUuid.ts +3 -3
  90. package/src/validators/functional/_isUniqueItems.ts +159 -159
  91. package/src/validators/index.ts +14 -14
  92. package/src/validators/internal/IOpenApiValidatorContext.ts +17 -17
  93. package/src/validators/internal/OpenApiArrayValidator.ts +49 -49
  94. package/src/validators/internal/OpenApiBooleanValidator.ts +11 -11
  95. package/src/validators/internal/OpenApiConstantValidator.ts +11 -11
  96. package/src/validators/internal/OpenApiIntegerValidator.ts +49 -49
  97. package/src/validators/internal/OpenApiNumberValidator.ts +48 -48
  98. package/src/validators/internal/OpenApiObjectValidator.ts +83 -83
  99. package/src/validators/internal/OpenApiOneOfValidator.ts +309 -309
  100. package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -124
  101. package/src/validators/internal/OpenApiStationValidator.ts +115 -115
  102. package/src/validators/internal/OpenApiStringValidator.ts +88 -88
  103. package/src/validators/internal/OpenApiTupleValidator.ts +55 -55
@@ -1,297 +1,297 @@
1
- import { IJsonSchemaTransformError, IResult, OpenApi } from "@typia/interface";
2
-
3
- import { OpenApiTypeCheckerBase } from "../utils/internal/OpenApiTypeCheckerBase";
4
-
5
- /**
6
- * Type checker for emended OpenAPI v3.1 JSON schemas.
7
- *
8
- * `OpenApiTypeChecker` provides type guard functions for
9
- * {@link OpenApi.IJsonSchema} (typia's normalized OpenAPI format). Use these to
10
- * narrow schema types before accessing type-specific properties.
11
- *
12
- * Type checkers:
13
- *
14
- * - Primitives: {@link isNull}, {@link isBoolean}, {@link isInteger},
15
- * {@link isNumber}, {@link isString}
16
- * - Constants: {@link isConstant}
17
- * - Collections: {@link isArray}, {@link isTuple}, {@link isObject}
18
- * - Composition: {@link isOneOf}, {@link isReference}
19
- * - Special: {@link isUnknown}
20
- *
21
- * Also provides schema operations:
22
- *
23
- * - {@link visit}: Traverse and transform schemas recursively
24
- * - {@link covers}: Check if one schema subsumes another
25
- * - {@link escape}: Unwrap reference schemas
26
- *
27
- * For other OpenAPI versions, use {@link OpenApiV3TypeChecker},
28
- * {@link OpenApiV3_1TypeChecker}, or {@link SwaggerV2TypeChecker}.
29
- *
30
- * @author Jeongho Nam - https://github.com/samchon
31
- */
32
- export namespace OpenApiTypeChecker {
33
- /* -----------------------------------------------------------
34
- TYPE CHECKERS
35
- ----------------------------------------------------------- */
36
- /**
37
- * Test whether the schema is a nul type.
38
- *
39
- * @param schema Target schema
40
- * @returns Whether null type or not
41
- */
42
- export const isNull = (
43
- schema: OpenApi.IJsonSchema,
44
- ): schema is OpenApi.IJsonSchema.INull =>
45
- OpenApiTypeCheckerBase.isNull(schema);
46
-
47
- /**
48
- * Test whether the schema is an unknown type.
49
- *
50
- * @param schema Target schema
51
- * @returns Whether unknown type or not
52
- */
53
- export const isUnknown = (
54
- schema: OpenApi.IJsonSchema,
55
- ): schema is OpenApi.IJsonSchema.IUnknown =>
56
- OpenApiTypeCheckerBase.isUnknown(schema);
57
-
58
- /**
59
- * Test whether the schema is a constant type.
60
- *
61
- * @param schema Target schema
62
- * @returns Whether constant type or not
63
- */
64
- export const isConstant = (
65
- schema: OpenApi.IJsonSchema,
66
- ): schema is OpenApi.IJsonSchema.IConstant =>
67
- OpenApiTypeCheckerBase.isConstant(schema);
68
-
69
- /**
70
- * Test whether the schema is a boolean type.
71
- *
72
- * @param schema Target schema
73
- * @returns Whether boolean type or not
74
- */
75
- export const isBoolean = (
76
- schema: OpenApi.IJsonSchema,
77
- ): schema is OpenApi.IJsonSchema.IBoolean =>
78
- OpenApiTypeCheckerBase.isBoolean(schema);
79
-
80
- /**
81
- * Test whether the schema is an integer type.
82
- *
83
- * @param schema Target schema
84
- * @returns Whether integer type or not
85
- */
86
- export const isInteger = (
87
- schema: OpenApi.IJsonSchema,
88
- ): schema is OpenApi.IJsonSchema.IInteger =>
89
- OpenApiTypeCheckerBase.isInteger(schema);
90
-
91
- /**
92
- * Test whether the schema is a number type.
93
- *
94
- * @param schema Target schema
95
- * @returns Whether number type or not
96
- */
97
- export const isNumber = (
98
- schema: OpenApi.IJsonSchema,
99
- ): schema is OpenApi.IJsonSchema.INumber =>
100
- OpenApiTypeCheckerBase.isNumber(schema);
101
-
102
- /**
103
- * Test whether the schema is a string type.
104
- *
105
- * @param schema Target schema
106
- * @returns Whether string type or not
107
- */
108
- export const isString = (
109
- schema: OpenApi.IJsonSchema,
110
- ): schema is OpenApi.IJsonSchema.IString =>
111
- OpenApiTypeCheckerBase.isString(schema);
112
-
113
- /**
114
- * Test whether the schema is an array type.
115
- *
116
- * @param schema Target schema
117
- * @returns Whether array type or not
118
- */
119
- export const isArray = (
120
- schema: OpenApi.IJsonSchema,
121
- ): schema is OpenApi.IJsonSchema.IArray =>
122
- OpenApiTypeCheckerBase.isArray(schema);
123
-
124
- /**
125
- * Test whether the schema is a tuple type.
126
- *
127
- * @param schema Target schema
128
- * @returns Whether tuple type or not
129
- */
130
- export const isTuple = (
131
- schema: OpenApi.IJsonSchema,
132
- ): schema is OpenApi.IJsonSchema.ITuple =>
133
- OpenApiTypeCheckerBase.isTuple(schema);
134
-
135
- /**
136
- * Test whether the schema is an object type.
137
- *
138
- * @param schema Target schema
139
- * @returns Whether object type or not
140
- */
141
- export const isObject = (
142
- schema: OpenApi.IJsonSchema,
143
- ): schema is OpenApi.IJsonSchema.IObject =>
144
- OpenApiTypeCheckerBase.isObject(schema);
145
-
146
- /**
147
- * Test whether the schema is a reference type.
148
- *
149
- * @param schema Target schema
150
- * @returns Whether reference type or not
151
- */
152
- export const isReference = (
153
- schema: OpenApi.IJsonSchema,
154
- ): schema is OpenApi.IJsonSchema.IReference =>
155
- OpenApiTypeCheckerBase.isReference(schema);
156
-
157
- /**
158
- * Test whether the schema is an union type.
159
- *
160
- * @param schema Target schema
161
- * @returns Whether union type or not
162
- */
163
- export const isOneOf = (
164
- schema: OpenApi.IJsonSchema,
165
- ): schema is OpenApi.IJsonSchema.IOneOf =>
166
- OpenApiTypeCheckerBase.isOneOf(schema);
167
-
168
- /**
169
- * Test whether the schema is recursive reference type.
170
- *
171
- * Test whether the target schema is a reference type, and test one thing more
172
- * that the reference is self-recursive or not.
173
- *
174
- * @param props Properties for recursive reference test
175
- * @returns Whether the schema is recursive reference type or not
176
- */
177
- export const isRecursiveReference = (props: {
178
- components: OpenApi.IComponents;
179
- schema: OpenApi.IJsonSchema;
180
- }): boolean =>
181
- OpenApiTypeCheckerBase.isRecursiveReference({
182
- prefix: "#/components/schemas/",
183
- components: props.components,
184
- schema: props.schema,
185
- });
186
-
187
- /* -----------------------------------------------------------
188
- OPERATORS
189
- ----------------------------------------------------------- */
190
- /**
191
- * Escape from the {@link OpenApi.IJsonSchema.IReference} type.
192
- *
193
- * Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the
194
- * every references to the actual schemas. If the escape is successful, the
195
- * returned schema never contains any {@link OpenApi.IJsonSchema.IReference}
196
- * type in its structure.
197
- *
198
- * If the schema has a recursive reference, the recursive reference would be
199
- * repeated as much as the `props.recursive` depth. If you've configured the
200
- * `props.recursive` as `false` or `0`, it would be failed and return an
201
- * {@link IJsonSchemaTransformError}. Also, if there's a
202
- * {@link OpenApi.IJsonSchema.IReference} type which cannot find the matched
203
- * type in the {@link OpenApi.IComponents.schemas}, it would also be failed and
204
- * return an {@link IJsonSchemaTransformError} either.
205
- *
206
- * @param props Properties for escaping
207
- * @returns Escaped schema, or error with reason
208
- */
209
- export const escape = (props: {
210
- components: OpenApi.IComponents;
211
- schema: OpenApi.IJsonSchema;
212
- recursive: false | number;
213
- accessor?: string;
214
- refAccessor?: string;
215
- }): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
216
- OpenApiTypeCheckerBase.escape({
217
- ...props,
218
- prefix: "#/components/schemas/",
219
- method: "OpenApiTypeChecker.method",
220
- });
221
-
222
- /**
223
- * Unreference the schema.
224
- *
225
- * Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference}
226
- * type to the actual schema. Different with {@link escape} is, the
227
- * `unreference` function does not resolve every references in the schema, but
228
- * resolve only one time.
229
- *
230
- * If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find
231
- * the matched type in the {@link OpenApi.IComponents.schemas}, and you've
232
- * called this `unreference()` function with the reference, it would also be
233
- * failed and return an {@link IJsonSchemaTransformError} value.
234
- *
235
- * @param props Properties of unreference
236
- * @returns Unreferenced schema
237
- */
238
- export const unreference = (props: {
239
- components: OpenApi.IComponents;
240
- schema: OpenApi.IJsonSchema;
241
- accessor?: string;
242
- refAccessor?: string;
243
- }): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
244
- OpenApiTypeCheckerBase.unreference({
245
- ...props,
246
- prefix: "#/components/schemas/",
247
- method: "OpenApiTypeChecker.unreference",
248
- });
249
-
250
- /**
251
- * Visit every nested schemas.
252
- *
253
- * Visit every nested schemas of the target, and apply the `props.closure`
254
- * function.
255
- *
256
- * Here is the list of occurring nested visitings:
257
- *
258
- * - {@link OpenApi.IJsonSchema.IOneOf.oneOf}
259
- * - {@link OpenApi.IJsonSchema.IReference}
260
- * - {@link OpenApi.IJsonSchema.IObject.properties}
261
- * - {@link OpenApi.IJsonSchema.IObject.additionalProperties}
262
- * - {@link OpenApi.IJsonSchema.IArray.items}
263
- * - {@link OpenApi.IJsonSchema.ITuple.prefixItems}
264
- * - {@link OpenApi.IJsonSchema.ITuple.additionalItems}
265
- *
266
- * @param props Properties for visiting
267
- */
268
- export const visit = (props: {
269
- closure: (schema: OpenApi.IJsonSchema, accessor: string) => void;
270
- components: OpenApi.IComponents;
271
- schema: OpenApi.IJsonSchema;
272
- accessor?: string;
273
- refAccessor?: string;
274
- }): void =>
275
- OpenApiTypeCheckerBase.visit({
276
- ...props,
277
- prefix: "#/components/schemas/",
278
- });
279
-
280
- /**
281
- * Test whether the `x` schema covers the `y` schema.
282
- *
283
- * @param props Properties for testing
284
- * @returns Whether the `x` schema covers the `y` schema
285
- */
286
- export const covers = (props: {
287
- components: OpenApi.IComponents;
288
- x: OpenApi.IJsonSchema;
289
- y: OpenApi.IJsonSchema;
290
- }): boolean =>
291
- OpenApiTypeCheckerBase.covers({
292
- prefix: "#/components/schemas/",
293
- components: props.components,
294
- x: props.x,
295
- y: props.y,
296
- });
297
- }
1
+ import { IJsonSchemaTransformError, IResult, OpenApi } from "@typia/interface";
2
+
3
+ import { OpenApiTypeCheckerBase } from "../utils/internal/OpenApiTypeCheckerBase";
4
+
5
+ /**
6
+ * Type checker for emended OpenAPI v3.1 JSON schemas.
7
+ *
8
+ * `OpenApiTypeChecker` provides type guard functions for
9
+ * {@link OpenApi.IJsonSchema} (typia's normalized OpenAPI format). Use these to
10
+ * narrow schema types before accessing type-specific properties.
11
+ *
12
+ * Type checkers:
13
+ *
14
+ * - Primitives: {@link isNull}, {@link isBoolean}, {@link isInteger},
15
+ * {@link isNumber}, {@link isString}
16
+ * - Constants: {@link isConstant}
17
+ * - Collections: {@link isArray}, {@link isTuple}, {@link isObject}
18
+ * - Composition: {@link isOneOf}, {@link isReference}
19
+ * - Special: {@link isUnknown}
20
+ *
21
+ * Also provides schema operations:
22
+ *
23
+ * - {@link visit}: Traverse and transform schemas recursively
24
+ * - {@link covers}: Check if one schema subsumes another
25
+ * - {@link escape}: Unwrap reference schemas
26
+ *
27
+ * For other OpenAPI versions, use {@link OpenApiV3TypeChecker},
28
+ * {@link OpenApiV3_1TypeChecker}, or {@link SwaggerV2TypeChecker}.
29
+ *
30
+ * @author Jeongho Nam - https://github.com/samchon
31
+ */
32
+ export namespace OpenApiTypeChecker {
33
+ /* -----------------------------------------------------------
34
+ TYPE CHECKERS
35
+ ----------------------------------------------------------- */
36
+ /**
37
+ * Test whether the schema is a nul type.
38
+ *
39
+ * @param schema Target schema
40
+ * @returns Whether null type or not
41
+ */
42
+ export const isNull = (
43
+ schema: OpenApi.IJsonSchema,
44
+ ): schema is OpenApi.IJsonSchema.INull =>
45
+ OpenApiTypeCheckerBase.isNull(schema);
46
+
47
+ /**
48
+ * Test whether the schema is an unknown type.
49
+ *
50
+ * @param schema Target schema
51
+ * @returns Whether unknown type or not
52
+ */
53
+ export const isUnknown = (
54
+ schema: OpenApi.IJsonSchema,
55
+ ): schema is OpenApi.IJsonSchema.IUnknown =>
56
+ OpenApiTypeCheckerBase.isUnknown(schema);
57
+
58
+ /**
59
+ * Test whether the schema is a constant type.
60
+ *
61
+ * @param schema Target schema
62
+ * @returns Whether constant type or not
63
+ */
64
+ export const isConstant = (
65
+ schema: OpenApi.IJsonSchema,
66
+ ): schema is OpenApi.IJsonSchema.IConstant =>
67
+ OpenApiTypeCheckerBase.isConstant(schema);
68
+
69
+ /**
70
+ * Test whether the schema is a boolean type.
71
+ *
72
+ * @param schema Target schema
73
+ * @returns Whether boolean type or not
74
+ */
75
+ export const isBoolean = (
76
+ schema: OpenApi.IJsonSchema,
77
+ ): schema is OpenApi.IJsonSchema.IBoolean =>
78
+ OpenApiTypeCheckerBase.isBoolean(schema);
79
+
80
+ /**
81
+ * Test whether the schema is an integer type.
82
+ *
83
+ * @param schema Target schema
84
+ * @returns Whether integer type or not
85
+ */
86
+ export const isInteger = (
87
+ schema: OpenApi.IJsonSchema,
88
+ ): schema is OpenApi.IJsonSchema.IInteger =>
89
+ OpenApiTypeCheckerBase.isInteger(schema);
90
+
91
+ /**
92
+ * Test whether the schema is a number type.
93
+ *
94
+ * @param schema Target schema
95
+ * @returns Whether number type or not
96
+ */
97
+ export const isNumber = (
98
+ schema: OpenApi.IJsonSchema,
99
+ ): schema is OpenApi.IJsonSchema.INumber =>
100
+ OpenApiTypeCheckerBase.isNumber(schema);
101
+
102
+ /**
103
+ * Test whether the schema is a string type.
104
+ *
105
+ * @param schema Target schema
106
+ * @returns Whether string type or not
107
+ */
108
+ export const isString = (
109
+ schema: OpenApi.IJsonSchema,
110
+ ): schema is OpenApi.IJsonSchema.IString =>
111
+ OpenApiTypeCheckerBase.isString(schema);
112
+
113
+ /**
114
+ * Test whether the schema is an array type.
115
+ *
116
+ * @param schema Target schema
117
+ * @returns Whether array type or not
118
+ */
119
+ export const isArray = (
120
+ schema: OpenApi.IJsonSchema,
121
+ ): schema is OpenApi.IJsonSchema.IArray =>
122
+ OpenApiTypeCheckerBase.isArray(schema);
123
+
124
+ /**
125
+ * Test whether the schema is a tuple type.
126
+ *
127
+ * @param schema Target schema
128
+ * @returns Whether tuple type or not
129
+ */
130
+ export const isTuple = (
131
+ schema: OpenApi.IJsonSchema,
132
+ ): schema is OpenApi.IJsonSchema.ITuple =>
133
+ OpenApiTypeCheckerBase.isTuple(schema);
134
+
135
+ /**
136
+ * Test whether the schema is an object type.
137
+ *
138
+ * @param schema Target schema
139
+ * @returns Whether object type or not
140
+ */
141
+ export const isObject = (
142
+ schema: OpenApi.IJsonSchema,
143
+ ): schema is OpenApi.IJsonSchema.IObject =>
144
+ OpenApiTypeCheckerBase.isObject(schema);
145
+
146
+ /**
147
+ * Test whether the schema is a reference type.
148
+ *
149
+ * @param schema Target schema
150
+ * @returns Whether reference type or not
151
+ */
152
+ export const isReference = (
153
+ schema: OpenApi.IJsonSchema,
154
+ ): schema is OpenApi.IJsonSchema.IReference =>
155
+ OpenApiTypeCheckerBase.isReference(schema);
156
+
157
+ /**
158
+ * Test whether the schema is an union type.
159
+ *
160
+ * @param schema Target schema
161
+ * @returns Whether union type or not
162
+ */
163
+ export const isOneOf = (
164
+ schema: OpenApi.IJsonSchema,
165
+ ): schema is OpenApi.IJsonSchema.IOneOf =>
166
+ OpenApiTypeCheckerBase.isOneOf(schema);
167
+
168
+ /**
169
+ * Test whether the schema is recursive reference type.
170
+ *
171
+ * Test whether the target schema is a reference type, and test one thing more
172
+ * that the reference is self-recursive or not.
173
+ *
174
+ * @param props Properties for recursive reference test
175
+ * @returns Whether the schema is recursive reference type or not
176
+ */
177
+ export const isRecursiveReference = (props: {
178
+ components: OpenApi.IComponents;
179
+ schema: OpenApi.IJsonSchema;
180
+ }): boolean =>
181
+ OpenApiTypeCheckerBase.isRecursiveReference({
182
+ prefix: "#/components/schemas/",
183
+ components: props.components,
184
+ schema: props.schema,
185
+ });
186
+
187
+ /* -----------------------------------------------------------
188
+ OPERATORS
189
+ ----------------------------------------------------------- */
190
+ /**
191
+ * Escape from the {@link OpenApi.IJsonSchema.IReference} type.
192
+ *
193
+ * Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the
194
+ * every references to the actual schemas. If the escape is successful, the
195
+ * returned schema never contains any {@link OpenApi.IJsonSchema.IReference}
196
+ * type in its structure.
197
+ *
198
+ * If the schema has a recursive reference, the recursive reference would be
199
+ * repeated as much as the `props.recursive` depth. If you've configured the
200
+ * `props.recursive` as `false` or `0`, it would be failed and return an
201
+ * {@link IJsonSchemaTransformError}. Also, if there's a
202
+ * {@link OpenApi.IJsonSchema.IReference} type which cannot find the matched
203
+ * type in the {@link OpenApi.IComponents.schemas}, it would also be failed and
204
+ * return an {@link IJsonSchemaTransformError} either.
205
+ *
206
+ * @param props Properties for escaping
207
+ * @returns Escaped schema, or error with reason
208
+ */
209
+ export const escape = (props: {
210
+ components: OpenApi.IComponents;
211
+ schema: OpenApi.IJsonSchema;
212
+ recursive: false | number;
213
+ accessor?: string;
214
+ refAccessor?: string;
215
+ }): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
216
+ OpenApiTypeCheckerBase.escape({
217
+ ...props,
218
+ prefix: "#/components/schemas/",
219
+ method: "OpenApiTypeChecker.method",
220
+ });
221
+
222
+ /**
223
+ * Unreference the schema.
224
+ *
225
+ * Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference}
226
+ * type to the actual schema. Different with {@link escape} is, the
227
+ * `unreference` function does not resolve every references in the schema, but
228
+ * resolve only one time.
229
+ *
230
+ * If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find
231
+ * the matched type in the {@link OpenApi.IComponents.schemas}, and you've
232
+ * called this `unreference()` function with the reference, it would also be
233
+ * failed and return an {@link IJsonSchemaTransformError} value.
234
+ *
235
+ * @param props Properties of unreference
236
+ * @returns Unreferenced schema
237
+ */
238
+ export const unreference = (props: {
239
+ components: OpenApi.IComponents;
240
+ schema: OpenApi.IJsonSchema;
241
+ accessor?: string;
242
+ refAccessor?: string;
243
+ }): IResult<OpenApi.IJsonSchema, IJsonSchemaTransformError> =>
244
+ OpenApiTypeCheckerBase.unreference({
245
+ ...props,
246
+ prefix: "#/components/schemas/",
247
+ method: "OpenApiTypeChecker.unreference",
248
+ });
249
+
250
+ /**
251
+ * Visit every nested schemas.
252
+ *
253
+ * Visit every nested schemas of the target, and apply the `props.closure`
254
+ * function.
255
+ *
256
+ * Here is the list of occurring nested visitings:
257
+ *
258
+ * - {@link OpenApi.IJsonSchema.IOneOf.oneOf}
259
+ * - {@link OpenApi.IJsonSchema.IReference}
260
+ * - {@link OpenApi.IJsonSchema.IObject.properties}
261
+ * - {@link OpenApi.IJsonSchema.IObject.additionalProperties}
262
+ * - {@link OpenApi.IJsonSchema.IArray.items}
263
+ * - {@link OpenApi.IJsonSchema.ITuple.prefixItems}
264
+ * - {@link OpenApi.IJsonSchema.ITuple.additionalItems}
265
+ *
266
+ * @param props Properties for visiting
267
+ */
268
+ export const visit = (props: {
269
+ closure: (schema: OpenApi.IJsonSchema, accessor: string) => void;
270
+ components: OpenApi.IComponents;
271
+ schema: OpenApi.IJsonSchema;
272
+ accessor?: string;
273
+ refAccessor?: string;
274
+ }): void =>
275
+ OpenApiTypeCheckerBase.visit({
276
+ ...props,
277
+ prefix: "#/components/schemas/",
278
+ });
279
+
280
+ /**
281
+ * Test whether the `x` schema covers the `y` schema.
282
+ *
283
+ * @param props Properties for testing
284
+ * @returns Whether the `x` schema covers the `y` schema
285
+ */
286
+ export const covers = (props: {
287
+ components: OpenApi.IComponents;
288
+ x: OpenApi.IJsonSchema;
289
+ y: OpenApi.IJsonSchema;
290
+ }): boolean =>
291
+ OpenApiTypeCheckerBase.covers({
292
+ prefix: "#/components/schemas/",
293
+ components: props.components,
294
+ x: props.x,
295
+ y: props.y,
296
+ });
297
+ }