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