@typia/utils 12.0.0-dev.20260307-2 → 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/README.md +2 -2
- package/lib/http/internal/HttpLlmApplicationComposer.js +1 -0
- package/lib/http/internal/HttpLlmApplicationComposer.js.map +1 -1
- package/lib/http/internal/HttpLlmApplicationComposer.mjs +1 -0
- package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -1
- package/lib/utils/LlmJson.d.ts +3 -3
- package/lib/utils/LlmJson.js +2 -2
- package/lib/utils/LlmJson.js.map +1 -1
- package/lib/utils/LlmJson.mjs +2 -2
- package/lib/utils/LlmJson.mjs.map +1 -1
- package/lib/utils/internal/coerceLlmArguments.js +17 -1
- package/lib/utils/internal/coerceLlmArguments.js.map +1 -1
- package/lib/utils/internal/coerceLlmArguments.mjs +17 -1
- package/lib/utils/internal/coerceLlmArguments.mjs.map +1 -1
- package/lib/utils/internal/parseLenientJson.js +236 -96
- package/lib/utils/internal/parseLenientJson.js.map +1 -1
- package/lib/utils/internal/parseLenientJson.mjs +236 -96
- package/lib/utils/internal/parseLenientJson.mjs.map +1 -1
- package/lib/utils/internal/stringifyValidationFailure.js +17 -15
- package/lib/utils/internal/stringifyValidationFailure.js.map +1 -1
- package/lib/utils/internal/stringifyValidationFailure.mjs +17 -15
- package/lib/utils/internal/stringifyValidationFailure.mjs.map +1 -1
- package/package.json +2 -2
- package/src/converters/LlmSchemaConverter.ts +647 -647
- package/src/converters/OpenApiConverter.ts +285 -285
- package/src/converters/index.ts +5 -5
- package/src/converters/internal/LlmDescriptionInverter.ts +178 -178
- package/src/converters/internal/LlmParametersComposer.ts +52 -52
- package/src/converters/internal/OpenApiConstraintShifter.ts +154 -154
- package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -46
- package/src/converters/internal/OpenApiV3Downgrader.ts +355 -355
- package/src/converters/internal/OpenApiV3Upgrader.ts +470 -470
- package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -685
- package/src/converters/internal/SwaggerV2Downgrader.ts +424 -424
- package/src/converters/internal/SwaggerV2Upgrader.ts +523 -523
- package/src/http/HttpError.ts +107 -107
- package/src/http/HttpLlm.ts +167 -167
- package/src/http/HttpMigration.ts +92 -92
- package/src/http/index.ts +3 -3
- package/src/http/internal/HttpLlmApplicationComposer.ts +361 -360
- package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -37
- package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -56
- package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -135
- package/src/http/internal/HttpMigrateRouteComposer.ts +505 -505
- package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -203
- package/src/index.ts +4 -4
- package/src/utils/ArrayUtil.ts +42 -42
- package/src/utils/LlmJson.ts +141 -141
- package/src/utils/MapUtil.ts +15 -15
- package/src/utils/NamingConvention.ts +205 -205
- package/src/utils/Singleton.ts +17 -17
- package/src/utils/StringUtil.ts +14 -14
- package/src/utils/dedent.ts +57 -57
- package/src/utils/index.ts +8 -8
- package/src/utils/internal/EndpointUtil.ts +44 -44
- package/src/utils/internal/JsonDescriptor.ts +70 -70
- package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -822
- package/src/utils/internal/coerceLlmArguments.ts +314 -297
- package/src/utils/internal/parseLenientJson.ts +894 -731
- package/src/utils/internal/stringifyValidationFailure.ts +415 -411
- package/src/validators/LlmTypeChecker.ts +402 -402
- package/src/validators/OpenApiTypeChecker.ts +297 -297
- package/src/validators/OpenApiV3TypeChecker.ts +70 -70
- package/src/validators/OpenApiV3_1TypeChecker.ts +86 -86
- package/src/validators/OpenApiValidator.ts +94 -94
- package/src/validators/SwaggerV2TypeChecker.ts +71 -71
- package/src/validators/functional/_isBigintString.ts +8 -8
- package/src/validators/functional/_isFormatByte.ts +7 -7
- package/src/validators/functional/_isFormatDate.ts +3 -3
- package/src/validators/functional/_isFormatDateTime.ts +4 -4
- package/src/validators/functional/_isFormatDuration.ts +4 -4
- package/src/validators/functional/_isFormatEmail.ts +4 -4
- package/src/validators/functional/_isFormatHostname.ts +4 -4
- package/src/validators/functional/_isFormatIdnEmail.ts +4 -4
- package/src/validators/functional/_isFormatIdnHostname.ts +4 -4
- package/src/validators/functional/_isFormatIpv4.ts +4 -4
- package/src/validators/functional/_isFormatIpv6.ts +4 -4
- package/src/validators/functional/_isFormatIri.ts +3 -3
- package/src/validators/functional/_isFormatIriReference.ts +4 -4
- package/src/validators/functional/_isFormatJsonPointer.ts +3 -3
- package/src/validators/functional/_isFormatPassword.ts +1 -1
- package/src/validators/functional/_isFormatRegex.ts +8 -8
- package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -4
- package/src/validators/functional/_isFormatTime.ts +4 -4
- package/src/validators/functional/_isFormatUri.ts +6 -6
- package/src/validators/functional/_isFormatUriReference.ts +5 -5
- package/src/validators/functional/_isFormatUriTemplate.ts +4 -4
- package/src/validators/functional/_isFormatUrl.ts +4 -4
- package/src/validators/functional/_isFormatUuid.ts +3 -3
- package/src/validators/functional/_isUniqueItems.ts +159 -159
- package/src/validators/index.ts +14 -14
- package/src/validators/internal/IOpenApiValidatorContext.ts +17 -17
- package/src/validators/internal/OpenApiArrayValidator.ts +49 -49
- package/src/validators/internal/OpenApiBooleanValidator.ts +11 -11
- package/src/validators/internal/OpenApiConstantValidator.ts +11 -11
- package/src/validators/internal/OpenApiIntegerValidator.ts +49 -49
- package/src/validators/internal/OpenApiNumberValidator.ts +48 -48
- package/src/validators/internal/OpenApiObjectValidator.ts +83 -83
- package/src/validators/internal/OpenApiOneOfValidator.ts +309 -309
- package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -124
- package/src/validators/internal/OpenApiStationValidator.ts +115 -115
- package/src/validators/internal/OpenApiStringValidator.ts +88 -88
- package/src/validators/internal/OpenApiTupleValidator.ts +55 -55
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import { OpenApi } from "@typia/interface";
|
|
2
|
-
|
|
3
|
-
import { OpenApiExclusiveEmender } from "./OpenApiExclusiveEmender";
|
|
4
|
-
|
|
5
|
-
export namespace OpenApiConstraintShifter {
|
|
6
|
-
export const shiftArray = <
|
|
7
|
-
Schema extends Pick<
|
|
8
|
-
OpenApi.IJsonSchema.IArray,
|
|
9
|
-
"description" | "minItems" | "maxItems" | "uniqueItems"
|
|
10
|
-
>,
|
|
11
|
-
>(
|
|
12
|
-
schema: Schema,
|
|
13
|
-
): Omit<Schema, "minItems" | "maxItems" | "uniqueItems"> => {
|
|
14
|
-
const tags: string[] = [];
|
|
15
|
-
if (schema.minItems !== undefined) {
|
|
16
|
-
tags.push(`@minItems ${schema.minItems}`);
|
|
17
|
-
delete schema.minItems;
|
|
18
|
-
}
|
|
19
|
-
if (schema.maxItems !== undefined) {
|
|
20
|
-
tags.push(`@maxItems ${schema.maxItems}`);
|
|
21
|
-
delete schema.maxItems;
|
|
22
|
-
}
|
|
23
|
-
if (schema.uniqueItems !== undefined) {
|
|
24
|
-
if (schema.uniqueItems === true) tags.push(`@uniqueItems`);
|
|
25
|
-
delete schema.uniqueItems;
|
|
26
|
-
}
|
|
27
|
-
schema.description = writeTagWithDescription({
|
|
28
|
-
description: schema.description,
|
|
29
|
-
tags,
|
|
30
|
-
});
|
|
31
|
-
return schema;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const shiftNumeric = <
|
|
35
|
-
Schema extends Pick<
|
|
36
|
-
OpenApi.IJsonSchema.INumber | OpenApi.IJsonSchema.IInteger,
|
|
37
|
-
| "description"
|
|
38
|
-
| "minimum"
|
|
39
|
-
| "maximum"
|
|
40
|
-
| "exclusiveMinimum"
|
|
41
|
-
| "exclusiveMaximum"
|
|
42
|
-
| "multipleOf"
|
|
43
|
-
| "default"
|
|
44
|
-
>,
|
|
45
|
-
>(
|
|
46
|
-
schema: Schema,
|
|
47
|
-
): Omit<
|
|
48
|
-
Schema,
|
|
49
|
-
| "minimum"
|
|
50
|
-
| "maximum"
|
|
51
|
-
| "exclusiveMinimum"
|
|
52
|
-
| "exclusiveMaximum"
|
|
53
|
-
| "multipleOf"
|
|
54
|
-
| "default"
|
|
55
|
-
> => {
|
|
56
|
-
Object.assign(schema, OpenApiExclusiveEmender.emend(schema));
|
|
57
|
-
|
|
58
|
-
const tags: string[] = [];
|
|
59
|
-
if (schema.minimum !== undefined) {
|
|
60
|
-
tags.push(`@minimum ${schema.minimum}`);
|
|
61
|
-
delete schema.minimum;
|
|
62
|
-
}
|
|
63
|
-
if (schema.maximum !== undefined) {
|
|
64
|
-
tags.push(`@maximum ${schema.maximum}`);
|
|
65
|
-
delete schema.maximum;
|
|
66
|
-
}
|
|
67
|
-
if (schema.exclusiveMinimum !== undefined) {
|
|
68
|
-
tags.push(`@exclusiveMinimum ${schema.exclusiveMinimum}`);
|
|
69
|
-
delete schema.exclusiveMinimum;
|
|
70
|
-
}
|
|
71
|
-
if (schema.exclusiveMaximum !== undefined) {
|
|
72
|
-
tags.push(`@exclusiveMaximum ${schema.exclusiveMaximum}`);
|
|
73
|
-
delete schema.exclusiveMaximum;
|
|
74
|
-
}
|
|
75
|
-
if (schema.multipleOf !== undefined) {
|
|
76
|
-
tags.push(`@multipleOf ${schema.multipleOf}`);
|
|
77
|
-
delete schema.multipleOf;
|
|
78
|
-
}
|
|
79
|
-
schema.description = writeTagWithDescription({
|
|
80
|
-
description: schema.description,
|
|
81
|
-
tags,
|
|
82
|
-
});
|
|
83
|
-
if (schema.default !== undefined) {
|
|
84
|
-
tags.push(`@default ${schema.default}`);
|
|
85
|
-
delete schema.default;
|
|
86
|
-
}
|
|
87
|
-
return schema;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const shiftString = <
|
|
91
|
-
Schema extends Pick<
|
|
92
|
-
OpenApi.IJsonSchema.IString,
|
|
93
|
-
| "description"
|
|
94
|
-
| "minLength"
|
|
95
|
-
| "maxLength"
|
|
96
|
-
| "format"
|
|
97
|
-
| "pattern"
|
|
98
|
-
| "contentMediaType"
|
|
99
|
-
| "default"
|
|
100
|
-
>,
|
|
101
|
-
>(
|
|
102
|
-
schema: Schema,
|
|
103
|
-
): Omit<
|
|
104
|
-
Schema,
|
|
105
|
-
| "minLength"
|
|
106
|
-
| "maxLength"
|
|
107
|
-
| "format"
|
|
108
|
-
| "pattern"
|
|
109
|
-
| "contentMediaType"
|
|
110
|
-
| "default"
|
|
111
|
-
> => {
|
|
112
|
-
const tags: string[] = [];
|
|
113
|
-
if (schema.minLength !== undefined) {
|
|
114
|
-
tags.push(`@minLength ${schema.minLength}`);
|
|
115
|
-
delete schema.minLength;
|
|
116
|
-
}
|
|
117
|
-
if (schema.maxLength !== undefined) {
|
|
118
|
-
tags.push(`@maxLength ${schema.maxLength}`);
|
|
119
|
-
delete schema.maxLength;
|
|
120
|
-
}
|
|
121
|
-
if (schema.format !== undefined) {
|
|
122
|
-
tags.push(`@format ${schema.format}`);
|
|
123
|
-
delete schema.format;
|
|
124
|
-
}
|
|
125
|
-
if (schema.pattern !== undefined) {
|
|
126
|
-
tags.push(`@pattern ${schema.pattern}`);
|
|
127
|
-
delete schema.pattern;
|
|
128
|
-
}
|
|
129
|
-
if (schema.contentMediaType !== undefined) {
|
|
130
|
-
tags.push(`@contentMediaType ${schema.contentMediaType}`);
|
|
131
|
-
delete schema.contentMediaType;
|
|
132
|
-
}
|
|
133
|
-
if (schema.default !== undefined) {
|
|
134
|
-
tags.push(`@default ${schema.default}`);
|
|
135
|
-
delete schema.default;
|
|
136
|
-
}
|
|
137
|
-
schema.description = writeTagWithDescription({
|
|
138
|
-
description: schema.description,
|
|
139
|
-
tags,
|
|
140
|
-
});
|
|
141
|
-
return schema;
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const writeTagWithDescription = (props: {
|
|
146
|
-
description: string | undefined;
|
|
147
|
-
tags: string[];
|
|
148
|
-
}): string | undefined => {
|
|
149
|
-
if (props.tags.length === 0) return props.description;
|
|
150
|
-
return [
|
|
151
|
-
...(props.description?.length ? [props.description, "\n"] : []),
|
|
152
|
-
...props.tags,
|
|
153
|
-
].join("\n");
|
|
154
|
-
};
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiExclusiveEmender } from "./OpenApiExclusiveEmender";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiConstraintShifter {
|
|
6
|
+
export const shiftArray = <
|
|
7
|
+
Schema extends Pick<
|
|
8
|
+
OpenApi.IJsonSchema.IArray,
|
|
9
|
+
"description" | "minItems" | "maxItems" | "uniqueItems"
|
|
10
|
+
>,
|
|
11
|
+
>(
|
|
12
|
+
schema: Schema,
|
|
13
|
+
): Omit<Schema, "minItems" | "maxItems" | "uniqueItems"> => {
|
|
14
|
+
const tags: string[] = [];
|
|
15
|
+
if (schema.minItems !== undefined) {
|
|
16
|
+
tags.push(`@minItems ${schema.minItems}`);
|
|
17
|
+
delete schema.minItems;
|
|
18
|
+
}
|
|
19
|
+
if (schema.maxItems !== undefined) {
|
|
20
|
+
tags.push(`@maxItems ${schema.maxItems}`);
|
|
21
|
+
delete schema.maxItems;
|
|
22
|
+
}
|
|
23
|
+
if (schema.uniqueItems !== undefined) {
|
|
24
|
+
if (schema.uniqueItems === true) tags.push(`@uniqueItems`);
|
|
25
|
+
delete schema.uniqueItems;
|
|
26
|
+
}
|
|
27
|
+
schema.description = writeTagWithDescription({
|
|
28
|
+
description: schema.description,
|
|
29
|
+
tags,
|
|
30
|
+
});
|
|
31
|
+
return schema;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const shiftNumeric = <
|
|
35
|
+
Schema extends Pick<
|
|
36
|
+
OpenApi.IJsonSchema.INumber | OpenApi.IJsonSchema.IInteger,
|
|
37
|
+
| "description"
|
|
38
|
+
| "minimum"
|
|
39
|
+
| "maximum"
|
|
40
|
+
| "exclusiveMinimum"
|
|
41
|
+
| "exclusiveMaximum"
|
|
42
|
+
| "multipleOf"
|
|
43
|
+
| "default"
|
|
44
|
+
>,
|
|
45
|
+
>(
|
|
46
|
+
schema: Schema,
|
|
47
|
+
): Omit<
|
|
48
|
+
Schema,
|
|
49
|
+
| "minimum"
|
|
50
|
+
| "maximum"
|
|
51
|
+
| "exclusiveMinimum"
|
|
52
|
+
| "exclusiveMaximum"
|
|
53
|
+
| "multipleOf"
|
|
54
|
+
| "default"
|
|
55
|
+
> => {
|
|
56
|
+
Object.assign(schema, OpenApiExclusiveEmender.emend(schema));
|
|
57
|
+
|
|
58
|
+
const tags: string[] = [];
|
|
59
|
+
if (schema.minimum !== undefined) {
|
|
60
|
+
tags.push(`@minimum ${schema.minimum}`);
|
|
61
|
+
delete schema.minimum;
|
|
62
|
+
}
|
|
63
|
+
if (schema.maximum !== undefined) {
|
|
64
|
+
tags.push(`@maximum ${schema.maximum}`);
|
|
65
|
+
delete schema.maximum;
|
|
66
|
+
}
|
|
67
|
+
if (schema.exclusiveMinimum !== undefined) {
|
|
68
|
+
tags.push(`@exclusiveMinimum ${schema.exclusiveMinimum}`);
|
|
69
|
+
delete schema.exclusiveMinimum;
|
|
70
|
+
}
|
|
71
|
+
if (schema.exclusiveMaximum !== undefined) {
|
|
72
|
+
tags.push(`@exclusiveMaximum ${schema.exclusiveMaximum}`);
|
|
73
|
+
delete schema.exclusiveMaximum;
|
|
74
|
+
}
|
|
75
|
+
if (schema.multipleOf !== undefined) {
|
|
76
|
+
tags.push(`@multipleOf ${schema.multipleOf}`);
|
|
77
|
+
delete schema.multipleOf;
|
|
78
|
+
}
|
|
79
|
+
schema.description = writeTagWithDescription({
|
|
80
|
+
description: schema.description,
|
|
81
|
+
tags,
|
|
82
|
+
});
|
|
83
|
+
if (schema.default !== undefined) {
|
|
84
|
+
tags.push(`@default ${schema.default}`);
|
|
85
|
+
delete schema.default;
|
|
86
|
+
}
|
|
87
|
+
return schema;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const shiftString = <
|
|
91
|
+
Schema extends Pick<
|
|
92
|
+
OpenApi.IJsonSchema.IString,
|
|
93
|
+
| "description"
|
|
94
|
+
| "minLength"
|
|
95
|
+
| "maxLength"
|
|
96
|
+
| "format"
|
|
97
|
+
| "pattern"
|
|
98
|
+
| "contentMediaType"
|
|
99
|
+
| "default"
|
|
100
|
+
>,
|
|
101
|
+
>(
|
|
102
|
+
schema: Schema,
|
|
103
|
+
): Omit<
|
|
104
|
+
Schema,
|
|
105
|
+
| "minLength"
|
|
106
|
+
| "maxLength"
|
|
107
|
+
| "format"
|
|
108
|
+
| "pattern"
|
|
109
|
+
| "contentMediaType"
|
|
110
|
+
| "default"
|
|
111
|
+
> => {
|
|
112
|
+
const tags: string[] = [];
|
|
113
|
+
if (schema.minLength !== undefined) {
|
|
114
|
+
tags.push(`@minLength ${schema.minLength}`);
|
|
115
|
+
delete schema.minLength;
|
|
116
|
+
}
|
|
117
|
+
if (schema.maxLength !== undefined) {
|
|
118
|
+
tags.push(`@maxLength ${schema.maxLength}`);
|
|
119
|
+
delete schema.maxLength;
|
|
120
|
+
}
|
|
121
|
+
if (schema.format !== undefined) {
|
|
122
|
+
tags.push(`@format ${schema.format}`);
|
|
123
|
+
delete schema.format;
|
|
124
|
+
}
|
|
125
|
+
if (schema.pattern !== undefined) {
|
|
126
|
+
tags.push(`@pattern ${schema.pattern}`);
|
|
127
|
+
delete schema.pattern;
|
|
128
|
+
}
|
|
129
|
+
if (schema.contentMediaType !== undefined) {
|
|
130
|
+
tags.push(`@contentMediaType ${schema.contentMediaType}`);
|
|
131
|
+
delete schema.contentMediaType;
|
|
132
|
+
}
|
|
133
|
+
if (schema.default !== undefined) {
|
|
134
|
+
tags.push(`@default ${schema.default}`);
|
|
135
|
+
delete schema.default;
|
|
136
|
+
}
|
|
137
|
+
schema.description = writeTagWithDescription({
|
|
138
|
+
description: schema.description,
|
|
139
|
+
tags,
|
|
140
|
+
});
|
|
141
|
+
return schema;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const writeTagWithDescription = (props: {
|
|
146
|
+
description: string | undefined;
|
|
147
|
+
tags: string[];
|
|
148
|
+
}): string | undefined => {
|
|
149
|
+
if (props.tags.length === 0) return props.description;
|
|
150
|
+
return [
|
|
151
|
+
...(props.description?.length ? [props.description, "\n"] : []),
|
|
152
|
+
...props.tags,
|
|
153
|
+
].join("\n");
|
|
154
|
+
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { OpenApi } from "@typia/interface";
|
|
2
|
-
|
|
3
|
-
export namespace OpenApiExclusiveEmender {
|
|
4
|
-
export const emend = <
|
|
5
|
-
Schema extends Pick<
|
|
6
|
-
OpenApi.IJsonSchema.INumber,
|
|
7
|
-
"exclusiveMinimum" | "exclusiveMaximum" | "minimum" | "maximum"
|
|
8
|
-
>,
|
|
9
|
-
>(
|
|
10
|
-
schema: Schema,
|
|
11
|
-
): Schema => {
|
|
12
|
-
const minimum =
|
|
13
|
-
typeof schema.minimum === "number" &&
|
|
14
|
-
typeof schema.exclusiveMinimum === "number"
|
|
15
|
-
? {
|
|
16
|
-
minimum:
|
|
17
|
-
schema.minimum > schema.exclusiveMinimum
|
|
18
|
-
? schema.minimum
|
|
19
|
-
: undefined,
|
|
20
|
-
exclusiveMinimum:
|
|
21
|
-
schema.minimum > schema.exclusiveMinimum
|
|
22
|
-
? undefined
|
|
23
|
-
: schema.exclusiveMinimum,
|
|
24
|
-
}
|
|
25
|
-
: {};
|
|
26
|
-
const maximum =
|
|
27
|
-
typeof schema.maximum === "number" &&
|
|
28
|
-
typeof schema.exclusiveMaximum === "number"
|
|
29
|
-
? {
|
|
30
|
-
maximum:
|
|
31
|
-
schema.maximum < schema.exclusiveMaximum
|
|
32
|
-
? schema.maximum
|
|
33
|
-
: undefined,
|
|
34
|
-
exclusiveMaximum:
|
|
35
|
-
schema.maximum < schema.exclusiveMaximum
|
|
36
|
-
? undefined
|
|
37
|
-
: schema.exclusiveMaximum,
|
|
38
|
-
}
|
|
39
|
-
: {};
|
|
40
|
-
return {
|
|
41
|
-
...schema,
|
|
42
|
-
...minimum,
|
|
43
|
-
...maximum,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
export namespace OpenApiExclusiveEmender {
|
|
4
|
+
export const emend = <
|
|
5
|
+
Schema extends Pick<
|
|
6
|
+
OpenApi.IJsonSchema.INumber,
|
|
7
|
+
"exclusiveMinimum" | "exclusiveMaximum" | "minimum" | "maximum"
|
|
8
|
+
>,
|
|
9
|
+
>(
|
|
10
|
+
schema: Schema,
|
|
11
|
+
): Schema => {
|
|
12
|
+
const minimum =
|
|
13
|
+
typeof schema.minimum === "number" &&
|
|
14
|
+
typeof schema.exclusiveMinimum === "number"
|
|
15
|
+
? {
|
|
16
|
+
minimum:
|
|
17
|
+
schema.minimum > schema.exclusiveMinimum
|
|
18
|
+
? schema.minimum
|
|
19
|
+
: undefined,
|
|
20
|
+
exclusiveMinimum:
|
|
21
|
+
schema.minimum > schema.exclusiveMinimum
|
|
22
|
+
? undefined
|
|
23
|
+
: schema.exclusiveMinimum,
|
|
24
|
+
}
|
|
25
|
+
: {};
|
|
26
|
+
const maximum =
|
|
27
|
+
typeof schema.maximum === "number" &&
|
|
28
|
+
typeof schema.exclusiveMaximum === "number"
|
|
29
|
+
? {
|
|
30
|
+
maximum:
|
|
31
|
+
schema.maximum < schema.exclusiveMaximum
|
|
32
|
+
? schema.maximum
|
|
33
|
+
: undefined,
|
|
34
|
+
exclusiveMaximum:
|
|
35
|
+
schema.maximum < schema.exclusiveMaximum
|
|
36
|
+
? undefined
|
|
37
|
+
: schema.exclusiveMaximum,
|
|
38
|
+
}
|
|
39
|
+
: {};
|
|
40
|
+
return {
|
|
41
|
+
...schema,
|
|
42
|
+
...minimum,
|
|
43
|
+
...maximum,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|