@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
|
@@ -15,6 +15,7 @@ const refFns_js_2 = require("../../../helpers/refFns.js");
|
|
|
15
15
|
const merge_intersection_js_1 = require("../_merge-all-of/merge-intersection.js");
|
|
16
16
|
const merge_union_js_1 = require("../_merge-all-of/merge-union.js");
|
|
17
17
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
18
|
+
const normalize_schema_shape_js_1 = require("./normalize-schema-shape.js");
|
|
18
19
|
const toSchemasV3 = ({ schemas, stackTrail, context }) => {
|
|
19
20
|
const output = {};
|
|
20
21
|
const entries = Object.entries(schemas);
|
|
@@ -41,185 +42,6 @@ const toOptionalSchemasV3 = ({ schemas, stackTrail, context }) => {
|
|
|
41
42
|
return (0, exports.toSchemasV3)({ schemas, stackTrail, context });
|
|
42
43
|
};
|
|
43
44
|
exports.toOptionalSchemasV3 = toOptionalSchemasV3;
|
|
44
|
-
/**
|
|
45
|
-
* OpenAPI 3.1 lets a schema's `type` be an ARRAY (e.g. `['string', 'null']`),
|
|
46
|
-
* which the shared IR — modelling a single `type` plus a `nullable` flag —
|
|
47
|
-
* does not. Normalize the array form into shapes the rest of the dispatcher
|
|
48
|
-
* already understands:
|
|
49
|
-
*
|
|
50
|
-
* - `['T', 'null']` (one non-null type) → `{ type: 'T', nullable: true }`
|
|
51
|
-
* - `['T1', 'T2', …]` (several non-null) → a `oneOf` of the bare types,
|
|
52
|
-
* i.e. the 3.1 multi-type union. 3.0 cannot express this — it is the
|
|
53
|
-
* CASE-2 gap where the v3-0 parser degrades to OasUnknown.
|
|
54
|
-
* - `['null']` (only null) → left unchanged → OasUnknown,
|
|
55
|
-
* since there is no first-class OasNull IR node yet (a documented gap).
|
|
56
|
-
*
|
|
57
|
-
* The hoisted `nullable` flag is the IR's representation of nullability; the
|
|
58
|
-
* leaf parsers read it via `parseNullable`. A non-array `type` passes through.
|
|
59
|
-
*/
|
|
60
|
-
const normalizeTypeArray = (schema) => {
|
|
61
|
-
const rawType = schema.type;
|
|
62
|
-
if (!Array.isArray(rawType)) {
|
|
63
|
-
return schema;
|
|
64
|
-
}
|
|
65
|
-
const members = rawType.filter(member => member !== 'null');
|
|
66
|
-
const nullable = rawType.length !== members.length || schema.nullable;
|
|
67
|
-
// Only `null` (`type: ['null']`): no OasNull node yet — fall through.
|
|
68
|
-
if (members.length === 0) {
|
|
69
|
-
return schema;
|
|
70
|
-
}
|
|
71
|
-
// Several non-null types: a 3.1 multi-type union. Model it as a `oneOf`
|
|
72
|
-
// of the bare types and let the oneOf branch build the OasUnion.
|
|
73
|
-
if (members.length > 1) {
|
|
74
|
-
const { type: _type, ...rest } = schema;
|
|
75
|
-
return { ...rest, nullable, oneOf: members.map(member => ({ type: member })) };
|
|
76
|
-
}
|
|
77
|
-
// Exactly one non-null type: dispatch as that type, carrying nullability.
|
|
78
|
-
switch (members[0]) {
|
|
79
|
-
case 'object':
|
|
80
|
-
case 'integer':
|
|
81
|
-
case 'number':
|
|
82
|
-
case 'boolean':
|
|
83
|
-
case 'string':
|
|
84
|
-
return { ...schema, type: members[0], nullable };
|
|
85
|
-
case 'array':
|
|
86
|
-
return 'items' in schema ? { ...schema, type: members[0], nullable } : schema;
|
|
87
|
-
default:
|
|
88
|
-
return schema;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* OpenAPI 3.1 `const: X` is the single-value form of `enum` (3.0 expresses a
|
|
93
|
-
* literal as a one-element `enum`). Rewrite it so the existing enum-aware leaf
|
|
94
|
-
* parsers handle it; matches down-convert's `convertConstToEnum`, so a 3.0
|
|
95
|
-
* `enum:[X]` and a 3.1 `const:X` land on the same IR.
|
|
96
|
-
*/
|
|
97
|
-
const normalizeConst = (schema) => {
|
|
98
|
-
if (!('const' in schema)) {
|
|
99
|
-
return schema;
|
|
100
|
-
}
|
|
101
|
-
// `const` is a 3.1 keyword the 3.0-typed SchemaObject does not model; read
|
|
102
|
-
// it via an annotated destructure rather than a cast.
|
|
103
|
-
const { const: constValue, ...rest } = schema;
|
|
104
|
-
return { ...rest, enum: [constValue] };
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* OpenAPI 3.1 schemas carry `examples` (an array, JSON Schema 2020-12); 3.0
|
|
108
|
-
* and the IR use a single `example`. Adopt the first array element as the IR
|
|
109
|
-
* `example` when no singular `example` is set, and drop the array. Matches
|
|
110
|
-
* down-convert's `convertJsonSchemaExamples`.
|
|
111
|
-
*/
|
|
112
|
-
const normalizeExamples = (schema) => {
|
|
113
|
-
if ('example' in schema || !('examples' in schema)) {
|
|
114
|
-
return schema;
|
|
115
|
-
}
|
|
116
|
-
// `examples` is a 3.1 keyword the 3.0-typed SchemaObject does not model.
|
|
117
|
-
const { examples, ...rest } = schema;
|
|
118
|
-
if (!Array.isArray(examples) || examples.length === 0) {
|
|
119
|
-
return rest;
|
|
120
|
-
}
|
|
121
|
-
return { ...rest, example: examples[0] };
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* OpenAPI 3.1 expresses exclusive bounds as NUMBERS (`exclusiveMinimum: 5`
|
|
125
|
-
* means "> 5"); the shared IR (and 3.0) model them as a boolean flag paired
|
|
126
|
-
* with `minimum`/`maximum`. Convert the numeric form so the number/integer
|
|
127
|
-
* leaves validate. Matches down-convert's `convertExclusiveMinMax`, so a 3.0
|
|
128
|
-
* `{minimum:5, exclusiveMinimum:true}` and a 3.1 `{exclusiveMinimum:5}` land
|
|
129
|
-
* on the same IR.
|
|
130
|
-
*/
|
|
131
|
-
const normalizeExclusiveBounds = (schema) => {
|
|
132
|
-
// `exclusiveMinimum`/`exclusiveMaximum` are 3.0-typed boolean here; in 3.1
|
|
133
|
-
// they arrive as numbers, so read them loosely.
|
|
134
|
-
const exclusiveMinimum = schema.exclusiveMinimum;
|
|
135
|
-
const exclusiveMaximum = schema.exclusiveMaximum;
|
|
136
|
-
if (typeof exclusiveMinimum !== 'number' && typeof exclusiveMaximum !== 'number') {
|
|
137
|
-
return schema;
|
|
138
|
-
}
|
|
139
|
-
const next = { ...schema };
|
|
140
|
-
if (typeof exclusiveMinimum === 'number') {
|
|
141
|
-
next.minimum = exclusiveMinimum;
|
|
142
|
-
next.exclusiveMinimum = true;
|
|
143
|
-
}
|
|
144
|
-
if (typeof exclusiveMaximum === 'number') {
|
|
145
|
-
next.maximum = exclusiveMaximum;
|
|
146
|
-
next.exclusiveMaximum = true;
|
|
147
|
-
}
|
|
148
|
-
return next;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* OpenAPI 3.1 / JSON Schema 2020-12 expresses a binary string payload with
|
|
152
|
-
* `contentMediaType: 'application/octet-stream'` and base64 with
|
|
153
|
-
* `contentEncoding: 'base64'`; the shared IR (and 3.0) carry these as a string
|
|
154
|
-
* `format` (`binary` / `byte`, both in the format allow-list). Map them so the
|
|
155
|
-
* format reaches the IR. Mirrors down-convert's
|
|
156
|
-
* `convertJsonSchemaContentMediaType` / `convertJsonSchemaContentEncoding`:
|
|
157
|
-
* string schemas only, and a pre-existing (conflicting) `format` wins — the
|
|
158
|
-
* content keyword is dropped, not overwritten. Without this, retiring
|
|
159
|
-
* down-convert would silently lose the `format` signal on 3.1 binary uploads.
|
|
160
|
-
*/
|
|
161
|
-
const normalizeContentFormat = (schema) => {
|
|
162
|
-
if (schema.type !== 'string') {
|
|
163
|
-
return schema;
|
|
164
|
-
}
|
|
165
|
-
// `contentMediaType`/`contentEncoding` are 3.1 keywords the 3.0-typed
|
|
166
|
-
// SchemaObject does not model; read them loosely.
|
|
167
|
-
const view = schema;
|
|
168
|
-
const derivedFormat = view.contentMediaType === 'application/octet-stream'
|
|
169
|
-
? 'binary'
|
|
170
|
-
: view.contentEncoding === 'base64'
|
|
171
|
-
? 'byte'
|
|
172
|
-
: undefined;
|
|
173
|
-
if (derivedFormat === undefined) {
|
|
174
|
-
return schema;
|
|
175
|
-
}
|
|
176
|
-
const { contentMediaType: _contentMediaType, contentEncoding: _contentEncoding, ...rest } = view;
|
|
177
|
-
return 'format' in rest ? rest : { ...rest, format: derivedFormat };
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* In-place applicators that evaluate keys `unevaluatedProperties` would
|
|
181
|
-
* otherwise see. `$ref` and `not` never reach `normalizeSchemaShape`.
|
|
182
|
-
*/
|
|
183
|
-
const inPlaceApplicators = [
|
|
184
|
-
'allOf',
|
|
185
|
-
'oneOf',
|
|
186
|
-
'anyOf',
|
|
187
|
-
'if',
|
|
188
|
-
'then',
|
|
189
|
-
'else',
|
|
190
|
-
'dependentSchemas',
|
|
191
|
-
'$dynamicRef'
|
|
192
|
-
];
|
|
193
|
-
/**
|
|
194
|
-
* With no in-place applicator on the same schema, `unevaluatedProperties`
|
|
195
|
-
* means the same as `additionalProperties` (JSON Schema 2020-12 §11.3,
|
|
196
|
-
* §10.3.2.3), so rename it. When `additionalProperties` is also present it
|
|
197
|
-
* evaluates every remaining key, so `unevaluatedProperties` is dropped.
|
|
198
|
-
*/
|
|
199
|
-
const normalizeUnevaluatedProperties = (schema) => {
|
|
200
|
-
if (!('unevaluatedProperties' in schema)) {
|
|
201
|
-
return schema;
|
|
202
|
-
}
|
|
203
|
-
if (inPlaceApplicators.some(keyword => keyword in schema)) {
|
|
204
|
-
return schema;
|
|
205
|
-
}
|
|
206
|
-
// `unevaluatedProperties` is a 3.1 keyword the 3.0-typed SchemaObject does
|
|
207
|
-
// not model; read it via an annotated destructure.
|
|
208
|
-
const { unevaluatedProperties, ...rest } = schema;
|
|
209
|
-
if ('additionalProperties' in rest) {
|
|
210
|
-
return rest;
|
|
211
|
-
}
|
|
212
|
-
if (!isAdditionalPropertiesValue(unevaluatedProperties)) {
|
|
213
|
-
return schema;
|
|
214
|
-
}
|
|
215
|
-
return { ...rest, additionalProperties: unevaluatedProperties };
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Is this a value `additionalProperties` accepts: a boolean, or a schema or
|
|
219
|
-
* `$ref` object?
|
|
220
|
-
*/
|
|
221
|
-
const isAdditionalPropertiesValue = (value) => typeof value === 'boolean' ||
|
|
222
|
-
(typeof value === 'object' && value !== null && !Array.isArray(value));
|
|
223
45
|
/**
|
|
224
46
|
* Remove `unevaluatedProperties` from an `allOf`/`oneOf`/`anyOf` wrapper and
|
|
225
47
|
* log it as skipped. Left in place, it would be renamed to
|
|
@@ -240,26 +62,13 @@ const withoutWrapperUnevaluatedProperties = ({ schema, parentType, stackTrail, c
|
|
|
240
62
|
return rest;
|
|
241
63
|
};
|
|
242
64
|
/**
|
|
243
|
-
*
|
|
244
|
-
* dispatching: `unevaluatedProperties`, type arrays, `const`, `examples[]`,
|
|
245
|
-
* numeric exclusive bounds, and binary/base64 content keywords. Each step
|
|
246
|
-
* returns its input unchanged when it does not apply, so the composed result
|
|
247
|
-
* is referentially equal to `schema` when nothing matched — letting the
|
|
248
|
-
* dispatcher re-dispatch only when needed.
|
|
249
|
-
*/
|
|
250
|
-
const normalizeSchemaShape = (schema) => {
|
|
251
|
-
return normalizeExclusiveBounds(normalizeExamples(normalizeConst(normalizeContentFormat(normalizeTypeArray(normalizeUnevaluatedProperties(schema))))));
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Is this a 3.1 `{ type: 'null' }` schema member? (`'null'` is a 3.1 type
|
|
255
|
-
* literal the 3.0-typed SchemaObject does not model, so read it loosely.)
|
|
65
|
+
* Is this a 3.1 null-only schema member (`type: 'null'` or `['null']`)?
|
|
256
66
|
*/
|
|
257
67
|
const isNullTypeSchema = (member) => {
|
|
258
68
|
if ((0, refFns_js_1.isRef)(member)) {
|
|
259
69
|
return false;
|
|
260
70
|
}
|
|
261
|
-
|
|
262
|
-
return type === 'null';
|
|
71
|
+
return (0, normalize_schema_shape_js_1.isNullOnlyType)(member.type);
|
|
263
72
|
};
|
|
264
73
|
/**
|
|
265
74
|
* Split `oneOf`/`anyOf` members into the non-null members plus whether a
|
|
@@ -315,7 +124,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
315
124
|
if ('not' in schema) {
|
|
316
125
|
throw new Error('Schema uses unsupported "not" keyword');
|
|
317
126
|
}
|
|
318
|
-
const normalized = normalizeSchemaShape(schema);
|
|
127
|
+
const normalized = (0, normalize_schema_shape_js_1.normalizeSchemaShape)(schema);
|
|
319
128
|
if (normalized !== schema) {
|
|
320
129
|
return (0, exports.toSchemaV3)({ schema: normalized, stackTrail, context });
|
|
321
130
|
}
|
|
@@ -356,7 +165,8 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
356
165
|
}
|
|
357
166
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
358
167
|
schema: wrapper,
|
|
359
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject)
|
|
168
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
169
|
+
normalize: normalize_schema_shape_js_1.normalizeMergeMember
|
|
360
170
|
});
|
|
361
171
|
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
362
172
|
});
|
|
@@ -378,6 +188,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
378
188
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
379
189
|
schema: withoutNull,
|
|
380
190
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
191
|
+
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
381
192
|
groupType: 'oneOf'
|
|
382
193
|
});
|
|
383
194
|
if (!('oneOf' in merged) || !Array.isArray(merged.oneOf)) {
|
|
@@ -439,6 +250,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
439
250
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
440
251
|
schema: withoutNull,
|
|
441
252
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
253
|
+
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
442
254
|
groupType: 'anyOf'
|
|
443
255
|
});
|
|
444
256
|
if (!('anyOf' in merged) || !Array.isArray(merged.anyOf)) {
|
|
@@ -4,9 +4,23 @@ exports.toServerV3 = exports.toOptionalServersV3 = exports.toServersV3 = void 0;
|
|
|
4
4
|
const Server_js_1 = require("../../../oas/server/Server.js");
|
|
5
5
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
6
6
|
const toServerVariableV3_js_1 = require("../serverVariable/toServerVariableV3.js");
|
|
7
|
+
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
7
8
|
const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
8
|
-
return servers.
|
|
9
|
-
|
|
9
|
+
return servers.flatMap((server, index) => {
|
|
10
|
+
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
11
|
+
stackTrail,
|
|
12
|
+
key: `${index}`,
|
|
13
|
+
context,
|
|
14
|
+
type: 'INVALID_OPERATION',
|
|
15
|
+
parent: servers,
|
|
16
|
+
fn: st => {
|
|
17
|
+
if (typeof server?.url !== 'string') {
|
|
18
|
+
throw new Error(`Expected a Server Object with a string url, got: ${JSON.stringify(server)}`);
|
|
19
|
+
}
|
|
20
|
+
return (0, exports.toServerV3)({ server, stackTrail: st, context });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return parsed ? [parsed] : [];
|
|
10
24
|
});
|
|
11
25
|
};
|
|
12
26
|
exports.toServersV3 = toServersV3;
|
|
@@ -115,8 +115,7 @@ const toWebhooksV3 = ({ webhooks, stackTrail, context }) => {
|
|
|
115
115
|
}
|
|
116
116
|
catch (error) {
|
|
117
117
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
118
|
-
context.
|
|
119
|
-
key: method,
|
|
118
|
+
context.logIssueNoKey({
|
|
120
119
|
parent: operation,
|
|
121
120
|
level: 'error',
|
|
122
121
|
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,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkArrayItemTypeConflicts = void 0;
|
|
4
|
-
const
|
|
4
|
+
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
5
|
+
const checkArrayItemTypeConflicts = (a, b, normalize) => {
|
|
5
6
|
if (a.type === 'array' && b.type === 'array' && 'items' in a && 'items' in b) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
if ((0, refFns_js_1.isRef)(a.items) || (0, refFns_js_1.isRef)(b.items)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const aItems = normalize(a.items);
|
|
11
|
+
const bItems = normalize(b.items);
|
|
8
12
|
if (aItems.type && bItems.type && aItems.type !== bItems.type) {
|
|
9
13
|
throw new Error(`Cannot merge schemas: array items have conflicting types '${aItems.type}' and '${bItems.type}'`);
|
|
10
14
|
}
|
|
@@ -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;
|
|
@@ -4,11 +4,11 @@ exports.genericMerge = void 0;
|
|
|
4
4
|
const merge_enum_values_js_1 = require("./merge-enum-values.js");
|
|
5
5
|
const merge_properties_js_1 = require("./merge-properties.js");
|
|
6
6
|
const merge_required_js_1 = require("./merge-required.js");
|
|
7
|
-
const genericMerge = (first, second, getRef, typeCheck) => {
|
|
7
|
+
const genericMerge = (first, second, getRef, normalize, typeCheck) => {
|
|
8
8
|
return {
|
|
9
9
|
...first,
|
|
10
10
|
...second,
|
|
11
|
-
...(0, merge_properties_js_1.mergeProperties)(first, second, getRef),
|
|
11
|
+
...(0, merge_properties_js_1.mergeProperties)(first, second, getRef, normalize),
|
|
12
12
|
...(0, merge_required_js_1.mergeRequired)(first, second),
|
|
13
13
|
...(0, merge_enum_values_js_1.mergeEnumValues)(first, second, typeCheck)
|
|
14
14
|
};
|
|
@@ -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;
|
|
@@ -38,16 +38,12 @@ const merge_js_1 = require("./merge.js");
|
|
|
38
38
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
39
39
|
const v = __importStar(require("valibot"));
|
|
40
40
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
41
|
-
function mergeArrayConstraints(first, second, getRef) {
|
|
41
|
+
function mergeArrayConstraints(first, second, getRef, normalize) {
|
|
42
42
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const result = {
|
|
47
|
-
...(0, generic_merge_js_1.genericMerge)(first, second, getRef, v.array(v.any())),
|
|
48
|
-
type: 'array',
|
|
49
|
-
items: mergeItems(first, second, getRef)
|
|
50
|
-
};
|
|
43
|
+
const merged = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.array(v.any()));
|
|
44
|
+
const items = mergeItems(first, second, getRef, normalize);
|
|
45
|
+
// With no `items` on either side, `items` stays absent (unknown items).
|
|
46
|
+
const result = items === undefined ? merged : { ...merged, type: 'array', items };
|
|
51
47
|
// Merge minItems
|
|
52
48
|
if (first.minItems !== undefined || second.minItems !== undefined) {
|
|
53
49
|
const minA = first.minItems ?? 0;
|
|
@@ -66,9 +62,9 @@ function mergeArrayConstraints(first, second, getRef) {
|
|
|
66
62
|
}
|
|
67
63
|
return result;
|
|
68
64
|
}
|
|
69
|
-
const mergeItems = (first, second, getRef) => {
|
|
65
|
+
const mergeItems = (first, second, getRef, normalize) => {
|
|
70
66
|
if ('items' in first && 'items' in second && first.items && second.items) {
|
|
71
|
-
return (0, merge_js_1.mergeSchemasOrRefs)(first.items, second.items, getRef);
|
|
67
|
+
return (0, merge_js_1.mergeSchemasOrRefs)(first.items, second.items, getRef, normalize);
|
|
72
68
|
}
|
|
73
69
|
if ('items' in first && first.items) {
|
|
74
70
|
return first.items;
|
|
@@ -76,5 +72,5 @@ const mergeItems = (first, second, getRef) => {
|
|
|
76
72
|
if ('items' in second && second.items) {
|
|
77
73
|
return second.items;
|
|
78
74
|
}
|
|
79
|
-
|
|
75
|
+
return undefined;
|
|
80
76
|
};
|
|
@@ -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;
|
|
@@ -37,7 +37,7 @@ exports.mergeBooleanConstraints = mergeBooleanConstraints;
|
|
|
37
37
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
38
38
|
const v = __importStar(require("valibot"));
|
|
39
39
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
40
|
-
function mergeBooleanConstraints(first, second, getRef) {
|
|
40
|
+
function mergeBooleanConstraints(first, second, getRef, normalize) {
|
|
41
41
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
42
|
-
return (0, generic_merge_js_1.genericMerge)(first, second, getRef, v.boolean());
|
|
42
|
+
return (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.boolean());
|
|
43
43
|
}
|
|
@@ -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;
|
|
@@ -37,10 +37,10 @@ exports.mergeIntegerConstraints = mergeIntegerConstraints;
|
|
|
37
37
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
38
38
|
const v = __importStar(require("valibot"));
|
|
39
39
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
40
|
-
function mergeIntegerConstraints(first, second, getRef) {
|
|
40
|
+
function mergeIntegerConstraints(first, second, getRef, normalize) {
|
|
41
41
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
42
42
|
// First merge enum values if present
|
|
43
|
-
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, v.number());
|
|
43
|
+
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.number());
|
|
44
44
|
// Then merge other constraints
|
|
45
45
|
result.type = 'integer';
|
|
46
46
|
// 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 {};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mergeIntersection = void 0;
|
|
4
4
|
const decompose_intersection_js_1 = require("./decompose-intersection.js");
|
|
5
5
|
const merge_js_1 = require("./merge.js");
|
|
6
|
-
const mergeIntersection = ({ schema, getRef }) => {
|
|
6
|
+
const mergeIntersection = ({ schema, getRef, normalize }) => {
|
|
7
7
|
const decomposed = (0, decompose_intersection_js_1.decomposeIntersection)({ schema });
|
|
8
8
|
if (decomposed.length === 1) {
|
|
9
9
|
return decomposed[0];
|
|
@@ -12,7 +12,7 @@ const mergeIntersection = ({ schema, getRef }) => {
|
|
|
12
12
|
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
13
13
|
});
|
|
14
14
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
15
|
-
const merged = (0, merge_js_1.mergeSchemasOrRefs)(acc, decomposed, getRef);
|
|
15
|
+
const merged = (0, merge_js_1.mergeSchemasOrRefs)(acc, decomposed, getRef, normalize);
|
|
16
16
|
return merged;
|
|
17
17
|
}, {});
|
|
18
18
|
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;
|
|
@@ -37,10 +37,10 @@ exports.mergeNumberConstraints = mergeNumberConstraints;
|
|
|
37
37
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
38
38
|
const v = __importStar(require("valibot"));
|
|
39
39
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
40
|
-
function mergeNumberConstraints(first, second, getRef) {
|
|
40
|
+
function mergeNumberConstraints(first, second, getRef, normalize) {
|
|
41
41
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
42
42
|
// First merge enum values if present
|
|
43
|
-
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, v.number());
|
|
43
|
+
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.number());
|
|
44
44
|
// Then merge other constraints
|
|
45
45
|
result.type = 'number';
|
|
46
46
|
// 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 {};
|
|
@@ -38,14 +38,14 @@ const merge_js_1 = require("./merge.js");
|
|
|
38
38
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
39
39
|
const v = __importStar(require("valibot"));
|
|
40
40
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
41
|
-
const mergeObjectConstraints = (first, second, getRef) => {
|
|
41
|
+
const mergeObjectConstraints = (first, second, getRef, normalize) => {
|
|
42
42
|
// Check for type conflicts
|
|
43
43
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
44
|
-
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, v.record(v.string(), v.any()));
|
|
44
|
+
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.record(v.string(), v.any()));
|
|
45
45
|
if (typeof second.additionalProperties === 'object' &&
|
|
46
46
|
typeof first.additionalProperties === 'object') {
|
|
47
47
|
// If both have additionalProperties as schemas, merge them
|
|
48
|
-
result.additionalProperties = (0, merge_js_1.mergeSchemasOrRefs)(first.additionalProperties, second.additionalProperties, getRef);
|
|
48
|
+
result.additionalProperties = (0, merge_js_1.mergeSchemasOrRefs)(first.additionalProperties, second.additionalProperties, getRef, normalize);
|
|
49
49
|
}
|
|
50
50
|
else if (second.additionalProperties !== undefined) {
|
|
51
51
|
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;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeProperties = void 0;
|
|
4
4
|
const merge_js_1 = require("./merge.js");
|
|
5
|
-
const mergeProperties = (first, second, getRef) => {
|
|
5
|
+
const mergeProperties = (first, second, getRef, normalize) => {
|
|
6
6
|
if (containsProperties(first, second)) {
|
|
7
7
|
const properties = { ...first.properties };
|
|
8
8
|
if (!properties) {
|
|
@@ -12,7 +12,7 @@ const mergeProperties = (first, second, getRef) => {
|
|
|
12
12
|
}
|
|
13
13
|
for (const key in second.properties) {
|
|
14
14
|
if (key in properties) {
|
|
15
|
-
properties[key] = (0, merge_js_1.mergeSchemasOrRefs)(properties[key], second.properties[key], getRef);
|
|
15
|
+
properties[key] = (0, merge_js_1.mergeSchemasOrRefs)(properties[key], second.properties[key], getRef, normalize);
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
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;
|
|
@@ -38,13 +38,13 @@ const generic_merge_js_1 = require("./generic-merge.js");
|
|
|
38
38
|
const v = __importStar(require("valibot"));
|
|
39
39
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
40
40
|
const check_at_least_one_type_match_js_1 = require("./check-at-least-one-type-match.js");
|
|
41
|
-
function mergeStringConstraints(first, second, getRef) {
|
|
41
|
+
function mergeStringConstraints(first, second, getRef, normalize) {
|
|
42
42
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
43
43
|
if (!(0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'string')) {
|
|
44
|
-
return (0, generic_merge_js_1.genericMerge)(first, second, getRef);
|
|
44
|
+
return (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize);
|
|
45
45
|
}
|
|
46
46
|
// First merge enum values if present
|
|
47
|
-
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, v.string());
|
|
47
|
+
const result = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.string());
|
|
48
48
|
// Then merge other constraints
|
|
49
49
|
result.type = 'string';
|
|
50
50
|
// 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 {};
|