@typia/utils 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.
Files changed (92) hide show
  1. package/lib/http/internal/HttpLlmApplicationComposer.mjs +5 -1
  2. package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -1
  3. package/lib/index.mjs +9 -9
  4. package/lib/utils/LlmJson.mjs +9 -2
  5. package/lib/utils/LlmJson.mjs.map +1 -1
  6. package/lib/utils/internal/stringifyValidationFailure.js +17 -15
  7. package/lib/utils/internal/stringifyValidationFailure.js.map +1 -1
  8. package/lib/utils/internal/stringifyValidationFailure.mjs +17 -15
  9. package/lib/utils/internal/stringifyValidationFailure.mjs.map +1 -1
  10. package/lib/validators/internal/OpenApiOneOfValidator.mjs +5 -1
  11. package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -1
  12. package/package.json +2 -2
  13. package/src/converters/LlmSchemaConverter.ts +647 -647
  14. package/src/converters/OpenApiConverter.ts +285 -285
  15. package/src/converters/index.ts +5 -5
  16. package/src/converters/internal/LlmDescriptionInverter.ts +178 -178
  17. package/src/converters/internal/LlmParametersComposer.ts +52 -52
  18. package/src/converters/internal/OpenApiConstraintShifter.ts +154 -154
  19. package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -46
  20. package/src/converters/internal/OpenApiV3Downgrader.ts +355 -355
  21. package/src/converters/internal/OpenApiV3Upgrader.ts +470 -470
  22. package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -685
  23. package/src/converters/internal/SwaggerV2Downgrader.ts +424 -424
  24. package/src/converters/internal/SwaggerV2Upgrader.ts +523 -523
  25. package/src/http/HttpError.ts +107 -107
  26. package/src/http/HttpLlm.ts +167 -167
  27. package/src/http/HttpMigration.ts +92 -92
  28. package/src/http/index.ts +3 -3
  29. package/src/http/internal/HttpLlmApplicationComposer.ts +361 -361
  30. package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -37
  31. package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -56
  32. package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -135
  33. package/src/http/internal/HttpMigrateRouteComposer.ts +505 -505
  34. package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -203
  35. package/src/index.ts +4 -4
  36. package/src/utils/ArrayUtil.ts +42 -42
  37. package/src/utils/LlmJson.ts +141 -141
  38. package/src/utils/MapUtil.ts +15 -15
  39. package/src/utils/NamingConvention.ts +205 -205
  40. package/src/utils/Singleton.ts +17 -17
  41. package/src/utils/StringUtil.ts +14 -14
  42. package/src/utils/dedent.ts +57 -57
  43. package/src/utils/index.ts +8 -8
  44. package/src/utils/internal/EndpointUtil.ts +44 -44
  45. package/src/utils/internal/JsonDescriptor.ts +70 -70
  46. package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -822
  47. package/src/utils/internal/coerceLlmArguments.ts +314 -314
  48. package/src/utils/internal/parseLenientJson.ts +894 -894
  49. package/src/utils/internal/stringifyValidationFailure.ts +415 -411
  50. package/src/validators/LlmTypeChecker.ts +402 -402
  51. package/src/validators/OpenApiTypeChecker.ts +297 -297
  52. package/src/validators/OpenApiV3TypeChecker.ts +70 -70
  53. package/src/validators/OpenApiV3_1TypeChecker.ts +86 -86
  54. package/src/validators/OpenApiValidator.ts +94 -94
  55. package/src/validators/SwaggerV2TypeChecker.ts +71 -71
  56. package/src/validators/functional/_isBigintString.ts +8 -8
  57. package/src/validators/functional/_isFormatByte.ts +7 -7
  58. package/src/validators/functional/_isFormatDate.ts +3 -3
  59. package/src/validators/functional/_isFormatDateTime.ts +4 -4
  60. package/src/validators/functional/_isFormatDuration.ts +4 -4
  61. package/src/validators/functional/_isFormatEmail.ts +4 -4
  62. package/src/validators/functional/_isFormatHostname.ts +4 -4
  63. package/src/validators/functional/_isFormatIdnEmail.ts +4 -4
  64. package/src/validators/functional/_isFormatIdnHostname.ts +4 -4
  65. package/src/validators/functional/_isFormatIpv4.ts +4 -4
  66. package/src/validators/functional/_isFormatIpv6.ts +4 -4
  67. package/src/validators/functional/_isFormatIri.ts +3 -3
  68. package/src/validators/functional/_isFormatIriReference.ts +4 -4
  69. package/src/validators/functional/_isFormatJsonPointer.ts +3 -3
  70. package/src/validators/functional/_isFormatPassword.ts +1 -1
  71. package/src/validators/functional/_isFormatRegex.ts +8 -8
  72. package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -4
  73. package/src/validators/functional/_isFormatTime.ts +4 -4
  74. package/src/validators/functional/_isFormatUri.ts +6 -6
  75. package/src/validators/functional/_isFormatUriReference.ts +5 -5
  76. package/src/validators/functional/_isFormatUriTemplate.ts +4 -4
  77. package/src/validators/functional/_isFormatUrl.ts +4 -4
  78. package/src/validators/functional/_isFormatUuid.ts +3 -3
  79. package/src/validators/functional/_isUniqueItems.ts +159 -159
  80. package/src/validators/index.ts +14 -14
  81. package/src/validators/internal/IOpenApiValidatorContext.ts +17 -17
  82. package/src/validators/internal/OpenApiArrayValidator.ts +49 -49
  83. package/src/validators/internal/OpenApiBooleanValidator.ts +11 -11
  84. package/src/validators/internal/OpenApiConstantValidator.ts +11 -11
  85. package/src/validators/internal/OpenApiIntegerValidator.ts +49 -49
  86. package/src/validators/internal/OpenApiNumberValidator.ts +48 -48
  87. package/src/validators/internal/OpenApiObjectValidator.ts +83 -83
  88. package/src/validators/internal/OpenApiOneOfValidator.ts +309 -309
  89. package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -124
  90. package/src/validators/internal/OpenApiStationValidator.ts +115 -115
  91. package/src/validators/internal/OpenApiStringValidator.ts +88 -88
  92. package/src/validators/internal/OpenApiTupleValidator.ts +55 -55
