@skmtc/core 0.32.1 → 0.32.3
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/esm/parse/v3-0/operation/toOperationsV3.js +1 -2
- package/esm/parse/v3-0/server/toServerV3.js +16 -2
- package/esm/parse/v3-0/webhook/toWebhooksV3.js +1 -2
- package/esm/parse/v3-1/_merge-all-of/check-array-item-type-conflicts.d.ts +2 -1
- package/esm/parse/v3-1/_merge-all-of/check-array-item-type-conflicts.js +7 -3
- package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +8 -12
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +5 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +31 -7
- package/esm/parse/v3-1/_merge-all-of/merge.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge.js +28 -23
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +6 -0
- package/esm/parse/v3-1/operation/toOperationsV3.js +1 -2
- package/esm/parse/v3-1/schema/normalize-schema-shape.d.ts +24 -0
- package/esm/parse/v3-1/schema/normalize-schema-shape.js +213 -0
- package/esm/parse/v3-1/schema/toSchemasV3.js +7 -195
- package/esm/parse/v3-1/server/toServerV3.js +16 -2
- package/esm/parse/v3-1/webhook/toWebhooksV3.js +1 -2
- package/esm/parse/v3-2/_merge-all-of/check-array-item-type-conflicts.d.ts +2 -1
- package/esm/parse/v3-2/_merge-all-of/check-array-item-type-conflicts.js +7 -3
- package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +8 -12
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +5 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +31 -7
- package/esm/parse/v3-2/_merge-all-of/merge.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge.js +28 -23
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +6 -0
- package/esm/parse/v3-2/operation/toOperationsV3.js +1 -2
- package/esm/parse/v3-2/schema/normalize-schema-shape.d.ts +24 -0
- package/esm/parse/v3-2/schema/normalize-schema-shape.js +213 -0
- package/esm/parse/v3-2/schema/toSchemasV3.js +7 -195
- package/esm/parse/v3-2/server/toServerV3.js +16 -2
- package/esm/parse/v3-2/webhook/toWebhooksV3.js +1 -2
- package/package.json +1 -1
- package/script/parse/v3-0/operation/toOperationsV3.js +1 -2
- package/script/parse/v3-0/server/toServerV3.js +16 -2
- package/script/parse/v3-0/webhook/toWebhooksV3.js +1 -2
- package/script/parse/v3-1/_merge-all-of/check-array-item-type-conflicts.d.ts +2 -1
- package/script/parse/v3-1/_merge-all-of/check-array-item-type-conflicts.js +7 -3
- package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +8 -12
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +5 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.js +31 -7
- package/script/parse/v3-1/_merge-all-of/merge.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge.js +28 -23
- package/script/parse/v3-1/_merge-all-of/types.d.ts +6 -0
- package/script/parse/v3-1/operation/toOperationsV3.js +1 -2
- package/script/parse/v3-1/schema/normalize-schema-shape.d.ts +24 -0
- package/script/parse/v3-1/schema/normalize-schema-shape.js +219 -0
- package/script/parse/v3-1/schema/toSchemasV3.js +8 -196
- package/script/parse/v3-1/server/toServerV3.js +16 -2
- package/script/parse/v3-1/webhook/toWebhooksV3.js +1 -2
- package/script/parse/v3-2/_merge-all-of/check-array-item-type-conflicts.d.ts +2 -1
- package/script/parse/v3-2/_merge-all-of/check-array-item-type-conflicts.js +7 -3
- package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +8 -12
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +5 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.js +31 -7
- package/script/parse/v3-2/_merge-all-of/merge.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge.js +28 -23
- package/script/parse/v3-2/_merge-all-of/types.d.ts +6 -0
- package/script/parse/v3-2/operation/toOperationsV3.js +1 -2
- package/script/parse/v3-2/schema/normalize-schema-shape.d.ts +24 -0
- package/script/parse/v3-2/schema/normalize-schema-shape.js +219 -0
- package/script/parse/v3-2/schema/toSchemasV3.js +8 -196
- package/script/parse/v3-2/server/toServerV3.js +16 -2
- package/script/parse/v3-2/webhook/toWebhooksV3.js +1 -2
|
@@ -98,8 +98,7 @@ export const toOperationsV3 = ({ paths, stackTrail, context }) => {
|
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
100
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
101
|
-
context.
|
|
102
|
-
key: method,
|
|
101
|
+
context.logIssueNoKey({
|
|
103
102
|
parent: operation,
|
|
104
103
|
level: 'error',
|
|
105
104
|
message: normalized.message,
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { OasServer } from '../../../oas/server/Server.js';
|
|
2
2
|
import { toSpecificationExtensionsV3 } from '../specificationExtensions/toSpecificationExtensionsV3.js';
|
|
3
3
|
import { toOptionalServerVariablesV3 } from '../serverVariable/toServerVariableV3.js';
|
|
4
|
+
import { tryParseAt } from '../../../context/tryParseAt.js';
|
|
4
5
|
export const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
5
|
-
return servers.
|
|
6
|
-
|
|
6
|
+
return servers.flatMap((server, index) => {
|
|
7
|
+
const parsed = tryParseAt({
|
|
8
|
+
stackTrail,
|
|
9
|
+
key: `${index}`,
|
|
10
|
+
context,
|
|
11
|
+
type: 'INVALID_OPERATION',
|
|
12
|
+
parent: servers,
|
|
13
|
+
fn: st => {
|
|
14
|
+
if (typeof server?.url !== 'string') {
|
|
15
|
+
throw new Error(`Expected a Server Object with a string url, got: ${JSON.stringify(server)}`);
|
|
16
|
+
}
|
|
17
|
+
return toServerV3({ server, stackTrail: st, context });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return parsed ? [parsed] : [];
|
|
7
21
|
});
|
|
8
22
|
};
|
|
9
23
|
export const toOptionalServersV3 = ({ servers, stackTrail, context }) => {
|
|
@@ -111,8 +111,7 @@ export const toWebhooksV3 = ({ webhooks, stackTrail, context }) => {
|
|
|
111
111
|
}
|
|
112
112
|
catch (error) {
|
|
113
113
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
114
|
-
context.
|
|
115
|
-
key: method,
|
|
114
|
+
context.logIssueNoKey({
|
|
116
115
|
parent: operation,
|
|
117
116
|
level: 'error',
|
|
118
117
|
message: normalized.message,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
|
|
2
|
+
import type { NormalizeFn } from './types.js';
|
|
3
|
+
export declare const checkArrayItemTypeConflicts: (a: OpenAPIV3.SchemaObject, b: OpenAPIV3.SchemaObject, normalize: NormalizeFn) => void;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { isRef } from '../../../helpers/refFns.js';
|
|
2
|
+
export const checkArrayItemTypeConflicts = (a, b, normalize) => {
|
|
2
3
|
if (a.type === 'array' && b.type === 'array' && 'items' in a && 'items' in b) {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
if (isRef(a.items) || isRef(b.items)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const aItems = normalize(a.items);
|
|
8
|
+
const bItems = normalize(b.items);
|
|
5
9
|
if (aItems.type && bItems.type && aItems.type !== bItems.type) {
|
|
6
10
|
throw new Error(`Cannot merge schemas: array items have conflicting types '${aItems.type}' and '${bItems.type}'`);
|
|
7
11
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SchemaObject, GetRefFn } from './types.js';
|
|
1
|
+
import type { SchemaObject, GetRefFn, NormalizeFn } from './types.js';
|
|
2
2
|
import type * as v from 'valibot';
|
|
3
|
-
export declare const genericMerge: <T>(first: SchemaObject, second: SchemaObject, getRef: GetRefFn, typeCheck?: v.GenericSchema<T>) => SchemaObject;
|
|
3
|
+
export declare const genericMerge: <T>(first: SchemaObject, second: SchemaObject, getRef: GetRefFn, normalize: NormalizeFn, typeCheck?: v.GenericSchema<T>) => SchemaObject;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mergeEnumValues } from './merge-enum-values.js';
|
|
2
2
|
import { mergeProperties } from './merge-properties.js';
|
|
3
3
|
import { mergeRequired } from './merge-required.js';
|
|
4
|
-
export const genericMerge = (first, second, getRef, typeCheck) => {
|
|
4
|
+
export const genericMerge = (first, second, getRef, normalize, typeCheck) => {
|
|
5
5
|
return {
|
|
6
6
|
...first,
|
|
7
7
|
...second,
|
|
8
|
-
...mergeProperties(first, second, getRef),
|
|
8
|
+
...mergeProperties(first, second, getRef, normalize),
|
|
9
9
|
...mergeRequired(first, second),
|
|
10
10
|
...mergeEnumValues(first, second, typeCheck)
|
|
11
11
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ArraySchemaObject, GetRefFn, SchemaObject } from './types.js';
|
|
2
|
-
export declare function mergeArrayConstraints(first: ArraySchemaObject | SchemaObject, second: ArraySchemaObject | SchemaObject, getRef: GetRefFn):
|
|
1
|
+
import type { ArraySchemaObject, GetRefFn, NormalizeFn, SchemaObject } from './types.js';
|
|
2
|
+
export declare function mergeArrayConstraints(first: ArraySchemaObject | SchemaObject, second: ArraySchemaObject | SchemaObject, getRef: GetRefFn, normalize: NormalizeFn): SchemaObject;
|
|
@@ -2,16 +2,12 @@ import { mergeSchemasOrRefs } from './merge.js';
|
|
|
2
2
|
import { genericMerge } from './generic-merge.js';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
5
|
-
export function mergeArrayConstraints(first, second, getRef) {
|
|
5
|
+
export function mergeArrayConstraints(first, second, getRef, normalize) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const result = {
|
|
11
|
-
...genericMerge(first, second, getRef, v.array(v.any())),
|
|
12
|
-
type: 'array',
|
|
13
|
-
items: mergeItems(first, second, getRef)
|
|
14
|
-
};
|
|
7
|
+
const merged = genericMerge(first, second, getRef, normalize, v.array(v.any()));
|
|
8
|
+
const items = mergeItems(first, second, getRef, normalize);
|
|
9
|
+
// With no `items` on either side, `items` stays absent (unknown items).
|
|
10
|
+
const result = items === undefined ? merged : { ...merged, type: 'array', items };
|
|
15
11
|
// Merge minItems
|
|
16
12
|
if (first.minItems !== undefined || second.minItems !== undefined) {
|
|
17
13
|
const minA = first.minItems ?? 0;
|
|
@@ -30,9 +26,9 @@ export function mergeArrayConstraints(first, second, getRef) {
|
|
|
30
26
|
}
|
|
31
27
|
return result;
|
|
32
28
|
}
|
|
33
|
-
const mergeItems = (first, second, getRef) => {
|
|
29
|
+
const mergeItems = (first, second, getRef, normalize) => {
|
|
34
30
|
if ('items' in first && 'items' in second && first.items && second.items) {
|
|
35
|
-
return mergeSchemasOrRefs(first.items, second.items, getRef);
|
|
31
|
+
return mergeSchemasOrRefs(first.items, second.items, getRef, normalize);
|
|
36
32
|
}
|
|
37
33
|
if ('items' in first && first.items) {
|
|
38
34
|
return first.items;
|
|
@@ -40,5 +36,5 @@ const mergeItems = (first, second, getRef) => {
|
|
|
40
36
|
if ('items' in second && second.items) {
|
|
41
37
|
return second.items;
|
|
42
38
|
}
|
|
43
|
-
|
|
39
|
+
return undefined;
|
|
44
40
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type { GetRefFn } from './types.js';
|
|
3
|
-
export declare function mergeBooleanConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn): OpenAPIV3.SchemaObject;
|
|
2
|
+
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
3
|
+
export declare function mergeBooleanConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn, normalize: NormalizeFn): OpenAPIV3.SchemaObject;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { genericMerge } from './generic-merge.js';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
|
-
export function mergeBooleanConstraints(first, second, getRef) {
|
|
4
|
+
export function mergeBooleanConstraints(first, second, getRef, normalize) {
|
|
5
5
|
checkTypeConflicts(first, second);
|
|
6
|
-
return genericMerge(first, second, getRef, v.boolean());
|
|
6
|
+
return genericMerge(first, second, getRef, normalize, v.boolean());
|
|
7
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type { GetRefFn } from './types.js';
|
|
3
|
-
export declare function mergeIntegerConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn): OpenAPIV3.SchemaObject;
|
|
2
|
+
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
3
|
+
export declare function mergeIntegerConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn, normalize: NormalizeFn): OpenAPIV3.SchemaObject;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { genericMerge } from './generic-merge.js';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
|
-
export function mergeIntegerConstraints(first, second, getRef) {
|
|
4
|
+
export function mergeIntegerConstraints(first, second, getRef, normalize) {
|
|
5
5
|
checkTypeConflicts(first, second);
|
|
6
6
|
// First merge enum values if present
|
|
7
|
-
const result = genericMerge(first, second, getRef, v.number());
|
|
7
|
+
const result = genericMerge(first, second, getRef, normalize, v.number());
|
|
8
8
|
// Then merge other constraints
|
|
9
9
|
result.type = 'integer';
|
|
10
10
|
// Merge minimum and exclusiveMinimum
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { GetRefFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
2
2
|
type MergeIntersectionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
|
+
normalize: NormalizeFn;
|
|
5
6
|
throwOnConflict?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const mergeIntersection: ({ schema, getRef }: MergeIntersectionArgs) => SchemaOrReference;
|
|
8
|
+
export declare const mergeIntersection: ({ schema, getRef, normalize }: MergeIntersectionArgs) => SchemaOrReference;
|
|
8
9
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decomposeIntersection } from './decompose-intersection.js';
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
|
-
export const mergeIntersection = ({ schema, getRef }) => {
|
|
3
|
+
export const mergeIntersection = ({ schema, getRef, normalize }) => {
|
|
4
4
|
const decomposed = decomposeIntersection({ schema });
|
|
5
5
|
if (decomposed.length === 1) {
|
|
6
6
|
return decomposed[0];
|
|
@@ -9,7 +9,7 @@ export const mergeIntersection = ({ schema, getRef }) => {
|
|
|
9
9
|
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
10
10
|
});
|
|
11
11
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
12
|
-
const merged = mergeSchemasOrRefs(acc, decomposed, getRef);
|
|
12
|
+
const merged = mergeSchemasOrRefs(acc, decomposed, getRef, normalize);
|
|
13
13
|
return merged;
|
|
14
14
|
}, {});
|
|
15
15
|
return result;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type { GetRefFn } from './types.js';
|
|
3
|
-
export declare function mergeNumberConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn): OpenAPIV3.SchemaObject;
|
|
2
|
+
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
3
|
+
export declare function mergeNumberConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn, normalize: NormalizeFn): OpenAPIV3.SchemaObject;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { genericMerge } from './generic-merge.js';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
|
-
export function mergeNumberConstraints(first, second, getRef) {
|
|
4
|
+
export function mergeNumberConstraints(first, second, getRef, normalize) {
|
|
5
5
|
checkTypeConflicts(first, second);
|
|
6
6
|
// First merge enum values if present
|
|
7
|
-
const result = genericMerge(first, second, getRef, v.number());
|
|
7
|
+
const result = genericMerge(first, second, getRef, normalize, v.number());
|
|
8
8
|
// Then merge other constraints
|
|
9
9
|
result.type = 'number';
|
|
10
10
|
// Merge minimum and exclusiveMinimum
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
2
3
|
type SchemaObject = OpenAPIV3.SchemaObject;
|
|
3
|
-
|
|
4
|
-
export declare const mergeObjectConstraints: (first: SchemaObject, second: SchemaObject, getRef: (ref: ReferenceObject) => SchemaObject) => SchemaObject;
|
|
4
|
+
export declare const mergeObjectConstraints: (first: SchemaObject, second: SchemaObject, getRef: GetRefFn, normalize: NormalizeFn) => SchemaObject;
|
|
5
5
|
export {};
|
|
@@ -2,14 +2,14 @@ import { mergeSchemasOrRefs } from './merge.js';
|
|
|
2
2
|
import { genericMerge } from './generic-merge.js';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
5
|
-
export const mergeObjectConstraints = (first, second, getRef) => {
|
|
5
|
+
export const mergeObjectConstraints = (first, second, getRef, normalize) => {
|
|
6
6
|
// Check for type conflicts
|
|
7
7
|
checkTypeConflicts(first, second);
|
|
8
|
-
const result = genericMerge(first, second, getRef, v.record(v.string(), v.any()));
|
|
8
|
+
const result = genericMerge(first, second, getRef, normalize, v.record(v.string(), v.any()));
|
|
9
9
|
if (typeof second.additionalProperties === 'object' &&
|
|
10
10
|
typeof first.additionalProperties === 'object') {
|
|
11
11
|
// If both have additionalProperties as schemas, merge them
|
|
12
|
-
result.additionalProperties = mergeSchemasOrRefs(first.additionalProperties, second.additionalProperties, getRef);
|
|
12
|
+
result.additionalProperties = mergeSchemasOrRefs(first.additionalProperties, second.additionalProperties, getRef, normalize);
|
|
13
13
|
}
|
|
14
14
|
else if (second.additionalProperties !== undefined) {
|
|
15
15
|
result.additionalProperties = second.additionalProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SchemaObject, GetRefFn } from './types.js';
|
|
2
|
-
export declare const mergeProperties: (first: SchemaObject, second: SchemaObject, getRef: GetRefFn) => SchemaObject | undefined;
|
|
1
|
+
import type { SchemaObject, GetRefFn, NormalizeFn } from './types.js';
|
|
2
|
+
export declare const mergeProperties: (first: SchemaObject, second: SchemaObject, getRef: GetRefFn, normalize: NormalizeFn) => SchemaObject | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
2
|
-
export const mergeProperties = (first, second, getRef) => {
|
|
2
|
+
export const mergeProperties = (first, second, getRef, normalize) => {
|
|
3
3
|
if (containsProperties(first, second)) {
|
|
4
4
|
const properties = { ...first.properties };
|
|
5
5
|
if (!properties) {
|
|
@@ -9,7 +9,7 @@ export const mergeProperties = (first, second, getRef) => {
|
|
|
9
9
|
}
|
|
10
10
|
for (const key in second.properties) {
|
|
11
11
|
if (key in properties) {
|
|
12
|
-
properties[key] = mergeSchemasOrRefs(properties[key], second.properties[key], getRef);
|
|
12
|
+
properties[key] = mergeSchemasOrRefs(properties[key], second.properties[key], getRef, normalize);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
properties[key] = second.properties[key];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type { GetRefFn } from './types.js';
|
|
3
|
-
export declare function mergeStringConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn): OpenAPIV3.SchemaObject;
|
|
2
|
+
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
3
|
+
export declare function mergeStringConstraints(first: OpenAPIV3.SchemaObject, second: OpenAPIV3.SchemaObject, getRef: GetRefFn, normalize: NormalizeFn): OpenAPIV3.SchemaObject;
|
|
@@ -2,13 +2,13 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { checkAtLeastOneTypeMatch } from './check-at-least-one-type-match.js';
|
|
5
|
-
export function mergeStringConstraints(first, second, getRef) {
|
|
5
|
+
export function mergeStringConstraints(first, second, getRef, normalize) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
if (!checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
8
|
-
return genericMerge(first, second, getRef);
|
|
8
|
+
return genericMerge(first, second, getRef, normalize);
|
|
9
9
|
}
|
|
10
10
|
// First merge enum values if present
|
|
11
|
-
const result = genericMerge(first, second, getRef, v.string());
|
|
11
|
+
const result = genericMerge(first, second, getRef, normalize, v.string());
|
|
12
12
|
// Then merge other constraints
|
|
13
13
|
result.type = 'string';
|
|
14
14
|
// Merge minLength
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import type { GetRefFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
2
2
|
type MergeUnionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
|
+
normalize: NormalizeFn;
|
|
5
6
|
groupType: 'oneOf' | 'anyOf';
|
|
6
7
|
};
|
|
7
|
-
export declare const mergeUnion: ({ schema, getRef, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
8
|
+
export declare const mergeUnion: ({ schema, getRef, normalize, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
8
9
|
type MergeCrossProductArgs = {
|
|
9
10
|
first: SchemaObject;
|
|
10
11
|
second: SchemaObject;
|
|
11
12
|
getRef: GetRefFn;
|
|
13
|
+
normalize: NormalizeFn;
|
|
12
14
|
groupType: 'oneOf' | 'anyOf';
|
|
13
15
|
};
|
|
14
|
-
export declare const mergeCrossProduct: ({ first, second, getRef, groupType }: MergeCrossProductArgs) => SchemaObject;
|
|
16
|
+
export declare const mergeCrossProduct: ({ first, second, getRef, normalize, groupType }: MergeCrossProductArgs) => SchemaObject;
|
|
15
17
|
export {};
|
|
@@ -2,7 +2,7 @@ import { decomposeUnion } from './decompose-union.js';
|
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
3
|
import { crossProduct } from './cross-product.js';
|
|
4
4
|
import { isRef } from '../../../helpers/refFns.js';
|
|
5
|
-
export const mergeUnion = ({ schema, getRef, groupType }) => {
|
|
5
|
+
export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
6
6
|
const { beforeExcluded, decomposed, afterExcluded } = decomposeUnion({ schema, groupType });
|
|
7
7
|
// if (decomposed.length === 1) {
|
|
8
8
|
// console.log('DECOMPOSED', JSON.stringify(decomposed[0], null, 2))
|
|
@@ -18,7 +18,13 @@ export const mergeUnion = ({ schema, getRef, groupType }) => {
|
|
|
18
18
|
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
19
19
|
});
|
|
20
20
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
21
|
-
const merged = mergeCrossProduct({
|
|
21
|
+
const merged = mergeCrossProduct({
|
|
22
|
+
first: acc,
|
|
23
|
+
second: decomposed,
|
|
24
|
+
getRef,
|
|
25
|
+
normalize,
|
|
26
|
+
groupType
|
|
27
|
+
});
|
|
22
28
|
return merged;
|
|
23
29
|
}, {});
|
|
24
30
|
const output = {
|
|
@@ -28,13 +34,21 @@ export const mergeUnion = ({ schema, getRef, groupType }) => {
|
|
|
28
34
|
};
|
|
29
35
|
return output;
|
|
30
36
|
};
|
|
31
|
-
export const mergeCrossProduct = ({ first, second, getRef, groupType }) => {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
37
|
+
export const mergeCrossProduct = ({ first, second, getRef, normalize, groupType }) => {
|
|
38
|
+
const firstMembers = Array.isArray(first[groupType]) ? first[groupType] : [first];
|
|
39
|
+
const secondMembers = Array.isArray(second[groupType]) ? second[groupType] : [second];
|
|
40
|
+
// A member that normalizes to exactly `{ nullable: true }` is a null-only
|
|
41
|
+
// member: it makes the union nullable instead of joining the cross product.
|
|
42
|
+
const firstGroup = firstMembers.filter(member => !isNullableOnly(member, normalize));
|
|
43
|
+
const secondGroup = secondMembers.filter(member => !isNullableOnly(member, normalize));
|
|
44
|
+
const nullable = isNullableGroup(first, groupType) ||
|
|
45
|
+
isNullableGroup(second, groupType) ||
|
|
46
|
+
firstGroup.length !== firstMembers.length ||
|
|
47
|
+
secondGroup.length !== secondMembers.length;
|
|
34
48
|
const mergedGroup = crossProduct(firstGroup, secondGroup)
|
|
35
49
|
.map(([firstItem, secondItem]) => {
|
|
36
50
|
try {
|
|
37
|
-
const result = mergeSchemasOrRefs(firstItem, secondItem, getRef);
|
|
51
|
+
const result = mergeSchemasOrRefs(firstItem, secondItem, getRef, normalize);
|
|
38
52
|
return result;
|
|
39
53
|
}
|
|
40
54
|
catch (_error) {
|
|
@@ -48,6 +62,16 @@ export const mergeCrossProduct = ({ first, second, getRef, groupType }) => {
|
|
|
48
62
|
return item[groupType];
|
|
49
63
|
}
|
|
50
64
|
return [item];
|
|
51
|
-
})
|
|
65
|
+
}),
|
|
66
|
+
...(nullable ? { nullable: true } : {})
|
|
52
67
|
};
|
|
53
68
|
};
|
|
69
|
+
const isNullableOnly = (member, normalize) => {
|
|
70
|
+
if (isRef(member)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const normalized = normalize(member);
|
|
74
|
+
return normalized.nullable === true && Object.keys(normalized).length === 1;
|
|
75
|
+
};
|
|
76
|
+
/** Is this a `oneOf`/`anyOf` group wrapper that already carries `nullable`? */
|
|
77
|
+
const isNullableGroup = (schema, groupType) => Array.isArray(schema[groupType]) && schema.nullable === true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SchemaOrReference, GetRefFn } from './types.js';
|
|
2
|
-
export declare const mergeSchemasOrRefs: (
|
|
1
|
+
import type { SchemaOrReference, GetRefFn, NormalizeFn } from './types.js';
|
|
2
|
+
export declare const mergeSchemasOrRefs: (inputFirst: SchemaOrReference, inputSecond: SchemaOrReference, getRef: GetRefFn, normalize: NormalizeFn) => SchemaOrReference;
|
|
@@ -17,9 +17,11 @@ import { mergeIntersection } from './merge-intersection.js';
|
|
|
17
17
|
import { mergeCrossProduct } from './merge-union.js';
|
|
18
18
|
import { isEmpty } from '../../../helpers/isEmpty.js';
|
|
19
19
|
import { isNullOnly, mergeNullOnly } from './nullable-merge.js';
|
|
20
|
-
export const mergeSchemasOrRefs = (
|
|
20
|
+
export const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) => {
|
|
21
|
+
const first = isRef(inputFirst) ? inputFirst : normalize(inputFirst);
|
|
22
|
+
const second = isRef(inputSecond) ? inputSecond : normalize(inputSecond);
|
|
21
23
|
if (containsRef(first, second)) {
|
|
22
|
-
return mergeWithRef(first, second, getRef);
|
|
24
|
+
return mergeWithRef(first, second, getRef, normalize);
|
|
23
25
|
}
|
|
24
26
|
if (isRef(first)) {
|
|
25
27
|
throw new Error('Ref in first');
|
|
@@ -28,17 +30,19 @@ export const mergeSchemasOrRefs = (first, second, getRef) => {
|
|
|
28
30
|
throw new Error('Ref in second');
|
|
29
31
|
}
|
|
30
32
|
if (containsAllOf(first) || containsAllOf(second)) {
|
|
31
|
-
const mergedFirst = containsAllOf(first)
|
|
33
|
+
const mergedFirst = containsAllOf(first)
|
|
34
|
+
? mergeIntersection({ schema: first, getRef, normalize })
|
|
35
|
+
: first;
|
|
32
36
|
const mergedSecond = containsAllOf(second)
|
|
33
|
-
? mergeIntersection({ schema: second, getRef })
|
|
37
|
+
? mergeIntersection({ schema: second, getRef, normalize })
|
|
34
38
|
: second;
|
|
35
|
-
return mergeSchemasOrRefs(mergedFirst, mergedSecond, getRef);
|
|
39
|
+
return mergeSchemasOrRefs(mergedFirst, mergedSecond, getRef, normalize);
|
|
36
40
|
}
|
|
37
41
|
if (containsOneOf(first, second)) {
|
|
38
|
-
return mergeCrossProduct({ first, second, getRef, groupType: 'oneOf' });
|
|
42
|
+
return mergeCrossProduct({ first, second, getRef, normalize, groupType: 'oneOf' });
|
|
39
43
|
}
|
|
40
44
|
if (containsAnyOf(first, second)) {
|
|
41
|
-
return mergeCrossProduct({ first, second, getRef, groupType: 'anyOf' });
|
|
45
|
+
return mergeCrossProduct({ first, second, getRef, normalize, groupType: 'anyOf' });
|
|
42
46
|
}
|
|
43
47
|
if (isNullOnly(first)) {
|
|
44
48
|
return mergeNullOnly(second);
|
|
@@ -46,7 +50,7 @@ export const mergeSchemasOrRefs = (first, second, getRef) => {
|
|
|
46
50
|
if (isNullOnly(second)) {
|
|
47
51
|
return mergeNullOnly(first);
|
|
48
52
|
}
|
|
49
|
-
return mergeSchemas(first, second, getRef);
|
|
53
|
+
return mergeSchemas(first, second, getRef, normalize);
|
|
50
54
|
};
|
|
51
55
|
const containsAllOf = (schema) => {
|
|
52
56
|
if (schema.allOf) {
|
|
@@ -90,7 +94,7 @@ const containsOneOf = (first, second) => {
|
|
|
90
94
|
const containsRef = (first, second) => {
|
|
91
95
|
return isRef(first) || isRef(second);
|
|
92
96
|
};
|
|
93
|
-
const mergeSchemas = (first, second, getRef) => {
|
|
97
|
+
const mergeSchemas = (first, second, getRef, normalize) => {
|
|
94
98
|
try {
|
|
95
99
|
checkTypeConflicts(first, second);
|
|
96
100
|
}
|
|
@@ -101,37 +105,38 @@ const mergeSchemas = (first, second, getRef) => {
|
|
|
101
105
|
checkFormatConflicts(first, second);
|
|
102
106
|
checkEnumConflicts(first, second);
|
|
103
107
|
checkNumberConstraintsConflicts(first, second);
|
|
104
|
-
checkArrayItemTypeConflicts(first, second);
|
|
108
|
+
checkArrayItemTypeConflicts(first, second, normalize);
|
|
105
109
|
if (first.not || second.not) {
|
|
106
110
|
throw new Error('Merging schemas with "not" keyword is not supported');
|
|
107
111
|
}
|
|
108
|
-
return typedMerge(first, second, getRef);
|
|
112
|
+
return typedMerge(first, second, getRef, normalize);
|
|
109
113
|
};
|
|
110
|
-
const typedMerge = (first, second, getRef) => {
|
|
114
|
+
const typedMerge = (first, second, getRef, normalize) => {
|
|
111
115
|
if (!first.type && !second.type) {
|
|
112
|
-
return genericMerge(first, second, getRef);
|
|
116
|
+
return genericMerge(first, second, getRef, normalize);
|
|
113
117
|
}
|
|
114
118
|
if (checkAtLeastOneTypeMatch(first, second, 'object')) {
|
|
115
|
-
return mergeObjectConstraints(first, second, getRef);
|
|
119
|
+
return mergeObjectConstraints(first, second, getRef, normalize);
|
|
116
120
|
}
|
|
117
121
|
if (checkAtLeastOneTypeMatch(first, second, 'array')) {
|
|
118
|
-
return mergeArrayConstraints(first, second, getRef);
|
|
122
|
+
return mergeArrayConstraints(first, second, getRef, normalize);
|
|
119
123
|
}
|
|
120
124
|
if (checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
121
|
-
return mergeStringConstraints(first, second, getRef);
|
|
125
|
+
return mergeStringConstraints(first, second, getRef, normalize);
|
|
122
126
|
}
|
|
123
127
|
if (checkAtLeastOneTypeMatch(first, second, 'number')) {
|
|
124
|
-
return mergeNumberConstraints(first, second, getRef);
|
|
128
|
+
return mergeNumberConstraints(first, second, getRef, normalize);
|
|
125
129
|
}
|
|
126
130
|
if (checkAtLeastOneTypeMatch(first, second, 'integer')) {
|
|
127
|
-
return mergeIntegerConstraints(first, second, getRef);
|
|
131
|
+
return mergeIntegerConstraints(first, second, getRef, normalize);
|
|
128
132
|
}
|
|
129
133
|
if (checkAtLeastOneTypeMatch(first, second, 'boolean')) {
|
|
130
|
-
return mergeBooleanConstraints(first, second, getRef);
|
|
134
|
+
return mergeBooleanConstraints(first, second, getRef, normalize);
|
|
131
135
|
}
|
|
132
136
|
throw new Error(`Cannot merge schemas with type "${first.type}" with type "${second.type}"`);
|
|
133
137
|
};
|
|
134
|
-
const mergeWithRef = (first, second, getRef) => {
|
|
138
|
+
const mergeWithRef = (first, second, getRef, normalize) => {
|
|
139
|
+
const readRef = (ref) => normalize(getRef(ref));
|
|
135
140
|
if (isRef(first) && isRef(second)) {
|
|
136
141
|
if (first.$ref === second.$ref) {
|
|
137
142
|
return {
|
|
@@ -140,15 +145,15 @@ const mergeWithRef = (first, second, getRef) => {
|
|
|
140
145
|
};
|
|
141
146
|
}
|
|
142
147
|
else {
|
|
143
|
-
return mergeSchemas(
|
|
148
|
+
return mergeSchemas(readRef(first), readRef(second), getRef, normalize);
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
if (isRef(first) && !isRef(second)) {
|
|
147
|
-
const merged = isEmpty(second) ? first : mergeSchemas(
|
|
152
|
+
const merged = isEmpty(second) ? first : mergeSchemas(readRef(first), second, getRef, normalize);
|
|
148
153
|
return merged;
|
|
149
154
|
}
|
|
150
155
|
if (!isRef(first) && isRef(second)) {
|
|
151
|
-
const merged = isEmpty(first) ? second : mergeSchemas(first,
|
|
156
|
+
const merged = isEmpty(first) ? second : mergeSchemas(first, readRef(second), getRef, normalize);
|
|
152
157
|
return merged;
|
|
153
158
|
}
|
|
154
159
|
throw new Error('Invalid input');
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
|
|
4
|
+
/**
|
|
5
|
+
* Maps a schema the merge reads (a member, a nested property or item schema,
|
|
6
|
+
* a `$ref` target) onto the shape the merge understands. The caller supplies
|
|
7
|
+
* it, so the merge holds no dialect rules of its own. Must be idempotent.
|
|
8
|
+
*/
|
|
9
|
+
export type NormalizeFn = (schema: OpenAPIV3.SchemaObject) => OpenAPIV3.SchemaObject;
|
|
4
10
|
export type OneOfObject = {
|
|
5
11
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
6
12
|
} & OpenAPIV3.SchemaObject;
|
|
@@ -101,8 +101,7 @@ export const toOperationsV3 = ({ paths, stackTrail, context }) => {
|
|
|
101
101
|
}
|
|
102
102
|
catch (error) {
|
|
103
103
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
104
|
-
context.
|
|
105
|
-
key: method,
|
|
104
|
+
context.logIssueNoKey({
|
|
106
105
|
parent: operation,
|
|
107
106
|
level: 'error',
|
|
108
107
|
message: normalized.message,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
/**
|
|
3
|
+
* Map the 3.1-only schema-shape encodings onto the shared IR shape before
|
|
4
|
+
* dispatching: `unevaluatedProperties`, type arrays, `const`, `examples[]`,
|
|
5
|
+
* numeric exclusive bounds, and binary/base64 content keywords. Each step
|
|
6
|
+
* returns its input unchanged when it does not apply, so the composed result
|
|
7
|
+
* is referentially equal to `schema` when nothing matched — letting the
|
|
8
|
+
* dispatcher re-dispatch only when needed. Idempotent: a normalized schema
|
|
9
|
+
* comes back as the same object.
|
|
10
|
+
*/
|
|
11
|
+
export declare const normalizeSchemaShape: (schema: OpenAPIV3.SchemaObject) => OpenAPIV3.SchemaObject;
|
|
12
|
+
/**
|
|
13
|
+
* Is `type` only `null` (`'null'` or `['null']`)? `'null'` is a 3.1 type the
|
|
14
|
+
* 3.0-typed SchemaObject does not model, so read it loosely.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isNullOnlyType: (type: unknown) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Normalize a schema as it enters the `allOf`/`oneOf`/`anyOf` merge: the
|
|
19
|
+
* {@link normalizeSchemaShape} rules, plus a null-only member (`type: 'null'`
|
|
20
|
+
* or `['null']`) becomes `{ nullable: true }` with no `type`, so it adds
|
|
21
|
+
* nullability instead of conflicting with the other members' types.
|
|
22
|
+
* Idempotent, like `normalizeSchemaShape`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const normalizeMergeMember: (schema: OpenAPIV3.SchemaObject) => OpenAPIV3.SchemaObject;
|