@kubb/adapter-oas 5.17.1 → 5.18.1

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 CHANGED
@@ -23,6 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  let _kubb_core = require("@kubb/core");
24
24
  let _kubb_kit = require("@kubb/kit");
25
25
  let node_path = require("node:path");
26
+ let node_url = require("node:url");
26
27
  let node_fs_promises = require("node:fs/promises");
27
28
  let _scalar_openapi_upgrader = require("@scalar/openapi-upgrader");
28
29
  let api_ref_bundler = require("api-ref-bundler");
@@ -35,7 +36,7 @@ var compatibility = {
35
36
  "node": ">=22.22"
36
37
  };
37
38
  // package.json
38
- var version = "5.17.1";
39
+ var version = "5.18.1";
39
40
  // src/constants.ts
40
41
  /**
41
42
  * Default parser options applied when no explicit options are provided.
@@ -263,7 +264,7 @@ function patchDiscriminatorNode(node, entry) {
263
264
  * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
264
265
  */
265
266
  function convert(text, pascal) {
266
- return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
267
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)(?!xx(?![a-z]))([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
267
268
  if (word.length > 1 && word === word.toUpperCase()) return word;
268
269
  return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
269
270
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
@@ -417,6 +418,21 @@ function isOpenApi32(document) {
417
418
  const [major = 0, minor = 0] = String(document.openapi).split(".").map(Number);
418
419
  return major > 3 || major === 3 && minor >= 2;
419
420
  }
421
+ function pickStrings(source, keys) {
422
+ if (!source || typeof source !== "object") return void 0;
423
+ const entries = keys.flatMap((key) => {
424
+ const value = source[key];
425
+ return typeof value === "string" ? [[key, value]] : [];
426
+ });
427
+ return entries.length ? Object.fromEntries(entries) : void 0;
428
+ }
429
+ function getExternalDocs(source) {
430
+ const docs = pickStrings(source, ["url", "description"]);
431
+ return docs?.url ? {
432
+ url: docs.url,
433
+ ...docs.description !== void 0 && { description: docs.description }
434
+ } : void 0;
435
+ }
420
436
  /**
421
437
  * Returns the `x-*` keys of `source` as-is, or `undefined` when there are none.
422
438
  */
@@ -431,12 +447,12 @@ function isReference(obj) {
431
447
  return !!obj && typeof obj === "object" && "$ref" in obj;
432
448
  }
433
449
  /**
434
- * Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object,
435
- * excluding the Swagger 2 string form.
450
+ * Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object that names a
451
+ * `propertyName`, excluding the Swagger 2 string form and a 3.2 discriminator that only sets `defaultMapping`.
436
452
  */
437
453
  function isDiscriminator(obj) {
438
- const record = obj;
439
- return !!obj && !!record["discriminator"] && typeof record["discriminator"] !== "string";
454
+ const discriminator = obj?.["discriminator"];
455
+ return !!discriminator && typeof discriminator === "object" && typeof discriminator.propertyName === "string";
440
456
  }
441
457
  /**
442
458
  * Returns `true` when a schema is a raw binary payload.
@@ -609,6 +625,65 @@ function createRefs(document) {
609
625
  derefKeepingRef
610
626
  };
611
627
  }
628
+ // src/load/schemaIds.ts
629
+ const DATA_KEYS = /* @__PURE__ */ new Set([
630
+ "example",
631
+ "examples",
632
+ "const",
633
+ "enum",
634
+ "default"
635
+ ]);
636
+ const NAMED_ENTRY_KEYS = /* @__PURE__ */ new Set([
637
+ "properties",
638
+ "patternProperties",
639
+ "$defs",
640
+ "definitions",
641
+ "schemas",
642
+ "dependentSchemas"
643
+ ]);
644
+ function walk(node, pointer, visit, parentKey) {
645
+ if (!node || typeof node !== "object") return;
646
+ if (!Array.isArray(node)) visit(node, pointer);
647
+ const named = parentKey !== void 0 && NAMED_ENTRY_KEYS.has(parentKey);
648
+ for (const [key, value] of Object.entries(node)) {
649
+ if (!named && (DATA_KEYS.has(key) || key.startsWith("x-"))) continue;
650
+ walk(value, `${pointer}/${escapePointerToken(key)}`, visit, Array.isArray(node) ? parentKey : key);
651
+ }
652
+ }
653
+ /**
654
+ * The declaration in the nearest enclosing schema, else the only one, else `undefined`.
655
+ */
656
+ function pick(declarations, pointer) {
657
+ if (!declarations) return void 0;
658
+ const enclosing = declarations.filter((target) => pointer === target || pointer.startsWith(`${target}/`));
659
+ if (enclosing.length) return enclosing.reduce((a, b) => b.length > a.length ? b : a);
660
+ return declarations.length === 1 ? declarations[0] : void 0;
661
+ }
662
+ /**
663
+ * Rewrites, in place, each `$ref` to an `$id`, `$anchor` or `$dynamicAnchor`, and each `$dynamicRef`, into a
664
+ * `#/...` pointer, so it is not fetched. Instance data and `x-` extensions are left as written.
665
+ *
666
+ * shortcut: `$id` matches the `$ref` string exactly and `$dynamicRef` resolves statically to the nearest
667
+ * enclosing anchor, so a relative `$id` base or a recursively extended schema is not followed, upgrade when a spec needs that.
668
+ */
669
+ function resolveSchemaIds(document) {
670
+ const targets = /* @__PURE__ */ new Map();
671
+ const declare = (key, pointer) => targets.set(key, [...targets.get(key) ?? [], pointer]);
672
+ walk(document, "#", (node, pointer) => {
673
+ if (typeof node["$id"] === "string") declare(node["$id"], pointer);
674
+ for (const key of ["$anchor", "$dynamicAnchor"]) if (typeof node[key] === "string") declare(`#${node[key]}`, pointer);
675
+ });
676
+ if (!targets.size) return;
677
+ walk(document, "#", (node, pointer) => {
678
+ const ref = typeof node["$ref"] === "string" ? pick(targets.get(node["$ref"]), pointer) : void 0;
679
+ if (ref) node["$ref"] = ref;
680
+ const dynamicRef = typeof node["$dynamicRef"] === "string" ? pick(targets.get(node["$dynamicRef"]), pointer) : void 0;
681
+ if (dynamicRef && node["$ref"] === void 0) {
682
+ node["$ref"] = dynamicRef;
683
+ delete node["$dynamicRef"];
684
+ }
685
+ });
686
+ }
612
687
  // src/load/source.ts
613
688
  const urlRegExp = /^https?:\/+/i;
614
689
  /**
@@ -778,6 +853,21 @@ function isExtensionPath(path) {
778
853
  return path.some((token, index) => String(token).startsWith("x-") && !namedEntryKeys.has(String(path[index - 1])));
779
854
  }
780
855
  /**
856
+ * Returns the base for relative `$ref`s: the 3.2 `$self` resolved against `pathOrUrl`, else `pathOrUrl`.
857
+ */
858
+ function getBaseUri(pathOrUrl, root) {
859
+ const self = root && typeof root === "object" ? root.$self : void 0;
860
+ if (typeof self !== "string" || !self) return pathOrUrl;
861
+ try {
862
+ if (urlRegExp.test(self)) return new URL(self).href;
863
+ if (/^file:/i.test(self)) return (0, node_url.fileURLToPath)(self);
864
+ if (/^[a-z][a-z\d+.-]*:/i.test(self)) return pathOrUrl;
865
+ return urlRegExp.test(pathOrUrl) ? new URL(self, pathOrUrl).href : (0, node_path.resolve)((0, node_path.dirname)(pathOrUrl), self);
866
+ } catch {
867
+ return pathOrUrl;
868
+ }
869
+ }
870
+ /**
781
871
  * Bundles a multi-file OpenAPI document into a single document via `api-ref-bundler`.
782
872
  *
783
873
  * External file schemas are hoisted into named `components.schemas` entries, so a property
@@ -790,8 +880,9 @@ function isExtensionPath(path) {
790
880
  * all-internal document it is a no-op that still walks the whole tree to confirm that, which
791
881
  * costs real time on a large spec.
792
882
  *
793
- * `document` stands in for the file at `pathOrUrl`, such as inline input. Every other file or URL
794
- * read, including one that fails, lands in `sources`. A `$ref` that cannot be read reports
883
+ * `document` stands in for the file at `pathOrUrl`, such as inline input. Relative `$ref`s resolve
884
+ * against the OpenAPI 3.2 `$self` when the document sets one. Every other file or URL read,
885
+ * including one that fails, lands in `sources`. A `$ref` that cannot be read reports
795
886
  * `KUBB_REF_NOT_FOUND` at the key that holds it, as a warning when it sits inside an `x-` extension.
796
887
  *
797
888
  * @example Local file
@@ -803,8 +894,10 @@ function isExtensionPath(path) {
803
894
  async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
804
895
  const cache = /* @__PURE__ */ new Map();
805
896
  const toKey = (sourcePath) => urlRegExp.test(sourcePath) ? new URL(sourcePath).href : sourcePath;
897
+ let entry = pathOrUrl;
898
+ let entryDocument = document;
806
899
  const resolver = (sourcePath) => {
807
- if (document && sourcePath === pathOrUrl) return Promise.resolve(document);
900
+ if (entryDocument !== void 0 && toKey(sourcePath) === toKey(entry)) return Promise.resolve(entryDocument);
808
901
  const key = toKey(sourcePath);
809
902
  const cached = cache.get(key);
810
903
  if (cached) return cached;
@@ -814,9 +907,12 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
814
907
  return result;
815
908
  };
816
909
  const root = await resolver(pathOrUrl);
910
+ resolveSchemaIds(root);
817
911
  if (typeof root === "object" && root !== null && !hasExternalRef(root)) return root;
818
- return await (0, api_ref_bundler.bundle)(pathOrUrl, resolver, { hooks: { onError: (message, { path, state }) => {
819
- const pointer = toKey(state.baseFile) === toKey(pathOrUrl) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
912
+ entry = getBaseUri(pathOrUrl, root);
913
+ entryDocument = root;
914
+ return await (0, api_ref_bundler.bundle)(entry, resolver, { hooks: { onError: (message, { path, state }) => {
915
+ const pointer = toKey(state.baseFile) === toKey(entry) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
820
916
  const diagnostic = {
821
917
  code: _kubb_kit.Diagnostics.code.refNotFound,
822
918
  severity: isExtensionPath(path) ? "warning" : "error",
@@ -855,10 +951,12 @@ async function parseFromConfig(source, sources = []) {
855
951
  origin: "the inline `input` string",
856
952
  help: "Fix the syntax at the reported line. Kubb reads `input` as an inline spec, not a file path, because it starts with `{`, `[`, `openapi:`, or `swagger:`, or spans several lines."
857
953
  }) : structuredClone(source.data);
858
- return source.root && hasExternalRef(data) ? bundleDocument((0, node_path.join)(source.root, inlineInputName), {
954
+ if (source.root && hasExternalRef(data)) return bundleDocument((0, node_path.join)(source.root, inlineInputName), {
859
955
  document: data,
860
956
  sources
861
- }) : data;
957
+ });
958
+ resolveSchemaIds(data);
959
+ return data;
862
960
  }
863
961
  await assertInputExists(source.path);
864
962
  return bundleDocument(source.path, { sources });
@@ -1127,8 +1225,29 @@ const semanticSuffixes = {
1127
1225
  */
1128
1226
  function getSchemas(document, { contentType }, refs) {
1129
1227
  const components = document.components;
1228
+ /**
1229
+ * Follows a `$ref` to the schema it ends at. Keywords next to a `$ref` apply together with its target,
1230
+ * so they stay on a one-member `allOf` around it.
1231
+ */
1232
+ function inlineRef(schema, seen = /* @__PURE__ */ new Set()) {
1233
+ if (!isReference(schema) || seen.has(schema.$ref)) return schema;
1234
+ const { $ref, ...siblings } = schema;
1235
+ const resolved = refs.resolve($ref);
1236
+ if (!resolved) return schema;
1237
+ const target = inlineRef(resolved, seen.add($ref));
1238
+ if (!Object.keys(siblings).length) return target;
1239
+ const own = "allOf" in siblings && Array.isArray(siblings.allOf) ? siblings.allOf : [];
1240
+ return {
1241
+ ...siblings,
1242
+ allOf: [...own, target]
1243
+ };
1244
+ }
1245
+ /**
1246
+ * Replaces a `$ref` schema with its target. A plain `$ref` to another `$ref` stays as it is, so the parser reads it as an alias.
1247
+ */
1130
1248
  function resolveSchemaRef(schema) {
1131
1249
  if (!isReference(schema)) return schema;
1250
+ if (Object.keys(schema).length > 1) return inlineRef(schema);
1132
1251
  const resolved = refs.resolve(schema.$ref);
1133
1252
  return resolved && !isReference(resolved) ? resolved : schema;
1134
1253
  }
@@ -1183,6 +1302,80 @@ function getSchemas(document, { contentType }, refs) {
1183
1302
  pointers
1184
1303
  };
1185
1304
  }
1305
+ // src/model/security.ts
1306
+ const SCHEME_POINTER = "#/components/securitySchemes/";
1307
+ const API_KEY_LOCATIONS = /* @__PURE__ */ new Set([
1308
+ "header",
1309
+ "query",
1310
+ "cookie"
1311
+ ]);
1312
+ function getCredential(scheme) {
1313
+ if (scheme.type === "apiKey") return scheme.name && scheme.in && API_KEY_LOCATIONS.has(scheme.in) ? {
1314
+ type: "apiKey",
1315
+ in: scheme.in,
1316
+ name: scheme.name
1317
+ } : void 0;
1318
+ if (scheme.type === "http") return scheme.scheme ? {
1319
+ type: "http",
1320
+ scheme: scheme.scheme.toLowerCase(),
1321
+ ...scheme.bearerFormat && { bearerFormat: scheme.bearerFormat }
1322
+ } : void 0;
1323
+ if (scheme.type === "openIdConnect") return {
1324
+ type: "openIdConnect",
1325
+ ...scheme.openIdConnectUrl && { url: scheme.openIdConnectUrl }
1326
+ };
1327
+ if (scheme.type === "oauth2") {
1328
+ const flows = Object.entries(scheme.flows ?? {}).map(([name, flow]) => {
1329
+ const scopes = flow && typeof flow === "object" && flow.scopes && typeof flow.scopes === "object" ? { scopes: flow.scopes } : {};
1330
+ return [name, {
1331
+ ...pickStrings(flow, [
1332
+ "authorizationUrl",
1333
+ "deviceAuthorizationUrl",
1334
+ "tokenUrl",
1335
+ "refreshUrl"
1336
+ ]),
1337
+ ...scopes
1338
+ }];
1339
+ });
1340
+ return {
1341
+ type: "oauth2",
1342
+ flows: Object.fromEntries(flows),
1343
+ ...scheme.oauth2MetadataUrl && { metadataUrl: scheme.oauth2MetadataUrl }
1344
+ };
1345
+ }
1346
+ return scheme.type === "mutualTLS" ? { type: "mutualTLS" } : void 0;
1347
+ }
1348
+ /**
1349
+ * Maps `components.securitySchemes` to `AuthScheme` entries, leaving out a scheme a client cannot place.
1350
+ */
1351
+ function toAuthSchemes(schemes, refs) {
1352
+ return Object.entries(schemes ?? {}).flatMap(([name, value]) => {
1353
+ const scheme = refs.deref(value);
1354
+ const credential = scheme && getCredential(scheme);
1355
+ if (!scheme || !credential) return [];
1356
+ return [{
1357
+ name,
1358
+ ...scheme.description && { description: scheme.description },
1359
+ ...scheme.deprecated && { deprecated: true },
1360
+ credential
1361
+ }];
1362
+ });
1363
+ }
1364
+ /**
1365
+ * Maps security requirements to `AuthRequirement` entries. A 3.2 URI key becomes the scheme name.
1366
+ */
1367
+ function toAuthRequirements(requirements, document) {
1368
+ if (!Array.isArray(requirements)) return void 0;
1369
+ const schemes = document.components?.securitySchemes ?? {};
1370
+ const toName = (key) => {
1371
+ const index = key.indexOf(SCHEME_POINTER);
1372
+ return Object.hasOwn(schemes, key) || index === -1 ? key : unescapePointerToken(key.slice(index + 29));
1373
+ };
1374
+ return requirements.filter((requirement) => !!requirement && typeof requirement === "object").map((requirement) => Object.entries(requirement).map(([key, scopes]) => ({
1375
+ scheme: toName(key),
1376
+ ...Array.isArray(scopes) && scopes.length && { scopes: scopes.map(String) }
1377
+ })));
1378
+ }
1186
1379
  // src/model/server.ts
1187
1380
  /**
1188
1381
  * Reads the server URL from the document's `servers` array at `server.index`,
@@ -1239,8 +1432,11 @@ function resolveServerUrl(server, overrides) {
1239
1432
  * Maps OpenAPI servers to `InputServer` entries: drops entries without a `url` and fills `{variable}` defaults.
1240
1433
  */
1241
1434
  function toInputServers(servers) {
1242
- return servers.filter((entry) => entry.url).map(({ url, description, variables }) => {
1243
- const declared = variables && Object.keys(variables).length > 0 ? { variables } : {};
1435
+ return servers.filter((entry) => entry.url).map(({ url, name, description, variables }) => {
1436
+ const declared = {
1437
+ ...name !== void 0 && { name },
1438
+ ...variables && Object.keys(variables).length > 0 && { variables }
1439
+ };
1244
1440
  try {
1245
1441
  return {
1246
1442
  url: resolveServerUrl({
@@ -1259,6 +1455,20 @@ function toInputServers(servers) {
1259
1455
  }
1260
1456
  });
1261
1457
  }
1458
+ // src/model/tag.ts
1459
+ function toInputTags(tags) {
1460
+ return tags.filter((tag) => typeof tag.name === "string").map(({ name, summary, description, parent, kind, externalDocs }) => {
1461
+ const docs = getExternalDocs(externalDocs);
1462
+ return {
1463
+ name,
1464
+ ...typeof summary === "string" && { summary },
1465
+ ...typeof description === "string" && { description },
1466
+ ...typeof parent === "string" && { parent },
1467
+ ...typeof kind === "string" && { kind },
1468
+ ...docs && { externalDocs: docs }
1469
+ };
1470
+ });
1471
+ }
1262
1472
  // src/model/mediaType.ts
1263
1473
  /**
1264
1474
  * The media type without its parameters, so `text/event-stream; charset=utf-8` matches the bare name.
@@ -1616,7 +1826,8 @@ const PARAMETER_STYLES = /* @__PURE__ */ new Set([
1616
1826
  "simple",
1617
1827
  "spaceDelimited",
1618
1828
  "pipeDelimited",
1619
- "deepObject"
1829
+ "deepObject",
1830
+ "cookie"
1620
1831
  ]);
1621
1832
  function pickStyleFields({ style, explode, allowReserved }) {
1622
1833
  return {
@@ -1625,16 +1836,45 @@ function pickStyleFields({ style, explode, allowReserved }) {
1625
1836
  ...allowReserved !== void 0 ? { allowReserved } : {}
1626
1837
  };
1627
1838
  }
1628
- /** The `encoding` of a media type, reduced to the entries that set a field Kubb carries. A `style` outside the OpenAPI set is dropped. */
1629
- function getEncoding(encoding) {
1630
- const entries = Object.entries(encoding ?? {}).flatMap(([property, { contentType, ...rest }]) => {
1631
- const node = {
1632
- ...contentType !== void 0 ? { contentType } : {},
1633
- ...pickStyleFields(rest)
1634
- };
1839
+ function getEncodingFields({ encoding, prefixEncoding, itemEncoding }) {
1840
+ const entries = Object.entries(encoding ?? {}).flatMap(([property, entry]) => {
1841
+ const node = toEncodingNode(entry);
1635
1842
  return Object.keys(node).length ? [[property, node]] : [];
1636
1843
  });
1637
- return entries.length ? Object.fromEntries(entries) : void 0;
1844
+ const item = itemEncoding && toEncodingNode(itemEncoding);
1845
+ return {
1846
+ ...entries.length && { encoding: Object.fromEntries(entries) },
1847
+ ...prefixEncoding?.length && { prefixEncoding: prefixEncoding.map(toEncodingNode) },
1848
+ ...item && Object.keys(item).length && { itemEncoding: item }
1849
+ };
1850
+ }
1851
+ function toEncodingNode({ contentType, encoding, prefixEncoding, itemEncoding, ...rest }) {
1852
+ return {
1853
+ ...contentType !== void 0 && { contentType },
1854
+ ...pickStyleFields(rest),
1855
+ ...getEncodingFields({
1856
+ encoding,
1857
+ prefixEncoding,
1858
+ itemEncoding
1859
+ })
1860
+ };
1861
+ }
1862
+ function getExamples({ example, examples }, refs) {
1863
+ const named = Object.entries(examples ?? {}).flatMap(([name, entry]) => {
1864
+ const resolved = refs.deref(entry);
1865
+ if (!resolved) return [];
1866
+ const { summary, description, dataValue, value, serializedValue } = resolved;
1867
+ const data = dataValue !== void 0 ? dataValue : value;
1868
+ return [{
1869
+ name,
1870
+ ...typeof summary === "string" && { summary },
1871
+ ...typeof description === "string" && { description },
1872
+ ...data !== void 0 && { value: data },
1873
+ ...typeof serializedValue === "string" && { serializedValue }
1874
+ }];
1875
+ });
1876
+ if (named.length) return { examples: named };
1877
+ return example !== void 0 ? { examples: [{ value: example }] } : {};
1638
1878
  }
1639
1879
  /**
1640
1880
  * Returns the media type entry for `contentType`, resolving a `$ref` into `components.mediaTypes`. `null` when absent.
@@ -1663,6 +1903,24 @@ function getBodySchema({ content, contentType, refs, document }) {
1663
1903
  if (binary) return binary;
1664
1904
  return schema ? refs.derefKeepingRef(schema) : null;
1665
1905
  }
1906
+ function getLinks(links, refs) {
1907
+ const entries = Object.entries(links ?? {}).flatMap(([name, value]) => {
1908
+ const link = refs.deref(value);
1909
+ if (!link) return [];
1910
+ const server = link.server ? toInputServers([link.server])[0] : void 0;
1911
+ return [[name, {
1912
+ ...pickStrings(link, [
1913
+ "operationId",
1914
+ "operationRef",
1915
+ "description"
1916
+ ]),
1917
+ ...link.parameters && { parameters: link.parameters },
1918
+ ..."requestBody" in link && { requestBody: link.requestBody },
1919
+ ...server && { server }
1920
+ }]];
1921
+ });
1922
+ return entries.length ? Object.fromEntries(entries) : void 0;
1923
+ }
1666
1924
  /** The `stream` field of a content node, set when the media type is a stream. `node` is the parsed item schema. */
1667
1925
  function getStreamField({ contentType, mediaType, refs, document, node }) {
1668
1926
  if (!isStream(contentType, mediaType)) return {};
@@ -1733,11 +1991,12 @@ function collectPropertyKeysByFlag(schema, flag) {
1733
1991
  function parseParameter({ param, pointer, parentName, options, parseSchema, refs }) {
1734
1992
  const schemaName = parentName && param.name ? pascalCase(`${parentName} ${param.name}`) : void 0;
1735
1993
  const contentType = param.schema ? void 0 : Object.keys(param.content ?? {})[0];
1736
- const rawSchema = param.schema ?? getMediaType({
1994
+ const mediaType = getMediaType({
1737
1995
  content: param.content,
1738
1996
  contentType,
1739
1997
  refs
1740
- })?.schema;
1998
+ });
1999
+ const rawSchema = param.schema ?? mediaType?.schema;
1741
2000
  const schema = rawSchema ? parseSchema({
1742
2001
  schema: rawSchema,
1743
2002
  name: schemaName
@@ -1753,7 +2012,10 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
1753
2012
  },
1754
2013
  required: param.required ?? false,
1755
2014
  ...pickStyleFields(param),
1756
- ...contentType !== void 0 ? { contentType } : {}
2015
+ ...contentType !== void 0 ? { contentType } : {},
2016
+ ...getExamples(mediaType ?? param, refs),
2017
+ ...param.deprecated && { deprecated: true },
2018
+ ...param.allowEmptyValue && { allowEmptyValue: true }
1757
2019
  });
1758
2020
  }
1759
2021
  /**
@@ -1798,12 +2060,12 @@ function parseOperation({ operation, ...ctx }) {
1798
2060
  name: requestBodyName
1799
2061
  }), bodyRequired);
1800
2062
  scanSchema(node, `${mediaTypePointer(body?.content, ct, `${pointer}/requestBody/content/${escapePointerToken(ct)}`)}/${schemaKeyword(mediaType)}`);
1801
- const encoding = getEncoding(mediaType?.encoding);
1802
2063
  return [_kubb_kit.ast.factory.createContent({
1803
2064
  contentType: ct,
1804
2065
  schema: node,
1805
2066
  keysToOmit: collectPropertyKeysByFlag(schema, "readOnly"),
1806
- ...encoding && { encoding },
2067
+ ...mediaType && getEncodingFields(mediaType),
2068
+ ...mediaType && getExamples(mediaType, refs),
1807
2069
  ...getStreamField({
1808
2070
  contentType: ct,
1809
2071
  mediaType,
@@ -1819,12 +2081,13 @@ function parseOperation({ operation, ...ctx }) {
1819
2081
  required: bodyRequired || void 0,
1820
2082
  content: content.length > 0 ? content : void 0
1821
2083
  } : void 0;
1822
- const responses = getResponseStatusCodes(operation).map((statusCode) => {
2084
+ const responses = getResponseStatusCodes(operation).map((key) => {
1823
2085
  const response = getResponseByStatusCode({
1824
2086
  operation,
1825
2087
  refs,
1826
- statusCode
2088
+ statusCode: key
1827
2089
  });
2090
+ const statusCode = key.toLowerCase();
1828
2091
  const responseName = operationName ? `${operationName}Status${statusCode}` : void 0;
1829
2092
  const parseEntrySchema = (ct) => {
1830
2093
  const raw = getBodySchema({
@@ -1842,10 +2105,12 @@ function parseOperation({ operation, ...ctx }) {
1842
2105
  schema: raw,
1843
2106
  name: responseName
1844
2107
  }) : _kubb_kit.ast.factory.createSchema({ type: options.emptySchemaType });
1845
- if (raw && ct) scanSchema(node, `${mediaTypePointer(response?.content, ct, `${pointer}/responses/${statusCode}/content/${escapePointerToken(ct)}`)}/${schemaKeyword(mediaType)}`);
2108
+ if (raw && ct) scanSchema(node, `${mediaTypePointer(response?.content, ct, `${pointer}/responses/${key}/content/${escapePointerToken(ct)}`)}/${schemaKeyword(mediaType)}`);
1846
2109
  return {
1847
2110
  schema: node,
1848
2111
  keysToOmit: collectPropertyKeysByFlag(raw, "writeOnly"),
2112
+ ...mediaType && getEncodingFields(mediaType),
2113
+ ...mediaType && getExamples(mediaType, refs),
1849
2114
  ...ct ? getStreamField({
1850
2115
  contentType: ct,
1851
2116
  mediaType,
@@ -1864,11 +2129,32 @@ function parseOperation({ operation, ...ctx }) {
1864
2129
  contentType: "",
1865
2130
  ...parseEntrySchema(contentType)
1866
2131
  }));
2132
+ const responsePointer = `${pointer}/responses/${key}`;
2133
+ const headers = Object.entries(response?.headers ?? {}).flatMap(([name, value]) => {
2134
+ const header = name.toLowerCase() === "content-type" ? null : refs.deref(value);
2135
+ if (!header) return [];
2136
+ return [parseParameter({
2137
+ param: {
2138
+ ...header,
2139
+ name,
2140
+ in: "header"
2141
+ },
2142
+ pointer: `${responsePointer}/headers/${escapePointerToken(name)}`,
2143
+ parentName: responseName,
2144
+ options,
2145
+ parseSchema,
2146
+ refs
2147
+ })];
2148
+ });
2149
+ const links = getLinks(response?.links, refs);
1867
2150
  return _kubb_kit.ast.factory.createResponse({
1868
- pointer: `${pointer}/responses/${statusCode}`,
2151
+ pointer: responsePointer,
1869
2152
  statusCode,
2153
+ summary: response?.summary,
1870
2154
  description: response?.description,
1871
- content: responseContent
2155
+ content: responseContent,
2156
+ ...headers.length && { headers },
2157
+ ...links && { links }
1872
2158
  });
1873
2159
  });
1874
2160
  const pickDoc = (key) => {
@@ -1877,7 +2163,8 @@ function parseOperation({ operation, ...ctx }) {
1877
2163
  const fallback = operation.pathItem[key];
1878
2164
  return typeof fallback === "string" ? fallback : void 0;
1879
2165
  };
1880
- const servers = operation.schema.servers ?? operation.pathItem.servers;
2166
+ const servers = operation.schema.servers?.length ? operation.schema.servers : operation.pathItem.servers;
2167
+ const auth = toAuthRequirements(operation.schema.security ?? document.security, document);
1881
2168
  return _kubb_kit.ast.factory.createOperation({
1882
2169
  pointer,
1883
2170
  operationId,
@@ -1888,11 +2175,13 @@ function parseOperation({ operation, ...ctx }) {
1888
2175
  summary: pickDoc("summary") || void 0,
1889
2176
  description: pickDoc("description") || void 0,
1890
2177
  deprecated: operation.schema.deprecated || void 0,
2178
+ externalDocs: getExternalDocs(operation.schema.externalDocs),
1891
2179
  parameters,
1892
2180
  requestBody,
1893
2181
  responses,
1894
2182
  extensions: pickExtensions(operation.schema),
1895
- ...servers && { servers: toInputServers(servers) }
2183
+ ...servers && { servers: toInputServers(servers) },
2184
+ ...auth && { auth }
1896
2185
  });
1897
2186
  }
1898
2187
  // src/emit/createNode.ts
@@ -1913,6 +2202,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
1913
2202
  default: defaultValue,
1914
2203
  examples: extractExamples(schema),
1915
2204
  format: schema.format,
2205
+ externalDocs: getExternalDocs(schema.externalDocs),
1916
2206
  ...extras
1917
2207
  });
1918
2208
  }
@@ -2377,13 +2667,15 @@ const annotationKeys = /* @__PURE__ */ new Set([
2377
2667
  ]);
2378
2668
  /**
2379
2669
  * Moves `allOf` members that hold only annotations or `if`/`then`/`else` onto the parent, so they do
2380
- * not become `unknown`. The parent's own values win, and the conditional keywords are not enforced.
2670
+ * not become `unknown`. The parent's own values win. The parser reads their `if`/`then`/`else` into `conditionals`.
2381
2671
  */
2672
+ function isAnnotationMember(member) {
2673
+ return !!member && typeof member === "object" && !isReference(member) && Object.keys(member).every((key) => annotationKeys.has(key));
2674
+ }
2382
2675
  function mergeAnnotations(schema) {
2383
2676
  const members = schema.allOf;
2384
- const isAnnotation = (member) => !isReference(member) && Object.keys(member).every((key) => annotationKeys.has(key));
2385
- const annotations = members.filter(isAnnotation);
2386
- const rest = members.filter((member) => !isAnnotation(member));
2677
+ const annotations = members.filter(isAnnotationMember);
2678
+ const rest = members.filter((member) => !isAnnotationMember(member));
2387
2679
  return annotations.length && rest.length ? {
2388
2680
  ...Object.assign({}, ...annotations),
2389
2681
  ...schema,
@@ -2416,7 +2708,8 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
2416
2708
  default: mergedDefault,
2417
2709
  examples: extractExamples(schema) ?? memberNode.examples,
2418
2710
  pattern: schema.pattern ?? ("pattern" in memberNode ? memberNode.pattern : void 0),
2419
- format: schema.format ?? memberNode.format
2711
+ format: schema.format ?? memberNode.format,
2712
+ externalDocs: getExternalDocs(schema.externalDocs) ?? memberNode.externalDocs
2420
2713
  });
2421
2714
  }
2422
2715
  const { members: discriminatedAllOf, discriminantValues } = extractDiscriminatedAllOfMembers({
@@ -2491,7 +2784,7 @@ function convertUnion(context) {
2491
2784
  };
2492
2785
  const discriminator = isDiscriminator(schema) ? schema.discriminator : void 0;
2493
2786
  const declaredMembers = [...schema.oneOf ?? [], ...schema.anyOf ?? []];
2494
- const defaultRef = getDefaultMappingRef(discriminator);
2787
+ const defaultRef = getDefaultMappingRef(typeof schema.discriminator === "object" ? schema.discriminator : void 0);
2495
2788
  const unionMembers = resolveUnionMembers(defaultRef && !declaredMembers.some((member) => isReference(member) && member.$ref === defaultRef) ? [...declaredMembers, { $ref: defaultRef }] : declaredMembers, schema.properties ?? {});
2496
2789
  const strategy = schema.oneOf ? "one" : "any";
2497
2790
  const explicitDiscriminatorPropertyName = discriminator?.propertyName;
@@ -2603,11 +2896,18 @@ function getPrimitiveType(type) {
2603
2896
  }
2604
2897
  /** Shared by number, integer and bigint nodes; the exclusive bounds keep only the OAS 3.1 numeric form. */
2605
2898
  function getNumericConstraints(schema) {
2899
+ const exclusiveMinimum = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : void 0;
2900
+ const exclusiveMaximum = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : void 0;
2901
+ const hasExclusive = exclusiveMinimum !== void 0 || exclusiveMaximum !== void 0;
2606
2902
  return {
2607
2903
  min: schema.minimum,
2608
2904
  max: schema.maximum,
2609
- exclusiveMinimum: typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : void 0,
2610
- exclusiveMaximum: typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : void 0,
2905
+ ...hasExclusive && { exclusive: {
2906
+ ...exclusiveMinimum !== void 0 && { min: exclusiveMinimum },
2907
+ ...exclusiveMaximum !== void 0 && { max: exclusiveMaximum }
2908
+ } },
2909
+ exclusiveMinimum,
2910
+ exclusiveMaximum,
2611
2911
  multipleOf: schema.multipleOf
2612
2912
  };
2613
2913
  }
@@ -2616,11 +2916,11 @@ function getNumericConstraints(schema) {
2616
2916
  */
2617
2917
  function isWithinBounds({ value, schema }) {
2618
2918
  if (typeof value !== "number") return true;
2619
- const { min, max, exclusiveMinimum, exclusiveMaximum, multipleOf } = getNumericConstraints(schema);
2919
+ const { min, max, exclusive, multipleOf } = getNumericConstraints(schema);
2620
2920
  if (min !== void 0 && value < min) return false;
2621
2921
  if (max !== void 0 && value > max) return false;
2622
- if (exclusiveMinimum !== void 0 && value <= exclusiveMinimum) return false;
2623
- if (exclusiveMaximum !== void 0 && value >= exclusiveMaximum) return false;
2922
+ if (exclusive?.min !== void 0 && value <= exclusive.min) return false;
2923
+ if (exclusive?.max !== void 0 && value >= exclusive.max) return false;
2624
2924
  if (multipleOf !== void 0 && Math.abs(value / multipleOf - Math.round(value / multipleOf)) > 1e-9) return false;
2625
2925
  return true;
2626
2926
  }
@@ -2778,6 +3078,15 @@ function convertFormattedEnum(context) {
2778
3078
  }))
2779
3079
  });
2780
3080
  }
3081
+ function getStringContent({ schema, parse }) {
3082
+ const { contentMediaType: mediaType, contentEncoding: encoding, contentSchema } = schema;
3083
+ if (mediaType === void 0 && encoding === void 0 && !contentSchema) return {};
3084
+ return { content: {
3085
+ ...mediaType !== void 0 && { mediaType },
3086
+ ...encoding !== void 0 && { encoding },
3087
+ ...contentSchema && { schema: parse({ schema: contentSchema }) }
3088
+ } };
3089
+ }
2781
3090
  /**
2782
3091
  * Converts a `type: 'string'` schema into a `StringSchemaNode`.
2783
3092
  */
@@ -2788,7 +3097,8 @@ function convertString(context) {
2788
3097
  primitive: "string",
2789
3098
  min: schema.minLength,
2790
3099
  max: schema.maxLength,
2791
- pattern: schema.pattern
3100
+ pattern: schema.pattern,
3101
+ ...getStringContent(context)
2792
3102
  });
2793
3103
  }
2794
3104
  /**
@@ -2802,6 +3112,15 @@ function convertNumeric(context, type) {
2802
3112
  });
2803
3113
  }
2804
3114
  // src/emit/converters/structural.ts
3115
+ function getContains(schema, parse) {
3116
+ const { contains, minContains, maxContains } = schema;
3117
+ if (!contains || typeof contains !== "object") return {};
3118
+ return { contains: {
3119
+ schema: parse({ schema: contains }),
3120
+ ...typeof minContains === "number" && { min: minContains },
3121
+ ...typeof maxContains === "number" && { max: maxContains }
3122
+ } };
3123
+ }
2805
3124
  /**
2806
3125
  * Resolves a `true` or empty-object map schema (`additionalProperties`/`patternProperties`) to
2807
3126
  * `options.unknownType`, otherwise parses it as a regular schema.
@@ -2854,7 +3173,7 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
2854
3173
  required
2855
3174
  });
2856
3175
  }) : [];
2857
- const additionalProperties = schema.additionalProperties;
3176
+ const additionalProperties = schema.additionalProperties ?? schema.unevaluatedProperties;
2858
3177
  const additionalPropertiesNode = (() => {
2859
3178
  if (additionalProperties === true) return true;
2860
3179
  if (additionalProperties) return resolveMapSchema(additionalProperties, {
@@ -2884,6 +3203,8 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
2884
3203
  additionalProperties: additionalPropertiesNode,
2885
3204
  patternProperties,
2886
3205
  propertyNames,
3206
+ min: schema.minProperties,
3207
+ max: schema.maxProperties,
2887
3208
  minProperties: schema.minProperties,
2888
3209
  maxProperties: schema.maxProperties
2889
3210
  });
@@ -2914,7 +3235,8 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
2914
3235
  */
2915
3236
  function convertTuple({ schema, name, nullable, defaultValue, options, parse }) {
2916
3237
  const tupleItems = (schema.prefixItems ?? []).map((item) => parse({ schema: item }));
2917
- const rest = schema.items === false ? void 0 : !schema.items || schema.items === true ? _kubb_kit.ast.factory.createSchema({ type: options.unknownType }) : parse({ schema: schema.items });
3238
+ const tail = schema.items ?? schema.unevaluatedItems;
3239
+ const rest = tail === false ? void 0 : !tail || tail === true ? _kubb_kit.ast.factory.createSchema({ type: options.unknownType }) : parse({ schema: tail });
2918
3240
  return createNode({
2919
3241
  schema,
2920
3242
  name,
@@ -2926,7 +3248,8 @@ function convertTuple({ schema, name, nullable, defaultValue, options, parse })
2926
3248
  items: tupleItems,
2927
3249
  rest,
2928
3250
  min: schema.minItems,
2929
- max: schema.maxItems
3251
+ max: schema.maxItems,
3252
+ ...getContains(schema, parse)
2930
3253
  });
2931
3254
  }
2932
3255
  /**
@@ -2950,7 +3273,8 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
2950
3273
  items,
2951
3274
  min: schema.minItems,
2952
3275
  max: schema.maxItems,
2953
- unique: schema.uniqueItems ?? void 0
3276
+ unique: schema.uniqueItems ?? void 0,
3277
+ ...getContains(schema, parse)
2954
3278
  });
2955
3279
  }
2956
3280
  // src/emit/parseSchema.ts
@@ -3078,6 +3402,20 @@ const schemaRules = [
3078
3402
  ];
3079
3403
  // src/parser.ts
3080
3404
  /**
3405
+ * `unevaluated*` also sees what composition siblings evaluate, so with such a sibling it is dropped to keep the schema open.
3406
+ */
3407
+ function hasUnevaluatedSiblings(schema) {
3408
+ if (schema.unevaluatedProperties === void 0 && schema.unevaluatedItems === void 0) return false;
3409
+ return [
3410
+ schema.allOf,
3411
+ schema.anyOf,
3412
+ schema.oneOf,
3413
+ schema.if,
3414
+ schema.dependentSchemas,
3415
+ schema.$ref
3416
+ ].some((value) => value !== void 0);
3417
+ }
3418
+ /**
3081
3419
  * Creates the schema converter bound to one OpenAPI document: `parseSchema` dispatches each
3082
3420
  * schema through the ordered `schemaRules` table, with the parser options merged once.
3083
3421
  *
@@ -3091,10 +3429,20 @@ function createSchemaParser(ctx) {
3091
3429
  };
3092
3430
  function parseSchema({ schema, name }) {
3093
3431
  const flattenedSchema = flattenSchema(schema);
3094
- if (flattenedSchema !== schema) return parseSchema({
3095
- schema: flattenedSchema,
3096
- name
3097
- });
3432
+ if (flattenedSchema !== schema) {
3433
+ const { if: _if, then: _then, else: _else, dependentRequired: _required, dependentSchemas: _schemas, ...shape } = flattenedSchema;
3434
+ return withConditionals(parseSchema({
3435
+ schema: shape,
3436
+ name
3437
+ }), [schema, ...schema.allOf]);
3438
+ }
3439
+ if (hasUnevaluatedSiblings(schema)) {
3440
+ const { unevaluatedProperties: _properties, unevaluatedItems: _items, ...open } = schema;
3441
+ return parseSchema({
3442
+ schema: open,
3443
+ name
3444
+ });
3445
+ }
3098
3446
  const nullable = isNullable(schema) || void 0;
3099
3447
  const context = {
3100
3448
  schema,
@@ -3108,8 +3456,81 @@ function createSchemaParser(ctx) {
3108
3456
  refs,
3109
3457
  renames
3110
3458
  };
3111
- for (const rule of schemaRules) if (rule.match(context)) return rule.convert(context);
3112
- return createNode(context, { type: options.emptySchemaType });
3459
+ const rule = schemaRules.find((entry) => entry.match(context));
3460
+ return withConditionals(rule ? rule.convert(context) : createNode(context, { type: options.emptySchemaType }), [schema, ...Array.isArray(schema.allOf) ? schema.allOf.filter(isAnnotationMember) : []]);
3461
+ }
3462
+ const presenceKeys = /* @__PURE__ */ new WeakMap();
3463
+ function requireKeys(keys) {
3464
+ const unknown = _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.schemaTypes.unknown });
3465
+ const node = _kubb_kit.ast.factory.createSchema({
3466
+ type: _kubb_kit.ast.schemaTypes.object,
3467
+ primitive: "object",
3468
+ properties: keys.map((name) => _kubb_kit.ast.factory.createProperty({
3469
+ name,
3470
+ required: true,
3471
+ schema: unknown
3472
+ }))
3473
+ });
3474
+ presenceKeys.set(node, keys.join("\0"));
3475
+ return node;
3476
+ }
3477
+ /**
3478
+ * Adds `if`/`then`/`else`, `dependentRequired` and `dependentSchemas` to the node as `conditionals`.
3479
+ */
3480
+ function withConditionals(node, sources) {
3481
+ const conditionals = sources.flatMap(toConditionals);
3482
+ const existing = new Set((node.conditionals ?? []).map(presenceKey));
3483
+ const added = conditionals.filter((entry) => {
3484
+ const key = presenceKey(entry);
3485
+ return key === void 0 || !existing.has(key);
3486
+ });
3487
+ return added.length ? {
3488
+ ...node,
3489
+ conditionals: [...node.conditionals ?? [], ...added]
3490
+ } : node;
3491
+ }
3492
+ /**
3493
+ * The keys an entry checks for presence, or `undefined` when a branch checks more than presence and the entry is always kept.
3494
+ */
3495
+ function presenceKey({ if: condition, then: thenNode, else: elseNode }) {
3496
+ const keys = [
3497
+ condition,
3498
+ thenNode,
3499
+ elseNode
3500
+ ].map((branch) => branch ? presenceKeys.get(branch) : "");
3501
+ return keys.includes(void 0) ? void 0 : keys.join("\n");
3502
+ }
3503
+ function toConditionals(schema) {
3504
+ const branch = (value) => {
3505
+ if (!value || typeof value !== "object") return void 0;
3506
+ const { required, type, ...rest } = value;
3507
+ if (Array.isArray(required) && required.length && (type === void 0 || type === "object") && !Object.keys(rest).length) return requireKeys(required);
3508
+ return parseSchema({ schema: value });
3509
+ };
3510
+ const entries = (value) => value && typeof value === "object" ? Object.entries(value) : [];
3511
+ const conditionals = [];
3512
+ const condition = branch(schema.if);
3513
+ if (condition) {
3514
+ const thenNode = branch(schema.then);
3515
+ const elseNode = branch(schema.else);
3516
+ conditionals.push({
3517
+ if: condition,
3518
+ ...thenNode && { then: thenNode },
3519
+ ...elseNode && { else: elseNode }
3520
+ });
3521
+ }
3522
+ for (const [key, required] of entries(schema.dependentRequired)) if (Array.isArray(required) && required.length && required.every((name) => typeof name === "string")) conditionals.push({
3523
+ if: requireKeys([key]),
3524
+ then: requireKeys(required)
3525
+ });
3526
+ for (const [key, dependent] of entries(schema.dependentSchemas)) {
3527
+ const thenNode = branch(dependent);
3528
+ if (thenNode) conditionals.push({
3529
+ if: requireKeys([key]),
3530
+ then: thenNode
3531
+ });
3532
+ }
3533
+ return conditionals;
3113
3534
  }
3114
3535
  return parseSchema;
3115
3536
  }
@@ -3448,6 +3869,7 @@ const adapterOas = (0, _kubb_core.defineExtension)({
3448
3869
  schemaNodes.push(promotedEnums ? refPromotedEnums(node, promotedEnums) : node);
3449
3870
  }
3450
3871
  const operations = promotedEnums ? operationNodes.map((node) => refPromotedEnums(node, promotedEnums)) : operationNodes;
3872
+ const authSchemes = toAuthSchemes(document.components?.securitySchemes, refs);
3451
3873
  return _kubb_kit.ast.factory.createInput({
3452
3874
  schemas: schemaNodes,
3453
3875
  operations,
@@ -3455,23 +3877,25 @@ const adapterOas = (0, _kubb_core.defineExtension)({
3455
3877
  title: document.info?.title,
3456
3878
  description: document.info?.description,
3457
3879
  version: document.info?.version,
3880
+ summary: document.info?.summary,
3881
+ termsOfService: document.info?.termsOfService,
3882
+ contact: pickStrings(document.info?.contact, [
3883
+ "name",
3884
+ "url",
3885
+ "email"
3886
+ ]),
3887
+ license: typeof document.info?.license?.name === "string" ? {
3888
+ ...pickStrings(document.info.license, ["identifier", "url"]),
3889
+ name: document.info.license.name
3890
+ } : void 0,
3891
+ externalDocs: getExternalDocs(document.externalDocs),
3458
3892
  baseURL: resolveBaseUrl({
3459
3893
  document,
3460
3894
  server
3461
3895
  }),
3462
3896
  servers: toInputServers(document.servers ?? []),
3463
- securitySchemes: Object.entries(document.components?.securitySchemes ?? {}).flatMap(([name, value]) => {
3464
- const scheme = refs.deref(value);
3465
- return scheme?.type ? [{
3466
- name,
3467
- type: scheme.type,
3468
- description: scheme.description,
3469
- scheme: scheme.scheme,
3470
- bearerFormat: scheme.bearerFormat,
3471
- in: scheme.in,
3472
- parameterName: scheme.name
3473
- }] : [];
3474
- }),
3897
+ ...document.tags?.length && { tags: toInputTags(document.tags) },
3898
+ ...authSchemes.length && { auth: authSchemes },
3475
3899
  extensions: pickExtensions(document)
3476
3900
  }
3477
3901
  });