@@ -1,49 +1,49 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { _isUniqueItems } from "../functional/_isUniqueItems";
4
- import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
5
- import { OpenApiStationValidator } from "./OpenApiStationValidator";
6
-
7
- export namespace OpenApiArrayValidator {
8
- export const validate = (
9
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IArray>,
10
- ): boolean => {
11
- if (Array.isArray(ctx.value) === false) return ctx.report(ctx);
12
- return [
13
- ctx.value
14
- .map((value, i) =>
15
- OpenApiStationValidator.validate({
16
- ...ctx,
17
- schema: ctx.schema.items,
18
- value,
19
- path: `${ctx.path}[${i}]`,
20
- required: true,
21
- }),
22
- )
23
- .every((v) => v),
24
- ctx.schema.minItems !== undefined
25
- ? ctx.value.length >= ctx.schema.minItems ||
26
- ctx.report({
27
- ...ctx,
28
- expected: `Array<> & MinItems<${ctx.schema.minItems}>`,
29
- })
30
- : true,
31
- ctx.schema.maxItems !== undefined
32
- ? ctx.value.length <= ctx.schema.maxItems ||
33
- ctx.report({
34
- ...ctx,
35
- expected: `Array<> & MaxItems<${ctx.schema.maxItems}>`,
36
- })
37
- : true,
38
- ctx.schema.uniqueItems !== undefined
39
- ? ctx.schema.uniqueItems
40
- ? _isUniqueItems(ctx.value) ||
41
- ctx.report({
42
- ...ctx,
43
- expected: `Array<> & UniqueItems`,
44
- })
45
- : true
46
- : true,
47
- ].every((v) => v);
48
- };
49
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { _isUniqueItems } from "../functional/_isUniqueItems";
4
+ import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
5
+ import { OpenApiStationValidator } from "./OpenApiStationValidator";
6
+
7
+ export namespace OpenApiArrayValidator {
8
+ export const validate = (
9
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IArray>,
10
+ ): boolean => {
11
+ if (Array.isArray(ctx.value) === false) return ctx.report(ctx);
12
+ return [
13
+ ctx.value
14
+ .map((value, i) =>
15
+ OpenApiStationValidator.validate({
16
+ ...ctx,
17
+ schema: ctx.schema.items,
18
+ value,
19
+ path: `${ctx.path}[${i}]`,
20
+ required: true,
21
+ }),
22
+ )
23
+ .every((v) => v),
24
+ ctx.schema.minItems !== undefined
25
+ ? ctx.value.length >= ctx.schema.minItems ||
26
+ ctx.report({
27
+ ...ctx,
28
+ expected: `Array<> & MinItems<${ctx.schema.minItems}>`,
29
+ })
30
+ : true,
31
+ ctx.schema.maxItems !== undefined
32
+ ? ctx.value.length <= ctx.schema.maxItems ||
33
+ ctx.report({
34
+ ...ctx,
35
+ expected: `Array<> & MaxItems<${ctx.schema.maxItems}>`,
36
+ })
37
+ : true,
38
+ ctx.schema.uniqueItems !== undefined
39
+ ? ctx.schema.uniqueItems
40
+ ? _isUniqueItems(ctx.value) ||
41
+ ctx.report({
42
+ ...ctx,
43
+ expected: `Array<> & UniqueItems`,
44
+ })
45
+ : true
46
+ : true,
47
+ ].every((v) => v);
48
+ };
49
+ }
@@ -1,11 +1,11 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
-
5
- export namespace OpenApiBooleanValidator {
6
- export const validate = (
7
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IBoolean>,
8
- ): boolean => {
9
- return typeof ctx.value === "boolean" || ctx.report(ctx);
10
- };
11
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
+
5
+ export namespace OpenApiBooleanValidator {
6
+ export const validate = (
7
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IBoolean>,
8
+ ): boolean => {
9
+ return typeof ctx.value === "boolean" || ctx.report(ctx);
10
+ };
11
+ }
@@ -1,11 +1,11 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
-
5
- export namespace OpenApiConstantValidator {
6
- export const validate = (
7
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IConstant>,
8
- ): boolean => {
9
- return ctx.value === ctx.schema.const || ctx.report(ctx);
10
- };
11
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
+
5
+ export namespace OpenApiConstantValidator {
6
+ export const validate = (
7
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IConstant>,
8
+ ): boolean => {
9
+ return ctx.value === ctx.schema.const || ctx.report(ctx);
10
+ };
11
+ }
@@ -1,49 +1,49 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
-
5
- export namespace OpenApiIntegerValidator {
6
- export const validate = (
7
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IInteger>,
8
- ): boolean => {
9
- if (typeof ctx.value !== "number" || Math.floor(ctx.value) !== ctx.value)
10
- return ctx.report(ctx);
11
- return [
12
- ctx.schema.minimum !== undefined
13
- ? ctx.value >= ctx.schema.minimum ||
14
- ctx.report({
15
- ...ctx,
16
- expected: `number & Type<"int32"> & Minimum<${ctx.schema.minimum}>`,
17
- })
18
- : true,
19
- ctx.schema.maximum !== undefined
20
- ? ctx.value <= ctx.schema.maximum ||
21
- ctx.report({
22
- ...ctx,
23
- expected: `number & Type<"int32"> & Maximum<${ctx.schema.maximum}>`,
24
- })
25
- : true,
26
- ctx.schema.exclusiveMinimum !== undefined
27
- ? ctx.value > ctx.schema.exclusiveMinimum ||
28
- ctx.report({
29
- ...ctx,
30
- expected: `number & Type<"int32"> & ExclusiveMinimum<${ctx.schema.exclusiveMinimum}>`,
31
- })
32
- : true,
33
- ctx.schema.exclusiveMaximum !== undefined
34
- ? ctx.value < ctx.schema.exclusiveMaximum ||
35
- ctx.report({
36
- ...ctx,
37
- expected: `number & Type<"int32"> & ExclusiveMaximum<${ctx.schema.exclusiveMaximum}>`,
38
- })
39
- : true,
40
- ctx.schema.multipleOf !== undefined
41
- ? ctx.value % ctx.schema.multipleOf === 0 ||
42
- ctx.report({
43
- ...ctx,
44
- expected: `number & Type<"int32"> & MultipleOf<${ctx.schema.multipleOf}>`,
45
- })
46
- : true,
47
- ].every((v) => v);
48
- };
49
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
+
5
+ export namespace OpenApiIntegerValidator {
6
+ export const validate = (
7
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IInteger>,
8
+ ): boolean => {
9
+ if (typeof ctx.value !== "number" || Math.floor(ctx.value) !== ctx.value)
10
+ return ctx.report(ctx);
11
+ return [
12
+ ctx.schema.minimum !== undefined
13
+ ? ctx.value >= ctx.schema.minimum ||
14
+ ctx.report({
15
+ ...ctx,
16
+ expected: `number & Type<"int32"> & Minimum<${ctx.schema.minimum}>`,
17
+ })
18
+ : true,
19
+ ctx.schema.maximum !== undefined
20
+ ? ctx.value <= ctx.schema.maximum ||
21
+ ctx.report({
22
+ ...ctx,
23
+ expected: `number & Type<"int32"> & Maximum<${ctx.schema.maximum}>`,
24
+ })
25
+ : true,
26
+ ctx.schema.exclusiveMinimum !== undefined
27
+ ? ctx.value > ctx.schema.exclusiveMinimum ||
28
+ ctx.report({
29
+ ...ctx,
30
+ expected: `number & Type<"int32"> & ExclusiveMinimum<${ctx.schema.exclusiveMinimum}>`,
31
+ })
32
+ : true,
33
+ ctx.schema.exclusiveMaximum !== undefined
34
+ ? ctx.value < ctx.schema.exclusiveMaximum ||
35
+ ctx.report({
36
+ ...ctx,
37
+ expected: `number & Type<"int32"> & ExclusiveMaximum<${ctx.schema.exclusiveMaximum}>`,
38
+ })
39
+ : true,
40
+ ctx.schema.multipleOf !== undefined
41
+ ? ctx.value % ctx.schema.multipleOf === 0 ||
42
+ ctx.report({
43
+ ...ctx,
44
+ expected: `number & Type<"int32"> & MultipleOf<${ctx.schema.multipleOf}>`,
45
+ })
46
+ : true,
47
+ ].every((v) => v);
48
+ };
49
+ }
@@ -1,48 +1,48 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
-
5
- export namespace OpenApiNumberValidator {
6
- export const validate = (
7
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.INumber>,
8
- ): boolean => {
9
- if (typeof ctx.value !== "number") return ctx.report(ctx);
10
- return [
11
- ctx.schema.minimum !== undefined
12
- ? ctx.value >= ctx.schema.minimum ||
13
- ctx.report({
14
- ...ctx,
15
- expected: `number & Minimum<${ctx.schema.minimum}>`,
16
- })
17
- : true,
18
- ctx.schema.maximum !== undefined
19
- ? ctx.value <= ctx.schema.maximum ||
20
- ctx.report({
21
- ...ctx,
22
- expected: `number & Maximum<${ctx.schema.maximum}>`,
23
- })
24
- : true,
25
- ctx.schema.exclusiveMinimum !== undefined
26
- ? ctx.value > ctx.schema.exclusiveMinimum ||
27
- ctx.report({
28
- ...ctx,
29
- expected: `number & ExclusiveMinimum<${ctx.schema.exclusiveMinimum}>`,
30
- })
31
- : true,
32
- ctx.schema.exclusiveMaximum !== undefined
33
- ? ctx.value < ctx.schema.exclusiveMaximum ||
34
- ctx.report({
35
- ...ctx,
36
- expected: `number & ExclusiveMaximum<${ctx.schema.exclusiveMaximum}>`,
37
- })
38
- : true,
39
- ctx.schema.multipleOf !== undefined
40
- ? ctx.value % ctx.schema.multipleOf === 0 ||
41
- ctx.report({
42
- ...ctx,
43
- expected: `number & MultipleOf<${ctx.schema.multipleOf}>`,
44
- })
45
- : true,
46
- ].every((v) => v);
47
- };
48
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
4
+
5
+ export namespace OpenApiNumberValidator {
6
+ export const validate = (
7
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.INumber>,
8
+ ): boolean => {
9
+ if (typeof ctx.value !== "number") return ctx.report(ctx);
10
+ return [
11
+ ctx.schema.minimum !== undefined
12
+ ? ctx.value >= ctx.schema.minimum ||
13
+ ctx.report({
14
+ ...ctx,
15
+ expected: `number & Minimum<${ctx.schema.minimum}>`,
16
+ })
17
+ : true,
18
+ ctx.schema.maximum !== undefined
19
+ ? ctx.value <= ctx.schema.maximum ||
20
+ ctx.report({
21
+ ...ctx,
22
+ expected: `number & Maximum<${ctx.schema.maximum}>`,
23
+ })
24
+ : true,
25
+ ctx.schema.exclusiveMinimum !== undefined
26
+ ? ctx.value > ctx.schema.exclusiveMinimum ||
27
+ ctx.report({
28
+ ...ctx,
29
+ expected: `number & ExclusiveMinimum<${ctx.schema.exclusiveMinimum}>`,
30
+ })
31
+ : true,
32
+ ctx.schema.exclusiveMaximum !== undefined
33
+ ? ctx.value < ctx.schema.exclusiveMaximum ||
34
+ ctx.report({
35
+ ...ctx,
36
+ expected: `number & ExclusiveMaximum<${ctx.schema.exclusiveMaximum}>`,
37
+ })
38
+ : true,
39
+ ctx.schema.multipleOf !== undefined
40
+ ? ctx.value % ctx.schema.multipleOf === 0 ||
41
+ ctx.report({
42
+ ...ctx,
43
+ expected: `number & MultipleOf<${ctx.schema.multipleOf}>`,
44
+ })
45
+ : true,
46
+ ].every((v) => v);
47
+ };
48
+ }
@@ -1,83 +1,83 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { NamingConvention } from "../../utils/NamingConvention";
4
- import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
5
- import { OpenApiStationValidator } from "./OpenApiStationValidator";
6
-
7
- export namespace OpenApiObjectValidator {
8
- export const validate = (
9
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IObject>,
10
- ): boolean => {
11
- if (typeof ctx.value !== "object" || ctx.value === null)
12
- return ctx.report(ctx);
13
- return [
14
- ...Object.entries(ctx.schema.properties ?? {}).map(([key, value]) =>
15
- OpenApiStationValidator.validate({
16
- ...ctx,
17
- schema: value,
18
- value: (ctx.value as Record<string, any>)[key],
19
- path:
20
- ctx.path +
21
- (NamingConvention.variable(key)
22
- ? `.${key}`
23
- : `[${JSON.stringify(key)}]`),
24
- required: ctx.schema.required?.includes(key) ?? false,
25
- }),
26
- ),
27
- ...(typeof ctx.schema.additionalProperties === "object" &&
28
- ctx.schema.additionalProperties !== null
29
- ? Object.entries(ctx.value)
30
- .filter(
31
- ([key]) =>
32
- Object.keys(ctx.schema.properties ?? {}).includes(key) ===
33
- false,
34
- )
35
- .map(([key, value]) =>
36
- OpenApiStationValidator.validate({
37
- ...ctx,
38
- schema: ctx.schema.additionalProperties as OpenApi.IJsonSchema,
39
- value,
40
- path:
41
- ctx.path +
42
- (NamingConvention.variable(key)
43
- ? `.${key}`
44
- : `[${JSON.stringify(key)}]`),
45
- required: true,
46
- }),
47
- )
48
- : []),
49
- ...(ctx.equals === true &&
50
- (ctx.schema.additionalProperties ?? false) === false
51
- ? [validateEquals(ctx)]
52
- : []),
53
- ].every((v) => v);
54
- };
55
-
56
- const validateEquals = (
57
- ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IObject>,
58
- ): boolean => {
59
- const regular: Set<string> = new Set(
60
- Object.keys(ctx.schema.properties ?? {}),
61
- );
62
- return Object.entries(ctx.value as object)
63
- .map(([key, value]) => {
64
- if (regular.has(key) === true) return true;
65
- return ctx.report({
66
- ...ctx,
67
- path:
68
- ctx.path +
69
- (NamingConvention.variable(key)
70
- ? `.${key}`
71
- : `[${JSON.stringify(key)}]`),
72
- value,
73
- expected: "undefined",
74
- description: [
75
- `The property \`${key}\` is not defined in the object type.`,
76
- "",
77
- "Please remove the property next time.",
78
- ].join("\n"),
79
- });
80
- })
81
- .every((v) => v);
82
- };
83
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { NamingConvention } from "../../utils/NamingConvention";
4
+ import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
5
+ import { OpenApiStationValidator } from "./OpenApiStationValidator";
6
+
7
+ export namespace OpenApiObjectValidator {
8
+ export const validate = (
9
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IObject>,
10
+ ): boolean => {
11
+ if (typeof ctx.value !== "object" || ctx.value === null)
12
+ return ctx.report(ctx);
13
+ return [
14
+ ...Object.entries(ctx.schema.properties ?? {}).map(([key, value]) =>
15
+ OpenApiStationValidator.validate({
16
+ ...ctx,
17
+ schema: value,
18
+ value: (ctx.value as Record<string, any>)[key],
19
+ path:
20
+ ctx.path +
21
+ (NamingConvention.variable(key)
22
+ ? `.${key}`
23
+ : `[${JSON.stringify(key)}]`),
24
+ required: ctx.schema.required?.includes(key) ?? false,
25
+ }),
26
+ ),
27
+ ...(typeof ctx.schema.additionalProperties === "object" &&
28
+ ctx.schema.additionalProperties !== null
29
+ ? Object.entries(ctx.value)
30
+ .filter(
31
+ ([key]) =>
32
+ Object.keys(ctx.schema.properties ?? {}).includes(key) ===
33
+ false,
34
+ )
35
+ .map(([key, value]) =>
36
+ OpenApiStationValidator.validate({
37
+ ...ctx,
38
+ schema: ctx.schema.additionalProperties as OpenApi.IJsonSchema,
39
+ value,
40
+ path:
41
+ ctx.path +
42
+ (NamingConvention.variable(key)
43
+ ? `.${key}`
44
+ : `[${JSON.stringify(key)}]`),
45
+ required: true,
46
+ }),
47
+ )
48
+ : []),
49
+ ...(ctx.equals === true &&
50
+ (ctx.schema.additionalProperties ?? false) === false
51
+ ? [validateEquals(ctx)]
52
+ : []),
53
+ ].every((v) => v);
54
+ };
55
+
56
+ const validateEquals = (
57
+ ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IObject>,
58
+ ): boolean => {
59
+ const regular: Set<string> = new Set(
60
+ Object.keys(ctx.schema.properties ?? {}),
61
+ );
62
+ return Object.entries(ctx.value as object)
63
+ .map(([key, value]) => {
64
+ if (regular.has(key) === true) return true;
65
+ return ctx.report({
66
+ ...ctx,
67
+ path:
68
+ ctx.path +
69
+ (NamingConvention.variable(key)
70
+ ? `.${key}`
71
+ : `[${JSON.stringify(key)}]`),
72
+ value,
73
+ expected: "undefined",
74
+ description: [
75
+ `The property \`${key}\` is not defined in the object type.`,
76
+ "",
77
+ "Please remove the property next time.",
78
+ ].join("\n"),
79
+ });
80
+ })
81
+ .every((v) => v);
82
+ };
83
+ }