@kubb/adapter-oas 5.9.4 → 5.9.6

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
@@ -11,7 +11,7 @@ var compatibility = {
11
11
  };
12
12
  //#endregion
13
13
  //#region package.json
14
- var version = "5.9.4";
14
+ var version = "5.9.6";
15
15
  //#endregion
16
16
  //#region src/constants.ts
17
17
  /**
@@ -892,6 +892,7 @@ function parseParameter({ param, parentName, options, parseSchema }) {
892
892
  }) : ast.factory.createSchema({ type: options.unknownType });
893
893
  const style = param.style;
894
894
  const explode = param.explode;
895
+ const allowReserved = param.allowReserved;
895
896
  return ast.factory.createParameter({
896
897
  name: param.name,
897
898
  in: param.in,
@@ -901,7 +902,8 @@ function parseParameter({ param, parentName, options, parseSchema }) {
901
902
  },
902
903
  required: param.required ?? false,
903
904
  ...style !== void 0 ? { style } : {},
904
- ...explode !== void 0 ? { explode } : {}
905
+ ...explode !== void 0 ? { explode } : {},
906
+ ...allowReserved !== void 0 ? { allowReserved } : {}
905
907
  });
906
908
  }
907
909
  /**
@@ -1376,6 +1378,27 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
1376
1378
  schema: resolvedSchema
1377
1379
  });
1378
1380
  }
1381
+ /** Converts `{ ...rest, not: X }` into `intersection[rest, not[X]]`; a bare `required` inside `not` borrows the outer `properties`. */
1382
+ function convertNot({ schema, name, nullable, defaultValue, parse }) {
1383
+ const { not, ...rest } = schema;
1384
+ const [subschema] = resolveUnionMembers([not], rest.properties ?? {});
1385
+ const notNode = ast.factory.createSchema({
1386
+ type: "not",
1387
+ members: [parse({ schema: subschema })]
1388
+ });
1389
+ return createNode({
1390
+ schema,
1391
+ name,
1392
+ nullable,
1393
+ defaultValue
1394
+ }, {
1395
+ type: "intersection",
1396
+ members: [parse({
1397
+ schema: rest,
1398
+ name
1399
+ }), notNode]
1400
+ });
1401
+ }
1379
1402
  /**
1380
1403
  * Converts an `allOf` schema into a flattened node or an `IntersectionSchemaNode`.
1381
1404
  */
@@ -1852,7 +1875,7 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
1852
1875
  //#endregion
1853
1876
  //#region src/emit/parseSchema.ts
1854
1877
  /**
1855
- * Ordered schema rule table. Order is significant: composition keywords (`$ref`, `allOf`,
1878
+ * Ordered schema rule table. Order is significant: composition keywords (`not`, `$ref`, `allOf`,
1856
1879
  * `oneOf`/`anyOf`) take precedence over `const`, which takes precedence over a genuine OAS 3.1
1857
1880
  * multi-type array (more than one non-`null` type), which takes precedence over `format`/`type`.
1858
1881
  * A multi-type array must split into its per-type members before `format` runs, otherwise
@@ -1863,6 +1886,10 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
1863
1886
  * match/convert/fall-through contract.
1864
1887
  */
1865
1888
  const schemaRules = [
1889
+ {
1890
+ match: ({ schema }) => typeof schema.not === "object" && schema.not !== null,
1891
+ convert: convertNot
1892
+ },
1866
1893
  {
1867
1894
  match: ({ schema }) => isReference(schema),
1868
1895
  convert: convertRef
@@ -2193,7 +2220,7 @@ function visit(node, pointer) {
2193
2220
  for (const [index, item] of (node.items ?? []).entries()) visit(item, `${pointer}/items/${index}`);
2194
2221
  return;
2195
2222
  }
2196
- if (node.type === "union" || node.type === "intersection") for (const [index, member] of (node.members ?? []).entries()) visit(member, `${pointer}/members/${index}`);
2223
+ if (node.type === "union" || node.type === "intersection" || node.type === "not") for (const [index, member] of (node.members ?? []).entries()) visit(member, `${pointer}/members/${index}`);
2197
2224
  }
2198
2225
  //#endregion
2199
2226
  //#region src/adapter.ts
@@ -2251,6 +2278,9 @@ const adapterOas = defineExtension({
2251
2278
  build({ validate, contentType, server, discriminator, enums, ...parserOptions }) {
2252
2279
  let parsedDocument = null;
2253
2280
  const inputCache = /* @__PURE__ */ new WeakMap();
2281
+ /**
2282
+ * Parses every schema and operation once, resolving ref aliases and discriminator children from that same pass.
2283
+ */
2254
2284
  function parseInput({ document, refs, schemas, parseSchema }) {
2255
2285
  const parsedByName = /* @__PURE__ */ new Map();
2256
2286
  const refAliasMap = /* @__PURE__ */ new Map();
@@ -2306,6 +2336,34 @@ const adapterOas = defineExtension({
2306
2336
  document,
2307
2337
  server
2308
2338
  }),
2339
+ servers: (document.servers ?? []).filter((entry) => entry.url).map(({ url, description, variables }) => {
2340
+ try {
2341
+ return {
2342
+ url: resolveServerUrl({
2343
+ url,
2344
+ variables
2345
+ }),
2346
+ description
2347
+ };
2348
+ } catch {
2349
+ return {
2350
+ url,
2351
+ description
2352
+ };
2353
+ }
2354
+ }),
2355
+ securitySchemes: Object.entries(document.components?.securitySchemes ?? {}).flatMap(([name, value]) => {
2356
+ const scheme = refs.deref(value);
2357
+ return scheme?.type ? [{
2358
+ name,
2359
+ type: scheme.type,
2360
+ description: scheme.description,
2361
+ scheme: scheme.scheme,
2362
+ bearerFormat: scheme.bearerFormat,
2363
+ in: scheme.in,
2364
+ parameterName: scheme.name
2365
+ }] : [];
2366
+ }),
2309
2367
  circularNames,
2310
2368
  enumNames
2311
2369
  }