@kubb/adapter-oas 5.18.1 → 5.18.2
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 +19 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var compatibility = {
|
|
|
36
36
|
"node": ">=22.22"
|
|
37
37
|
};
|
|
38
38
|
// package.json
|
|
39
|
-
var version = "5.18.
|
|
39
|
+
var version = "5.18.2";
|
|
40
40
|
// src/constants.ts
|
|
41
41
|
/**
|
|
42
42
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -2013,6 +2013,7 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
|
|
|
2013
2013
|
required: param.required ?? false,
|
|
2014
2014
|
...pickStyleFields(param),
|
|
2015
2015
|
...contentType !== void 0 ? { contentType } : {},
|
|
2016
|
+
...mediaType?.encoding && { encoding: getEncodingFields({ encoding: mediaType.encoding }).encoding },
|
|
2016
2017
|
...getExamples(mediaType ?? param, refs),
|
|
2017
2018
|
...param.deprecated && { deprecated: true },
|
|
2018
2019
|
...param.allowEmptyValue && { allowEmptyValue: true }
|
|
@@ -2364,10 +2365,13 @@ function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode,
|
|
|
2364
2365
|
if (!variant) return null;
|
|
2365
2366
|
const propertyName = discriminator.propertyName;
|
|
2366
2367
|
const seen = /* @__PURE__ */ new Set([member.$ref]);
|
|
2368
|
+
/** Whether the variant, or a schema it composes, pins the discriminator property to literal values. */
|
|
2367
2369
|
function constrains(v) {
|
|
2368
2370
|
const prop = v.properties?.[propertyName];
|
|
2369
2371
|
const resolved = prop && isReference(prop) ? refs.resolve(prop.$ref, { report: false }) : prop;
|
|
2370
|
-
|
|
2372
|
+
const pins = (candidate) => Array.isArray(candidate.enum) || candidate.const !== void 0;
|
|
2373
|
+
const members = (resolved?.anyOf ?? resolved?.oneOf ?? []).filter((member) => member.type !== "null");
|
|
2374
|
+
if (resolved && (pins(resolved) || members.length > 0 && members.every(pins))) return true;
|
|
2371
2375
|
const composition = v.allOf ?? v.oneOf ?? v.anyOf;
|
|
2372
2376
|
if (!composition) return false;
|
|
2373
2377
|
return composition.some((m) => {
|
|
@@ -2536,13 +2540,13 @@ function convertAnnotatedEnum(context) {
|
|
|
2536
2540
|
function collectSiblingProperties(allOfMembers, refs, outerProperties) {
|
|
2537
2541
|
const properties = { ...outerProperties };
|
|
2538
2542
|
const visited = /* @__PURE__ */ new Set();
|
|
2543
|
+
/** Adds the properties of one member, following its `$ref` and its own `allOf`. */
|
|
2539
2544
|
function collectFrom(item) {
|
|
2540
2545
|
if (!item) return;
|
|
2541
2546
|
if (isReference(item)) {
|
|
2542
2547
|
if (visited.has(item.$ref)) return;
|
|
2543
2548
|
visited.add(item.$ref);
|
|
2544
|
-
|
|
2545
|
-
if (resolved && !isReference(resolved)) collectFrom(resolved);
|
|
2549
|
+
collectFrom(refs.resolve(item.$ref, { report: false }) ?? void 0);
|
|
2546
2550
|
return;
|
|
2547
2551
|
}
|
|
2548
2552
|
if (item.properties) Object.assign(properties, item.properties);
|
|
@@ -2732,7 +2736,12 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
|
|
|
2732
2736
|
if (missingRequired.length) {
|
|
2733
2737
|
const resolvedMembers = schema.allOf.flatMap((item) => {
|
|
2734
2738
|
if (!isReference(item)) return [item];
|
|
2735
|
-
const
|
|
2739
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2740
|
+
let deref = item;
|
|
2741
|
+
while (deref && isReference(deref) && !seen.has(deref.$ref)) {
|
|
2742
|
+
seen.add(deref.$ref);
|
|
2743
|
+
deref = refs.resolve(deref.$ref);
|
|
2744
|
+
}
|
|
2736
2745
|
return deref && !isReference(deref) ? [deref] : [];
|
|
2737
2746
|
});
|
|
2738
2747
|
for (const key of missingRequired) for (const resolved of resolvedMembers) {
|
|
@@ -3427,7 +3436,12 @@ function createSchemaParser(ctx) {
|
|
|
3427
3436
|
...DEFAULT_PARSER_OPTIONS,
|
|
3428
3437
|
...ctx.options
|
|
3429
3438
|
};
|
|
3439
|
+
/** Converts one OpenAPI schema into a `SchemaNode`, through the first matching rule of `schemaRules`. */
|
|
3430
3440
|
function parseSchema({ schema, name }) {
|
|
3441
|
+
if (typeof schema === "boolean") return _kubb_kit.ast.factory.createSchema({
|
|
3442
|
+
type: schema ? options.emptySchemaType : "never",
|
|
3443
|
+
name: name ?? void 0
|
|
3444
|
+
});
|
|
3431
3445
|
const flattenedSchema = flattenSchema(schema);
|
|
3432
3446
|
if (flattenedSchema !== schema) {
|
|
3433
3447
|
const { if: _if, then: _then, else: _else, dependentRequired: _required, dependentSchemas: _schemas, ...shape } = flattenedSchema;
|