@kubb/adapter-oas 5.29.5 → 5.30.0
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/dist/index.cjs +43 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -11
- package/dist/index.js.map +1 -1
- package/docs/options.md +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -15,7 +15,7 @@ var compatibility = {
|
|
|
15
15
|
"node": ">=22.22"
|
|
16
16
|
};
|
|
17
17
|
// package.json
|
|
18
|
-
var version = "5.
|
|
18
|
+
var version = "5.30.0";
|
|
19
19
|
// src/constants.ts
|
|
20
20
|
/**
|
|
21
21
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -2474,14 +2474,38 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
|
|
|
2474
2474
|
schema: resolvedSchema
|
|
2475
2475
|
});
|
|
2476
2476
|
}
|
|
2477
|
+
/**
|
|
2478
|
+
* `not`, `contains` and the `if`/`then`/`else` branches check a value and are not its type, so a subschema without a
|
|
2479
|
+
* type accepts every value there. A `void` from `emptySchemaType` or `unknownType` would reject them all, so it becomes
|
|
2480
|
+
* `unknown`, also behind a `$ref`.
|
|
2481
|
+
*/
|
|
2482
|
+
function acceptAnyValue(node) {
|
|
2483
|
+
return _kubb_kit.ast.node.transform(node, { schema: (child) => {
|
|
2484
|
+
if (child.type === _kubb_kit.ast.schema.types.void) return {
|
|
2485
|
+
...child,
|
|
2486
|
+
type: _kubb_kit.ast.schema.types.unknown,
|
|
2487
|
+
primitive: "unknown"
|
|
2488
|
+
};
|
|
2489
|
+
if (_kubb_kit.ast.ref.getSchema(child).type === _kubb_kit.ast.schema.types.void) return _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.schema.types.unknown });
|
|
2490
|
+
} });
|
|
2491
|
+
}
|
|
2477
2492
|
/** Converts `{ ...rest, not: X }` into `intersection[rest, not[X]]`; a bare `required` inside `not` borrows the outer `properties`. */
|
|
2478
2493
|
function convertNot({ schema, name, nullable, defaultValue, parse }) {
|
|
2479
|
-
const { not, ...rest } = schema;
|
|
2494
|
+
const { not, if: _if, then: _then, else: _else, dependentRequired: _required, dependentSchemas: _schemas, ...rest } = schema;
|
|
2480
2495
|
const [subschema] = resolveUnionMembers([not], rest.properties ?? {});
|
|
2481
2496
|
const notNode = _kubb_kit.ast.factory.createSchema({
|
|
2482
2497
|
type: _kubb_kit.ast.schema.types.not,
|
|
2483
|
-
members: [parse({ schema: subschema })]
|
|
2498
|
+
members: [acceptAnyValue(parse({ schema: subschema }))]
|
|
2484
2499
|
});
|
|
2500
|
+
const parsedRest = parse({
|
|
2501
|
+
schema: rest,
|
|
2502
|
+
name
|
|
2503
|
+
});
|
|
2504
|
+
const restNode = parsedRest.type === _kubb_kit.ast.schema.types.void ? {
|
|
2505
|
+
...parsedRest,
|
|
2506
|
+
type: _kubb_kit.ast.schema.types.unknown,
|
|
2507
|
+
primitive: "unknown"
|
|
2508
|
+
} : parsedRest;
|
|
2485
2509
|
return createNode({
|
|
2486
2510
|
schema,
|
|
2487
2511
|
name,
|
|
@@ -2489,10 +2513,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
|
|
|
2489
2513
|
defaultValue
|
|
2490
2514
|
}, {
|
|
2491
2515
|
type: _kubb_kit.ast.schema.types.intersection,
|
|
2492
|
-
members: [
|
|
2493
|
-
schema: rest,
|
|
2494
|
-
name
|
|
2495
|
-
}), notNode]
|
|
2516
|
+
members: [restNode, notNode]
|
|
2496
2517
|
});
|
|
2497
2518
|
}
|
|
2498
2519
|
/**
|
|
@@ -2622,7 +2643,7 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
|
|
|
2622
2643
|
}
|
|
2623
2644
|
}
|
|
2624
2645
|
if (keepsOwnKeywords(schema)) {
|
|
2625
|
-
const { allOf: _allOf, ...schemaWithoutAllOf } = schema;
|
|
2646
|
+
const { allOf: _allOf, if: _if, then: _then, else: _else, dependentRequired: _required, dependentSchemas: _schemas, ...schemaWithoutAllOf } = schema;
|
|
2626
2647
|
allOfMembers.push(parse({ schema: schemaWithoutAllOf }));
|
|
2627
2648
|
}
|
|
2628
2649
|
for (const { propertyName, values } of discriminantValues) allOfMembers.push(createDiscriminantNode({
|
|
@@ -3891,7 +3912,7 @@ function getContains(schema, parse) {
|
|
|
3891
3912
|
const { contains, minContains, maxContains } = schema;
|
|
3892
3913
|
if (!contains || typeof contains !== "object") return {};
|
|
3893
3914
|
return { contains: {
|
|
3894
|
-
schema: parse({ schema: contains }),
|
|
3915
|
+
schema: acceptAnyValue(parse({ schema: contains })),
|
|
3895
3916
|
...typeof minContains === "number" && { min: minContains },
|
|
3896
3917
|
...typeof maxContains === "number" && { max: maxContains }
|
|
3897
3918
|
} };
|
|
@@ -4087,7 +4108,7 @@ function formatPrintsPlainType({ schema, options, type }) {
|
|
|
4087
4108
|
*/
|
|
4088
4109
|
const schemaRules = [
|
|
4089
4110
|
{
|
|
4090
|
-
match: ({ schema }) => typeof schema.not === "object" && schema.not !== null,
|
|
4111
|
+
match: ({ schema }) => schema.not === true || typeof schema.not === "object" && schema.not !== null,
|
|
4091
4112
|
convert: convertNot
|
|
4092
4113
|
},
|
|
4093
4114
|
{
|
|
@@ -4189,6 +4210,12 @@ function hasUnevaluatedSiblings(schema) {
|
|
|
4189
4210
|
schema.$ref
|
|
4190
4211
|
].some((value) => value !== void 0);
|
|
4191
4212
|
}
|
|
4213
|
+
const arrayKeywords = [
|
|
4214
|
+
"minItems",
|
|
4215
|
+
"maxItems",
|
|
4216
|
+
"uniqueItems",
|
|
4217
|
+
"contains"
|
|
4218
|
+
];
|
|
4192
4219
|
function isKeyList(value) {
|
|
4193
4220
|
return Array.isArray(value) && value.length > 0 && value.every((name) => typeof name === "string");
|
|
4194
4221
|
}
|
|
@@ -4297,10 +4324,15 @@ var SchemaParser = class {
|
|
|
4297
4324
|
return keys.includes(void 0) ? void 0 : keys.join("\n");
|
|
4298
4325
|
}
|
|
4299
4326
|
#toBranch(value) {
|
|
4327
|
+
if (typeof value === "boolean") return acceptAnyValue(this.parse({ schema: value }));
|
|
4300
4328
|
if (!value || typeof value !== "object") return void 0;
|
|
4301
4329
|
const { required, type, ...rest } = value;
|
|
4302
4330
|
if (Array.isArray(required) && required.length && (type === void 0 || type === "object") && !Object.keys(rest).length) return this.#requireKeys(required);
|
|
4303
|
-
|
|
4331
|
+
const isArrayCheck = type === void 0 && arrayKeywords.some((key) => rest[key] !== void 0);
|
|
4332
|
+
return acceptAnyValue(this.parse({ schema: isArrayCheck ? {
|
|
4333
|
+
...value,
|
|
4334
|
+
type: "array"
|
|
4335
|
+
} : value }));
|
|
4304
4336
|
}
|
|
4305
4337
|
#toConditionals(schema) {
|
|
4306
4338
|
const entries = (value) => value && typeof value === "object" ? Object.entries(value) : [];
|