@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.js CHANGED
@@ -20,7 +20,7 @@ var compatibility = {
20
20
  "node": ">=22.22"
21
21
  };
22
22
  // package.json
23
- var version = "5.18.1";
23
+ var version = "5.18.2";
24
24
  // src/constants.ts
25
25
  /**
26
26
  * Default parser options applied when no explicit options are provided.
@@ -1997,6 +1997,7 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
1997
1997
  required: param.required ?? false,
1998
1998
  ...pickStyleFields(param),
1999
1999
  ...contentType !== void 0 ? { contentType } : {},
2000
+ ...mediaType?.encoding && { encoding: getEncodingFields({ encoding: mediaType.encoding }).encoding },
2000
2001
  ...getExamples(mediaType ?? param, refs),
2001
2002
  ...param.deprecated && { deprecated: true },
2002
2003
  ...param.allowEmptyValue && { allowEmptyValue: true }
@@ -2348,10 +2349,13 @@ function narrowUnionMembers({ unionMembers, discriminator, sharedPropertiesNode,
2348
2349
  if (!variant) return null;
2349
2350
  const propertyName = discriminator.propertyName;
2350
2351
  const seen = /* @__PURE__ */ new Set([member.$ref]);
2352
+ /** Whether the variant, or a schema it composes, pins the discriminator property to literal values. */
2351
2353
  function constrains(v) {
2352
2354
  const prop = v.properties?.[propertyName];
2353
2355
  const resolved = prop && isReference(prop) ? refs.resolve(prop.$ref, { report: false }) : prop;
2354
- if (resolved && (Array.isArray(resolved.enum) || resolved.const !== void 0)) return true;
2356
+ const pins = (candidate) => Array.isArray(candidate.enum) || candidate.const !== void 0;
2357
+ const members = (resolved?.anyOf ?? resolved?.oneOf ?? []).filter((member) => member.type !== "null");
2358
+ if (resolved && (pins(resolved) || members.length > 0 && members.every(pins))) return true;
2355
2359
  const composition = v.allOf ?? v.oneOf ?? v.anyOf;
2356
2360
  if (!composition) return false;
2357
2361
  return composition.some((m) => {
@@ -2520,13 +2524,13 @@ function convertAnnotatedEnum(context) {
2520
2524
  function collectSiblingProperties(allOfMembers, refs, outerProperties) {
2521
2525
  const properties = { ...outerProperties };
2522
2526
  const visited = /* @__PURE__ */ new Set();
2527
+ /** Adds the properties of one member, following its `$ref` and its own `allOf`. */
2523
2528
  function collectFrom(item) {
2524
2529
  if (!item) return;
2525
2530
  if (isReference(item)) {
2526
2531
  if (visited.has(item.$ref)) return;
2527
2532
  visited.add(item.$ref);
2528
- const resolved = refs.resolve(item.$ref, { report: false });
2529
- if (resolved && !isReference(resolved)) collectFrom(resolved);
2533
+ collectFrom(refs.resolve(item.$ref, { report: false }) ?? void 0);
2530
2534
  return;
2531
2535
  }
2532
2536
  if (item.properties) Object.assign(properties, item.properties);
@@ -2716,7 +2720,12 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
2716
2720
  if (missingRequired.length) {
2717
2721
  const resolvedMembers = schema.allOf.flatMap((item) => {
2718
2722
  if (!isReference(item)) return [item];
2719
- const deref = refs.resolve(item.$ref);
2723
+ const seen = /* @__PURE__ */ new Set();
2724
+ let deref = item;
2725
+ while (deref && isReference(deref) && !seen.has(deref.$ref)) {
2726
+ seen.add(deref.$ref);
2727
+ deref = refs.resolve(deref.$ref);
2728
+ }
2720
2729
  return deref && !isReference(deref) ? [deref] : [];
2721
2730
  });
2722
2731
  for (const key of missingRequired) for (const resolved of resolvedMembers) {
@@ -3411,7 +3420,12 @@ function createSchemaParser(ctx) {
3411
3420
  ...DEFAULT_PARSER_OPTIONS,
3412
3421
  ...ctx.options
3413
3422
  };
3423
+ /** Converts one OpenAPI schema into a `SchemaNode`, through the first matching rule of `schemaRules`. */
3414
3424
  function parseSchema({ schema, name }) {
3425
+ if (typeof schema === "boolean") return ast.factory.createSchema({
3426
+ type: schema ? options.emptySchemaType : "never",
3427
+ name: name ?? void 0
3428
+ });
3415
3429
  const flattenedSchema = flattenSchema(schema);
3416
3430
  if (flattenedSchema !== schema) {
3417
3431
  const { if: _if, then: _then, else: _else, dependentRequired: _required, dependentSchemas: _schemas, ...shape } = flattenedSchema;