@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.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { defineExtension } from "@kubb/core";
2
2
  import { Diagnostics, ast, childName, enumPrimitive, enumPropName, extractRefName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
3
- import { join } from "node:path";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
4
5
  import { access, readFile } from "node:fs/promises";
5
6
  import { upgrade } from "@scalar/openapi-upgrader";
6
7
  import { bundle } from "api-ref-bundler";
@@ -19,7 +20,7 @@ var compatibility = {
19
20
  "node": ">=22.22"
20
21
  };
21
22
  // package.json
22
- var version = "5.17.1";
23
+ var version = "5.18.1";
23
24
  // src/constants.ts
24
25
  /**
25
26
  * Default parser options applied when no explicit options are provided.
@@ -247,7 +248,7 @@ function patchDiscriminatorNode(node, entry) {
247
248
  * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
248
249
  */
249
250
  function convert(text, pascal) {
250
- 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) => {
251
+ 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) => {
251
252
  if (word.length > 1 && word === word.toUpperCase()) return word;
252
253
  return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
253
254
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
@@ -401,6 +402,21 @@ function isOpenApi32(document) {
401
402
  const [major = 0, minor = 0] = String(document.openapi).split(".").map(Number);
402
403
  return major > 3 || major === 3 && minor >= 2;
403
404
  }
405
+ function pickStrings(source, keys) {
406
+ if (!source || typeof source !== "object") return void 0;
407
+ const entries = keys.flatMap((key) => {
408
+ const value = source[key];
409
+ return typeof value === "string" ? [[key, value]] : [];
410
+ });
411
+ return entries.length ? Object.fromEntries(entries) : void 0;
412
+ }
413
+ function getExternalDocs(source) {
414
+ const docs = pickStrings(source, ["url", "description"]);
415
+ return docs?.url ? {
416
+ url: docs.url,
417
+ ...docs.description !== void 0 && { description: docs.description }
418
+ } : void 0;
419
+ }
404
420
  /**
405
421
  * Returns the `x-*` keys of `source` as-is, or `undefined` when there are none.
406
422
  */
@@ -415,12 +431,12 @@ function isReference(obj) {
415
431
  return !!obj && typeof obj === "object" && "$ref" in obj;
416
432
  }
417
433
  /**
418
- * Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object,
419
- * excluding the Swagger 2 string form.
434
+ * Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object that names a
435
+ * `propertyName`, excluding the Swagger 2 string form and a 3.2 discriminator that only sets `defaultMapping`.
420
436
  */
421
437
  function isDiscriminator(obj) {
422
- const record = obj;
423
- return !!obj && !!record["discriminator"] && typeof record["discriminator"] !== "string";
438
+ const discriminator = obj?.["discriminator"];
439
+ return !!discriminator && typeof discriminator === "object" && typeof discriminator.propertyName === "string";
424
440
  }
425
441
  /**
426
442
  * Returns `true` when a schema is a raw binary payload.
@@ -593,6 +609,65 @@ function createRefs(document) {
593
609
  derefKeepingRef
594
610
  };
595
611
  }
612
+ // src/load/schemaIds.ts
613
+ const DATA_KEYS = /* @__PURE__ */ new Set([
614
+ "example",
615
+ "examples",
616
+ "const",
617
+ "enum",
618
+ "default"
619
+ ]);
620
+ const NAMED_ENTRY_KEYS = /* @__PURE__ */ new Set([
621
+ "properties",
622
+ "patternProperties",
623
+ "$defs",
624
+ "definitions",
625
+ "schemas",
626
+ "dependentSchemas"
627
+ ]);
628
+ function walk(node, pointer, visit, parentKey) {
629
+ if (!node || typeof node !== "object") return;
630
+ if (!Array.isArray(node)) visit(node, pointer);
631
+ const named = parentKey !== void 0 && NAMED_ENTRY_KEYS.has(parentKey);
632
+ for (const [key, value] of Object.entries(node)) {
633
+ if (!named && (DATA_KEYS.has(key) || key.startsWith("x-"))) continue;
634
+ walk(value, `${pointer}/${escapePointerToken(key)}`, visit, Array.isArray(node) ? parentKey : key);
635
+ }
636
+ }
637
+ /**
638
+ * The declaration in the nearest enclosing schema, else the only one, else `undefined`.
639
+ */
640
+ function pick(declarations, pointer) {
641
+ if (!declarations) return void 0;
642
+ const enclosing = declarations.filter((target) => pointer === target || pointer.startsWith(`${target}/`));
643
+ if (enclosing.length) return enclosing.reduce((a, b) => b.length > a.length ? b : a);
644
+ return declarations.length === 1 ? declarations[0] : void 0;
645
+ }
646
+ /**
647
+ * Rewrites, in place, each `$ref` to an `$id`, `$anchor` or `$dynamicAnchor`, and each `$dynamicRef`, into a
648
+ * `#/...` pointer, so it is not fetched. Instance data and `x-` extensions are left as written.
649
+ *
650
+ * shortcut: `$id` matches the `$ref` string exactly and `$dynamicRef` resolves statically to the nearest
651
+ * enclosing anchor, so a relative `$id` base or a recursively extended schema is not followed, upgrade when a spec needs that.
652
+ */
653
+ function resolveSchemaIds(document) {
654
+ const targets = /* @__PURE__ */ new Map();
655
+ const declare = (key, pointer) => targets.set(key, [...targets.get(key) ?? [], pointer]);
656
+ walk(document, "#", (node, pointer) => {
657
+ if (typeof node["$id"] === "string") declare(node["$id"], pointer);
658
+ for (const key of ["$anchor", "$dynamicAnchor"]) if (typeof node[key] === "string") declare(`#${node[key]}`, pointer);
659
+ });
660
+ if (!targets.size) return;
661
+ walk(document, "#", (node, pointer) => {
662
+ const ref = typeof node["$ref"] === "string" ? pick(targets.get(node["$ref"]), pointer) : void 0;
663
+ if (ref) node["$ref"] = ref;
664
+ const dynamicRef = typeof node["$dynamicRef"] === "string" ? pick(targets.get(node["$dynamicRef"]), pointer) : void 0;
665
+ if (dynamicRef && node["$ref"] === void 0) {
666
+ node["$ref"] = dynamicRef;
667
+ delete node["$dynamicRef"];
668
+ }
669
+ });
670
+ }
596
671
  // src/load/source.ts
597
672
  const urlRegExp = /^https?:\/+/i;
598
673
  /**
@@ -762,6 +837,21 @@ function isExtensionPath(path) {
762
837
  return path.some((token, index) => String(token).startsWith("x-") && !namedEntryKeys.has(String(path[index - 1])));
763
838
  }
764
839
  /**
840
+ * Returns the base for relative `$ref`s: the 3.2 `$self` resolved against `pathOrUrl`, else `pathOrUrl`.
841
+ */
842
+ function getBaseUri(pathOrUrl, root) {
843
+ const self = root && typeof root === "object" ? root.$self : void 0;
844
+ if (typeof self !== "string" || !self) return pathOrUrl;
845
+ try {
846
+ if (urlRegExp.test(self)) return new URL(self).href;
847
+ if (/^file:/i.test(self)) return fileURLToPath(self);
848
+ if (/^[a-z][a-z\d+.-]*:/i.test(self)) return pathOrUrl;
849
+ return urlRegExp.test(pathOrUrl) ? new URL(self, pathOrUrl).href : resolve(dirname(pathOrUrl), self);
850
+ } catch {
851
+ return pathOrUrl;
852
+ }
853
+ }
854
+ /**
765
855
  * Bundles a multi-file OpenAPI document into a single document via `api-ref-bundler`.
766
856
  *
767
857
  * External file schemas are hoisted into named `components.schemas` entries, so a property
@@ -774,8 +864,9 @@ function isExtensionPath(path) {
774
864
  * all-internal document it is a no-op that still walks the whole tree to confirm that, which
775
865
  * costs real time on a large spec.
776
866
  *
777
- * `document` stands in for the file at `pathOrUrl`, such as inline input. Every other file or URL
778
- * read, including one that fails, lands in `sources`. A `$ref` that cannot be read reports
867
+ * `document` stands in for the file at `pathOrUrl`, such as inline input. Relative `$ref`s resolve
868
+ * against the OpenAPI 3.2 `$self` when the document sets one. Every other file or URL read,
869
+ * including one that fails, lands in `sources`. A `$ref` that cannot be read reports
779
870
  * `KUBB_REF_NOT_FOUND` at the key that holds it, as a warning when it sits inside an `x-` extension.
780
871
  *
781
872
  * @example Local file
@@ -787,8 +878,10 @@ function isExtensionPath(path) {
787
878
  async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
788
879
  const cache = /* @__PURE__ */ new Map();
789
880
  const toKey = (sourcePath) => urlRegExp.test(sourcePath) ? new URL(sourcePath).href : sourcePath;
881
+ let entry = pathOrUrl;
882
+ let entryDocument = document;
790
883
  const resolver = (sourcePath) => {
791
- if (document && sourcePath === pathOrUrl) return Promise.resolve(document);
884
+ if (entryDocument !== void 0 && toKey(sourcePath) === toKey(entry)) return Promise.resolve(entryDocument);
792
885
  const key = toKey(sourcePath);
793
886
  const cached = cache.get(key);
794
887
  if (cached) return cached;
@@ -798,9 +891,12 @@ async function bundleDocument(pathOrUrl, { document, sources = [] } = {}) {
798
891
  return result;
799
892
  };
800
893
  const root = await resolver(pathOrUrl);
894
+ resolveSchemaIds(root);
801
895
  if (typeof root === "object" && root !== null && !hasExternalRef(root)) return root;
802
- return await bundle(pathOrUrl, resolver, { hooks: { onError: (message, { path, state }) => {
803
- const pointer = toKey(state.baseFile) === toKey(pathOrUrl) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
896
+ entry = getBaseUri(pathOrUrl, root);
897
+ entryDocument = root;
898
+ return await bundle(entry, resolver, { hooks: { onError: (message, { path, state }) => {
899
+ const pointer = toKey(state.baseFile) === toKey(entry) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
804
900
  const diagnostic = {
805
901
  code: Diagnostics.code.refNotFound,
806
902
  severity: isExtensionPath(path) ? "warning" : "error",
@@ -839,10 +935,12 @@ async function parseFromConfig(source, sources = []) {
839
935
  origin: "the inline `input` string",
840
936
  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."
841
937
  }) : structuredClone(source.data);
842
- return source.root && hasExternalRef(data) ? bundleDocument(join(source.root, inlineInputName), {
938
+ if (source.root && hasExternalRef(data)) return bundleDocument(join(source.root, inlineInputName), {
843
939
  document: data,
844
940
  sources
845
- }) : data;
941
+ });
942
+ resolveSchemaIds(data);
943
+ return data;
846
944
  }
847
945
  await assertInputExists(source.path);
848
946
  return bundleDocument(source.path, { sources });
@@ -1111,8 +1209,29 @@ const semanticSuffixes = {
1111
1209
  */
1112
1210
  function getSchemas(document, { contentType }, refs) {
1113
1211
  const components = document.components;
1212
+ /**
1213
+ * Follows a `$ref` to the schema it ends at. Keywords next to a `$ref` apply together with its target,
1214
+ * so they stay on a one-member `allOf` around it.
1215
+ */
1216
+ function inlineRef(schema, seen = /* @__PURE__ */ new Set()) {
1217
+ if (!isReference(schema) || seen.has(schema.$ref)) return schema;
1218
+ const { $ref, ...siblings } = schema;
1219
+ const resolved = refs.resolve($ref);
1220
+ if (!resolved) return schema;
1221
+ const target = inlineRef(resolved, seen.add($ref));
1222
+ if (!Object.keys(siblings).length) return target;
1223
+ const own = "allOf" in siblings && Array.isArray(siblings.allOf) ? siblings.allOf : [];
1224
+ return {
1225
+ ...siblings,
1226
+ allOf: [...own, target]
1227
+ };
1228
+ }
1229
+ /**
1230
+ * 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.
1231
+ */
1114
1232
  function resolveSchemaRef(schema) {
1115
1233
  if (!isReference(schema)) return schema;
1234
+ if (Object.keys(schema).length > 1) return inlineRef(schema);
1116
1235
  const resolved = refs.resolve(schema.$ref);
1117
1236
  return resolved && !isReference(resolved) ? resolved : schema;
1118
1237
  }
@@ -1167,6 +1286,80 @@ function getSchemas(document, { contentType }, refs) {
1167
1286
  pointers
1168
1287
  };
1169
1288
  }
1289
+ // src/model/security.ts
1290
+ const SCHEME_POINTER = "#/components/securitySchemes/";
1291
+ const API_KEY_LOCATIONS = /* @__PURE__ */ new Set([
1292
+ "header",
1293
+ "query",
1294
+ "cookie"
1295
+ ]);
1296
+ function getCredential(scheme) {
1297
+ if (scheme.type === "apiKey") return scheme.name && scheme.in && API_KEY_LOCATIONS.has(scheme.in) ? {
1298
+ type: "apiKey",
1299
+ in: scheme.in,
1300
+ name: scheme.name
1301
+ } : void 0;
1302
+ if (scheme.type === "http") return scheme.scheme ? {
1303
+ type: "http",
1304
+ scheme: scheme.scheme.toLowerCase(),
1305
+ ...scheme.bearerFormat && { bearerFormat: scheme.bearerFormat }
1306
+ } : void 0;
1307
+ if (scheme.type === "openIdConnect") return {
1308
+ type: "openIdConnect",
1309
+ ...scheme.openIdConnectUrl && { url: scheme.openIdConnectUrl }
1310
+ };
1311
+ if (scheme.type === "oauth2") {
1312
+ const flows = Object.entries(scheme.flows ?? {}).map(([name, flow]) => {
1313
+ const scopes = flow && typeof flow === "object" && flow.scopes && typeof flow.scopes === "object" ? { scopes: flow.scopes } : {};
1314
+ return [name, {
1315
+ ...pickStrings(flow, [
1316
+ "authorizationUrl",
1317
+ "deviceAuthorizationUrl",
1318
+ "tokenUrl",
1319
+ "refreshUrl"
1320
+ ]),
1321
+ ...scopes
1322
+ }];
1323
+ });
1324
+ return {
1325
+ type: "oauth2",
1326
+ flows: Object.fromEntries(flows),
1327
+ ...scheme.oauth2MetadataUrl && { metadataUrl: scheme.oauth2MetadataUrl }
1328
+ };
1329
+ }
1330
+ return scheme.type === "mutualTLS" ? { type: "mutualTLS" } : void 0;
1331
+ }
1332
+ /**
1333
+ * Maps `components.securitySchemes` to `AuthScheme` entries, leaving out a scheme a client cannot place.
1334
+ */
1335
+ function toAuthSchemes(schemes, refs) {
1336
+ return Object.entries(schemes ?? {}).flatMap(([name, value]) => {
1337
+ const scheme = refs.deref(value);
1338
+ const credential = scheme && getCredential(scheme);
1339
+ if (!scheme || !credential) return [];
1340
+ return [{
1341
+ name,
1342
+ ...scheme.description && { description: scheme.description },
1343
+ ...scheme.deprecated && { deprecated: true },
1344
+ credential
1345
+ }];
1346
+ });
1347
+ }
1348
+ /**
1349
+ * Maps security requirements to `AuthRequirement` entries. A 3.2 URI key becomes the scheme name.
1350
+ */
1351
+ function toAuthRequirements(requirements, document) {
1352
+ if (!Array.isArray(requirements)) return void 0;
1353
+ const schemes = document.components?.securitySchemes ?? {};
1354
+ const toName = (key) => {
1355
+ const index = key.indexOf(SCHEME_POINTER);
1356
+ return Object.hasOwn(schemes, key) || index === -1 ? key : unescapePointerToken(key.slice(index + 29));
1357
+ };
1358
+ return requirements.filter((requirement) => !!requirement && typeof requirement === "object").map((requirement) => Object.entries(requirement).map(([key, scopes]) => ({
1359
+ scheme: toName(key),
1360
+ ...Array.isArray(scopes) && scopes.length && { scopes: scopes.map(String) }
1361
+ })));
1362
+ }
1170
1363
  // src/model/server.ts
1171
1364
  /**
1172
1365
  * Reads the server URL from the document's `servers` array at `server.index`,
@@ -1223,8 +1416,11 @@ function resolveServerUrl(server, overrides) {
1223
1416
  * Maps OpenAPI servers to `InputServer` entries: drops entries without a `url` and fills `{variable}` defaults.
1224
1417
  */
1225
1418
  function toInputServers(servers) {
1226
- return servers.filter((entry) => entry.url).map(({ url, description, variables }) => {
1227
- const declared = variables && Object.keys(variables).length > 0 ? { variables } : {};
1419
+ return servers.filter((entry) => entry.url).map(({ url, name, description, variables }) => {
1420
+ const declared = {
1421
+ ...name !== void 0 && { name },
1422
+ ...variables && Object.keys(variables).length > 0 && { variables }
1423
+ };
1228
1424
  try {
1229
1425
  return {
1230
1426
  url: resolveServerUrl({
@@ -1243,6 +1439,20 @@ function toInputServers(servers) {
1243
1439
  }
1244
1440
  });
1245
1441
  }
1442
+ // src/model/tag.ts
1443
+ function toInputTags(tags) {
1444
+ return tags.filter((tag) => typeof tag.name === "string").map(({ name, summary, description, parent, kind, externalDocs }) => {
1445
+ const docs = getExternalDocs(externalDocs);
1446
+ return {
1447
+ name,
1448
+ ...typeof summary === "string" && { summary },
1449
+ ...typeof description === "string" && { description },
1450
+ ...typeof parent === "string" && { parent },
1451
+ ...typeof kind === "string" && { kind },
1452
+ ...docs && { externalDocs: docs }
1453
+ };
1454
+ });
1455
+ }
1246
1456
  // src/model/mediaType.ts
1247
1457
  /**
1248
1458
  * The media type without its parameters, so `text/event-stream; charset=utf-8` matches the bare name.
@@ -1600,7 +1810,8 @@ const PARAMETER_STYLES = /* @__PURE__ */ new Set([
1600
1810
  "simple",
1601
1811
  "spaceDelimited",
1602
1812
  "pipeDelimited",
1603
- "deepObject"
1813
+ "deepObject",
1814
+ "cookie"
1604
1815
  ]);
1605
1816
  function pickStyleFields({ style, explode, allowReserved }) {
1606
1817
  return {
@@ -1609,16 +1820,45 @@ function pickStyleFields({ style, explode, allowReserved }) {
1609
1820
  ...allowReserved !== void 0 ? { allowReserved } : {}
1610
1821
  };
1611
1822
  }
1612
- /** The `encoding` of a media type, reduced to the entries that set a field Kubb carries. A `style` outside the OpenAPI set is dropped. */
1613
- function getEncoding(encoding) {
1614
- const entries = Object.entries(encoding ?? {}).flatMap(([property, { contentType, ...rest }]) => {
1615
- const node = {
1616
- ...contentType !== void 0 ? { contentType } : {},
1617
- ...pickStyleFields(rest)
1618
- };
1823
+ function getEncodingFields({ encoding, prefixEncoding, itemEncoding }) {
1824
+ const entries = Object.entries(encoding ?? {}).flatMap(([property, entry]) => {
1825
+ const node = toEncodingNode(entry);
1619
1826
  return Object.keys(node).length ? [[property, node]] : [];
1620
1827
  });
1621
- return entries.length ? Object.fromEntries(entries) : void 0;
1828
+ const item = itemEncoding && toEncodingNode(itemEncoding);
1829
+ return {
1830
+ ...entries.length && { encoding: Object.fromEntries(entries) },
1831
+ ...prefixEncoding?.length && { prefixEncoding: prefixEncoding.map(toEncodingNode) },
1832
+ ...item && Object.keys(item).length && { itemEncoding: item }
1833
+ };
1834
+ }
1835
+ function toEncodingNode({ contentType, encoding, prefixEncoding, itemEncoding, ...rest }) {
1836
+ return {
1837
+ ...contentType !== void 0 && { contentType },
1838
+ ...pickStyleFields(rest),
1839
+ ...getEncodingFields({
1840
+ encoding,
1841
+ prefixEncoding,
1842
+ itemEncoding
1843
+ })
1844
+ };
1845
+ }
1846
+ function getExamples({ example, examples }, refs) {
1847
+ const named = Object.entries(examples ?? {}).flatMap(([name, entry]) => {
1848
+ const resolved = refs.deref(entry);
1849
+ if (!resolved) return [];
1850
+ const { summary, description, dataValue, value, serializedValue } = resolved;
1851
+ const data = dataValue !== void 0 ? dataValue : value;
1852
+ return [{
1853
+ name,
1854
+ ...typeof summary === "string" && { summary },
1855
+ ...typeof description === "string" && { description },
1856
+ ...data !== void 0 && { value: data },
1857
+ ...typeof serializedValue === "string" && { serializedValue }
1858
+ }];
1859
+ });
1860
+ if (named.length) return { examples: named };
1861
+ return example !== void 0 ? { examples: [{ value: example }] } : {};
1622
1862
  }
1623
1863
  /**
1624
1864
  * Returns the media type entry for `contentType`, resolving a `$ref` into `components.mediaTypes`. `null` when absent.
@@ -1647,6 +1887,24 @@ function getBodySchema({ content, contentType, refs, document }) {
1647
1887
  if (binary) return binary;
1648
1888
  return schema ? refs.derefKeepingRef(schema) : null;
1649
1889
  }
1890
+ function getLinks(links, refs) {
1891
+ const entries = Object.entries(links ?? {}).flatMap(([name, value]) => {
1892
+ const link = refs.deref(value);
1893
+ if (!link) return [];
1894
+ const server = link.server ? toInputServers([link.server])[0] : void 0;
1895
+ return [[name, {
1896
+ ...pickStrings(link, [
1897
+ "operationId",
1898
+ "operationRef",
1899
+ "description"
1900
+ ]),
1901
+ ...link.parameters && { parameters: link.parameters },
1902
+ ..."requestBody" in link && { requestBody: link.requestBody },
1903
+ ...server && { server }
1904
+ }]];
1905
+ });
1906
+ return entries.length ? Object.fromEntries(entries) : void 0;
1907
+ }
1650
1908
  /** The `stream` field of a content node, set when the media type is a stream. `node` is the parsed item schema. */
1651
1909
  function getStreamField({ contentType, mediaType, refs, document, node }) {
1652
1910
  if (!isStream(contentType, mediaType)) return {};
@@ -1717,11 +1975,12 @@ function collectPropertyKeysByFlag(schema, flag) {
1717
1975
  function parseParameter({ param, pointer, parentName, options, parseSchema, refs }) {
1718
1976
  const schemaName = parentName && param.name ? pascalCase(`${parentName} ${param.name}`) : void 0;
1719
1977
  const contentType = param.schema ? void 0 : Object.keys(param.content ?? {})[0];
1720
- const rawSchema = param.schema ?? getMediaType({
1978
+ const mediaType = getMediaType({
1721
1979
  content: param.content,
1722
1980
  contentType,
1723
1981
  refs
1724
- })?.schema;
1982
+ });
1983
+ const rawSchema = param.schema ?? mediaType?.schema;
1725
1984
  const schema = rawSchema ? parseSchema({
1726
1985
  schema: rawSchema,
1727
1986
  name: schemaName
@@ -1737,7 +1996,10 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
1737
1996
  },
1738
1997
  required: param.required ?? false,
1739
1998
  ...pickStyleFields(param),
1740
- ...contentType !== void 0 ? { contentType } : {}
1999
+ ...contentType !== void 0 ? { contentType } : {},
2000
+ ...getExamples(mediaType ?? param, refs),
2001
+ ...param.deprecated && { deprecated: true },
2002
+ ...param.allowEmptyValue && { allowEmptyValue: true }
1741
2003
  });
1742
2004
  }
1743
2005
  /**
@@ -1782,12 +2044,12 @@ function parseOperation({ operation, ...ctx }) {
1782
2044
  name: requestBodyName
1783
2045
  }), bodyRequired);
1784
2046
  scanSchema(node, `${mediaTypePointer(body?.content, ct, `${pointer}/requestBody/content/${escapePointerToken(ct)}`)}/${schemaKeyword(mediaType)}`);
1785
- const encoding = getEncoding(mediaType?.encoding);
1786
2047
  return [ast.factory.createContent({
1787
2048
  contentType: ct,
1788
2049
  schema: node,
1789
2050
  keysToOmit: collectPropertyKeysByFlag(schema, "readOnly"),
1790
- ...encoding && { encoding },
2051
+ ...mediaType && getEncodingFields(mediaType),
2052
+ ...mediaType && getExamples(mediaType, refs),
1791
2053
  ...getStreamField({
1792
2054
  contentType: ct,
1793
2055
  mediaType,
@@ -1803,12 +2065,13 @@ function parseOperation({ operation, ...ctx }) {
1803
2065
  required: bodyRequired || void 0,
1804
2066
  content: content.length > 0 ? content : void 0
1805
2067
  } : void 0;
1806
- const responses = getResponseStatusCodes(operation).map((statusCode) => {
2068
+ const responses = getResponseStatusCodes(operation).map((key) => {
1807
2069
  const response = getResponseByStatusCode({
1808
2070
  operation,
1809
2071
  refs,
1810
- statusCode
2072
+ statusCode: key
1811
2073
  });
2074
+ const statusCode = key.toLowerCase();
1812
2075
  const responseName = operationName ? `${operationName}Status${statusCode}` : void 0;
1813
2076
  const parseEntrySchema = (ct) => {
1814
2077
  const raw = getBodySchema({
@@ -1826,10 +2089,12 @@ function parseOperation({ operation, ...ctx }) {
1826
2089
  schema: raw,
1827
2090
  name: responseName
1828
2091
  }) : ast.factory.createSchema({ type: options.emptySchemaType });
1829
- if (raw && ct) scanSchema(node, `${mediaTypePointer(response?.content, ct, `${pointer}/responses/${statusCode}/content/${escapePointerToken(ct)}`)}/${schemaKeyword(mediaType)}`);
2092
+ if (raw && ct) scanSchema(node, `${mediaTypePointer(response?.content, ct, `${pointer}/responses/${key}/content/${escapePointerToken(ct)}`)}/${schemaKeyword(mediaType)}`);
1830
2093
  return {
1831
2094
  schema: node,
1832
2095
  keysToOmit: collectPropertyKeysByFlag(raw, "writeOnly"),
2096
+ ...mediaType && getEncodingFields(mediaType),
2097
+ ...mediaType && getExamples(mediaType, refs),
1833
2098
  ...ct ? getStreamField({
1834
2099
  contentType: ct,
1835
2100
  mediaType,
@@ -1848,11 +2113,32 @@ function parseOperation({ operation, ...ctx }) {
1848
2113
  contentType: "",
1849
2114
  ...parseEntrySchema(contentType)
1850
2115
  }));
2116
+ const responsePointer = `${pointer}/responses/${key}`;
2117
+ const headers = Object.entries(response?.headers ?? {}).flatMap(([name, value]) => {
2118
+ const header = name.toLowerCase() === "content-type" ? null : refs.deref(value);
2119
+ if (!header) return [];
2120
+ return [parseParameter({
2121
+ param: {
2122
+ ...header,
2123
+ name,
2124
+ in: "header"
2125
+ },
2126
+ pointer: `${responsePointer}/headers/${escapePointerToken(name)}`,
2127
+ parentName: responseName,
2128
+ options,
2129
+ parseSchema,
2130
+ refs
2131
+ })];
2132
+ });
2133
+ const links = getLinks(response?.links, refs);
1851
2134
  return ast.factory.createResponse({
1852
- pointer: `${pointer}/responses/${statusCode}`,
2135
+ pointer: responsePointer,
1853
2136
  statusCode,
2137
+ summary: response?.summary,
1854
2138
  description: response?.description,
1855
- content: responseContent
2139
+ content: responseContent,
2140
+ ...headers.length && { headers },
2141
+ ...links && { links }
1856
2142
  });
1857
2143
  });
1858
2144
  const pickDoc = (key) => {
@@ -1861,7 +2147,8 @@ function parseOperation({ operation, ...ctx }) {
1861
2147
  const fallback = operation.pathItem[key];
1862
2148
  return typeof fallback === "string" ? fallback : void 0;
1863
2149
  };
1864
- const servers = operation.schema.servers ?? operation.pathItem.servers;
2150
+ const servers = operation.schema.servers?.length ? operation.schema.servers : operation.pathItem.servers;
2151
+ const auth = toAuthRequirements(operation.schema.security ?? document.security, document);
1865
2152
  return ast.factory.createOperation({
1866
2153
  pointer,
1867
2154
  operationId,
@@ -1872,11 +2159,13 @@ function parseOperation({ operation, ...ctx }) {
1872
2159
  summary: pickDoc("summary") || void 0,
1873
2160
  description: pickDoc("description") || void 0,
1874
2161
  deprecated: operation.schema.deprecated || void 0,
2162
+ externalDocs: getExternalDocs(operation.schema.externalDocs),
1875
2163
  parameters,
1876
2164
  requestBody,
1877
2165
  responses,
1878
2166
  extensions: pickExtensions(operation.schema),
1879
- ...servers && { servers: toInputServers(servers) }
2167
+ ...servers && { servers: toInputServers(servers) },
2168
+ ...auth && { auth }
1880
2169
  });
1881
2170
  }
1882
2171
  // src/emit/createNode.ts
@@ -1897,6 +2186,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
1897
2186
  default: defaultValue,
1898
2187
  examples: extractExamples(schema),
1899
2188
  format: schema.format,
2189
+ externalDocs: getExternalDocs(schema.externalDocs),
1900
2190
  ...extras
1901
2191
  });
1902
2192
  }
@@ -2361,13 +2651,15 @@ const annotationKeys = /* @__PURE__ */ new Set([
2361
2651
  ]);
2362
2652
  /**
2363
2653
  * Moves `allOf` members that hold only annotations or `if`/`then`/`else` onto the parent, so they do
2364
- * not become `unknown`. The parent's own values win, and the conditional keywords are not enforced.
2654
+ * not become `unknown`. The parent's own values win. The parser reads their `if`/`then`/`else` into `conditionals`.
2365
2655
  */
2656
+ function isAnnotationMember(member) {
2657
+ return !!member && typeof member === "object" && !isReference(member) && Object.keys(member).every((key) => annotationKeys.has(key));
2658
+ }
2366
2659
  function mergeAnnotations(schema) {
2367
2660
  const members = schema.allOf;
2368
- const isAnnotation = (member) => !isReference(member) && Object.keys(member).every((key) => annotationKeys.has(key));
2369
- const annotations = members.filter(isAnnotation);
2370
- const rest = members.filter((member) => !isAnnotation(member));
2661
+ const annotations = members.filter(isAnnotationMember);
2662
+ const rest = members.filter((member) => !isAnnotationMember(member));
2371
2663
  return annotations.length && rest.length ? {
2372
2664
  ...Object.assign({}, ...annotations),
2373
2665
  ...schema,
@@ -2400,7 +2692,8 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
2400
2692
  default: mergedDefault,
2401
2693
  examples: extractExamples(schema) ?? memberNode.examples,
2402
2694
  pattern: schema.pattern ?? ("pattern" in memberNode ? memberNode.pattern : void 0),
2403
- format: schema.format ?? memberNode.format
2695
+ format: schema.format ?? memberNode.format,
2696
+ externalDocs: getExternalDocs(schema.externalDocs) ?? memberNode.externalDocs
2404
2697
  });
2405
2698
  }
2406
2699
  const { members: discriminatedAllOf, discriminantValues } = extractDiscriminatedAllOfMembers({
@@ -2475,7 +2768,7 @@ function convertUnion(context) {
2475
2768
  };
2476
2769
  const discriminator = isDiscriminator(schema) ? schema.discriminator : void 0;
2477
2770
  const declaredMembers = [...schema.oneOf ?? [], ...schema.anyOf ?? []];
2478
- const defaultRef = getDefaultMappingRef(discriminator);
2771
+ const defaultRef = getDefaultMappingRef(typeof schema.discriminator === "object" ? schema.discriminator : void 0);
2479
2772
  const unionMembers = resolveUnionMembers(defaultRef && !declaredMembers.some((member) => isReference(member) && member.$ref === defaultRef) ? [...declaredMembers, { $ref: defaultRef }] : declaredMembers, schema.properties ?? {});
2480
2773
  const strategy = schema.oneOf ? "one" : "any";
2481
2774
  const explicitDiscriminatorPropertyName = discriminator?.propertyName;
@@ -2587,11 +2880,18 @@ function getPrimitiveType(type) {
2587
2880
  }
2588
2881
  /** Shared by number, integer and bigint nodes; the exclusive bounds keep only the OAS 3.1 numeric form. */
2589
2882
  function getNumericConstraints(schema) {
2883
+ const exclusiveMinimum = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : void 0;
2884
+ const exclusiveMaximum = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : void 0;
2885
+ const hasExclusive = exclusiveMinimum !== void 0 || exclusiveMaximum !== void 0;
2590
2886
  return {
2591
2887
  min: schema.minimum,
2592
2888
  max: schema.maximum,
2593
- exclusiveMinimum: typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : void 0,
2594
- exclusiveMaximum: typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : void 0,
2889
+ ...hasExclusive && { exclusive: {
2890
+ ...exclusiveMinimum !== void 0 && { min: exclusiveMinimum },
2891
+ ...exclusiveMaximum !== void 0 && { max: exclusiveMaximum }
2892
+ } },
2893
+ exclusiveMinimum,
2894
+ exclusiveMaximum,
2595
2895
  multipleOf: schema.multipleOf
2596
2896
  };
2597
2897
  }
@@ -2600,11 +2900,11 @@ function getNumericConstraints(schema) {
2600
2900
  */
2601
2901
  function isWithinBounds({ value, schema }) {
2602
2902
  if (typeof value !== "number") return true;
2603
- const { min, max, exclusiveMinimum, exclusiveMaximum, multipleOf } = getNumericConstraints(schema);
2903
+ const { min, max, exclusive, multipleOf } = getNumericConstraints(schema);
2604
2904
  if (min !== void 0 && value < min) return false;
2605
2905
  if (max !== void 0 && value > max) return false;
2606
- if (exclusiveMinimum !== void 0 && value <= exclusiveMinimum) return false;
2607
- if (exclusiveMaximum !== void 0 && value >= exclusiveMaximum) return false;
2906
+ if (exclusive?.min !== void 0 && value <= exclusive.min) return false;
2907
+ if (exclusive?.max !== void 0 && value >= exclusive.max) return false;
2608
2908
  if (multipleOf !== void 0 && Math.abs(value / multipleOf - Math.round(value / multipleOf)) > 1e-9) return false;
2609
2909
  return true;
2610
2910
  }
@@ -2762,6 +3062,15 @@ function convertFormattedEnum(context) {
2762
3062
  }))
2763
3063
  });
2764
3064
  }
3065
+ function getStringContent({ schema, parse }) {
3066
+ const { contentMediaType: mediaType, contentEncoding: encoding, contentSchema } = schema;
3067
+ if (mediaType === void 0 && encoding === void 0 && !contentSchema) return {};
3068
+ return { content: {
3069
+ ...mediaType !== void 0 && { mediaType },
3070
+ ...encoding !== void 0 && { encoding },
3071
+ ...contentSchema && { schema: parse({ schema: contentSchema }) }
3072
+ } };
3073
+ }
2765
3074
  /**
2766
3075
  * Converts a `type: 'string'` schema into a `StringSchemaNode`.
2767
3076
  */
@@ -2772,7 +3081,8 @@ function convertString(context) {
2772
3081
  primitive: "string",
2773
3082
  min: schema.minLength,
2774
3083
  max: schema.maxLength,
2775
- pattern: schema.pattern
3084
+ pattern: schema.pattern,
3085
+ ...getStringContent(context)
2776
3086
  });
2777
3087
  }
2778
3088
  /**
@@ -2786,6 +3096,15 @@ function convertNumeric(context, type) {
2786
3096
  });
2787
3097
  }
2788
3098
  // src/emit/converters/structural.ts
3099
+ function getContains(schema, parse) {
3100
+ const { contains, minContains, maxContains } = schema;
3101
+ if (!contains || typeof contains !== "object") return {};
3102
+ return { contains: {
3103
+ schema: parse({ schema: contains }),
3104
+ ...typeof minContains === "number" && { min: minContains },
3105
+ ...typeof maxContains === "number" && { max: maxContains }
3106
+ } };
3107
+ }
2789
3108
  /**
2790
3109
  * Resolves a `true` or empty-object map schema (`additionalProperties`/`patternProperties`) to
2791
3110
  * `options.unknownType`, otherwise parses it as a regular schema.
@@ -2838,7 +3157,7 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
2838
3157
  required
2839
3158
  });
2840
3159
  }) : [];
2841
- const additionalProperties = schema.additionalProperties;
3160
+ const additionalProperties = schema.additionalProperties ?? schema.unevaluatedProperties;
2842
3161
  const additionalPropertiesNode = (() => {
2843
3162
  if (additionalProperties === true) return true;
2844
3163
  if (additionalProperties) return resolveMapSchema(additionalProperties, {
@@ -2868,6 +3187,8 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
2868
3187
  additionalProperties: additionalPropertiesNode,
2869
3188
  patternProperties,
2870
3189
  propertyNames,
3190
+ min: schema.minProperties,
3191
+ max: schema.maxProperties,
2871
3192
  minProperties: schema.minProperties,
2872
3193
  maxProperties: schema.maxProperties
2873
3194
  });
@@ -2898,7 +3219,8 @@ function convertObject({ schema, name, nullable, defaultValue, options, parse, r
2898
3219
  */
2899
3220
  function convertTuple({ schema, name, nullable, defaultValue, options, parse }) {
2900
3221
  const tupleItems = (schema.prefixItems ?? []).map((item) => parse({ schema: item }));
2901
- const rest = schema.items === false ? void 0 : !schema.items || schema.items === true ? ast.factory.createSchema({ type: options.unknownType }) : parse({ schema: schema.items });
3222
+ const tail = schema.items ?? schema.unevaluatedItems;
3223
+ const rest = tail === false ? void 0 : !tail || tail === true ? ast.factory.createSchema({ type: options.unknownType }) : parse({ schema: tail });
2902
3224
  return createNode({
2903
3225
  schema,
2904
3226
  name,
@@ -2910,7 +3232,8 @@ function convertTuple({ schema, name, nullable, defaultValue, options, parse })
2910
3232
  items: tupleItems,
2911
3233
  rest,
2912
3234
  min: schema.minItems,
2913
- max: schema.maxItems
3235
+ max: schema.maxItems,
3236
+ ...getContains(schema, parse)
2914
3237
  });
2915
3238
  }
2916
3239
  /**
@@ -2934,7 +3257,8 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
2934
3257
  items,
2935
3258
  min: schema.minItems,
2936
3259
  max: schema.maxItems,
2937
- unique: schema.uniqueItems ?? void 0
3260
+ unique: schema.uniqueItems ?? void 0,
3261
+ ...getContains(schema, parse)
2938
3262
  });
2939
3263
  }
2940
3264
  // src/emit/parseSchema.ts
@@ -3062,6 +3386,20 @@ const schemaRules = [
3062
3386
  ];
3063
3387
  // src/parser.ts
3064
3388
  /**
3389
+ * `unevaluated*` also sees what composition siblings evaluate, so with such a sibling it is dropped to keep the schema open.
3390
+ */
3391
+ function hasUnevaluatedSiblings(schema) {
3392
+ if (schema.unevaluatedProperties === void 0 && schema.unevaluatedItems === void 0) return false;
3393
+ return [
3394
+ schema.allOf,
3395
+ schema.anyOf,
3396
+ schema.oneOf,
3397
+ schema.if,
3398
+ schema.dependentSchemas,
3399
+ schema.$ref
3400
+ ].some((value) => value !== void 0);
3401
+ }
3402
+ /**
3065
3403
  * Creates the schema converter bound to one OpenAPI document: `parseSchema` dispatches each
3066
3404
  * schema through the ordered `schemaRules` table, with the parser options merged once.
3067
3405
  *
@@ -3075,10 +3413,20 @@ function createSchemaParser(ctx) {
3075
3413
  };
3076
3414
  function parseSchema({ schema, name }) {
3077
3415
  const flattenedSchema = flattenSchema(schema);
3078
- if (flattenedSchema !== schema) return parseSchema({
3079
- schema: flattenedSchema,
3080
- name
3081
- });
3416
+ if (flattenedSchema !== schema) {
3417
+ const { if: _if, then: _then, else: _else, dependentRequired: _required, dependentSchemas: _schemas, ...shape } = flattenedSchema;
3418
+ return withConditionals(parseSchema({
3419
+ schema: shape,
3420
+ name
3421
+ }), [schema, ...schema.allOf]);
3422
+ }
3423
+ if (hasUnevaluatedSiblings(schema)) {
3424
+ const { unevaluatedProperties: _properties, unevaluatedItems: _items, ...open } = schema;
3425
+ return parseSchema({
3426
+ schema: open,
3427
+ name
3428
+ });
3429
+ }
3082
3430
  const nullable = isNullable(schema) || void 0;
3083
3431
  const context = {
3084
3432
  schema,
@@ -3092,8 +3440,81 @@ function createSchemaParser(ctx) {
3092
3440
  refs,
3093
3441
  renames
3094
3442
  };
3095
- for (const rule of schemaRules) if (rule.match(context)) return rule.convert(context);
3096
- return createNode(context, { type: options.emptySchemaType });
3443
+ const rule = schemaRules.find((entry) => entry.match(context));
3444
+ return withConditionals(rule ? rule.convert(context) : createNode(context, { type: options.emptySchemaType }), [schema, ...Array.isArray(schema.allOf) ? schema.allOf.filter(isAnnotationMember) : []]);
3445
+ }
3446
+ const presenceKeys = /* @__PURE__ */ new WeakMap();
3447
+ function requireKeys(keys) {
3448
+ const unknown = ast.factory.createSchema({ type: ast.schemaTypes.unknown });
3449
+ const node = ast.factory.createSchema({
3450
+ type: ast.schemaTypes.object,
3451
+ primitive: "object",
3452
+ properties: keys.map((name) => ast.factory.createProperty({
3453
+ name,
3454
+ required: true,
3455
+ schema: unknown
3456
+ }))
3457
+ });
3458
+ presenceKeys.set(node, keys.join("\0"));
3459
+ return node;
3460
+ }
3461
+ /**
3462
+ * Adds `if`/`then`/`else`, `dependentRequired` and `dependentSchemas` to the node as `conditionals`.
3463
+ */
3464
+ function withConditionals(node, sources) {
3465
+ const conditionals = sources.flatMap(toConditionals);
3466
+ const existing = new Set((node.conditionals ?? []).map(presenceKey));
3467
+ const added = conditionals.filter((entry) => {
3468
+ const key = presenceKey(entry);
3469
+ return key === void 0 || !existing.has(key);
3470
+ });
3471
+ return added.length ? {
3472
+ ...node,
3473
+ conditionals: [...node.conditionals ?? [], ...added]
3474
+ } : node;
3475
+ }
3476
+ /**
3477
+ * The keys an entry checks for presence, or `undefined` when a branch checks more than presence and the entry is always kept.
3478
+ */
3479
+ function presenceKey({ if: condition, then: thenNode, else: elseNode }) {
3480
+ const keys = [
3481
+ condition,
3482
+ thenNode,
3483
+ elseNode
3484
+ ].map((branch) => branch ? presenceKeys.get(branch) : "");
3485
+ return keys.includes(void 0) ? void 0 : keys.join("\n");
3486
+ }
3487
+ function toConditionals(schema) {
3488
+ const branch = (value) => {
3489
+ if (!value || typeof value !== "object") return void 0;
3490
+ const { required, type, ...rest } = value;
3491
+ if (Array.isArray(required) && required.length && (type === void 0 || type === "object") && !Object.keys(rest).length) return requireKeys(required);
3492
+ return parseSchema({ schema: value });
3493
+ };
3494
+ const entries = (value) => value && typeof value === "object" ? Object.entries(value) : [];
3495
+ const conditionals = [];
3496
+ const condition = branch(schema.if);
3497
+ if (condition) {
3498
+ const thenNode = branch(schema.then);
3499
+ const elseNode = branch(schema.else);
3500
+ conditionals.push({
3501
+ if: condition,
3502
+ ...thenNode && { then: thenNode },
3503
+ ...elseNode && { else: elseNode }
3504
+ });
3505
+ }
3506
+ for (const [key, required] of entries(schema.dependentRequired)) if (Array.isArray(required) && required.length && required.every((name) => typeof name === "string")) conditionals.push({
3507
+ if: requireKeys([key]),
3508
+ then: requireKeys(required)
3509
+ });
3510
+ for (const [key, dependent] of entries(schema.dependentSchemas)) {
3511
+ const thenNode = branch(dependent);
3512
+ if (thenNode) conditionals.push({
3513
+ if: requireKeys([key]),
3514
+ then: thenNode
3515
+ });
3516
+ }
3517
+ return conditionals;
3097
3518
  }
3098
3519
  return parseSchema;
3099
3520
  }
@@ -3433,6 +3854,7 @@ const adapterOas = defineExtension({
3433
3854
  schemaNodes.push(promotedEnums ? refPromotedEnums(node, promotedEnums) : node);
3434
3855
  }
3435
3856
  const operations = promotedEnums ? operationNodes.map((node) => refPromotedEnums(node, promotedEnums)) : operationNodes;
3857
+ const authSchemes = toAuthSchemes(document.components?.securitySchemes, refs);
3436
3858
  return ast.factory.createInput({
3437
3859
  schemas: schemaNodes,
3438
3860
  operations,
@@ -3440,23 +3862,25 @@ const adapterOas = defineExtension({
3440
3862
  title: document.info?.title,
3441
3863
  description: document.info?.description,
3442
3864
  version: document.info?.version,
3865
+ summary: document.info?.summary,
3866
+ termsOfService: document.info?.termsOfService,
3867
+ contact: pickStrings(document.info?.contact, [
3868
+ "name",
3869
+ "url",
3870
+ "email"
3871
+ ]),
3872
+ license: typeof document.info?.license?.name === "string" ? {
3873
+ ...pickStrings(document.info.license, ["identifier", "url"]),
3874
+ name: document.info.license.name
3875
+ } : void 0,
3876
+ externalDocs: getExternalDocs(document.externalDocs),
3443
3877
  baseURL: resolveBaseUrl({
3444
3878
  document,
3445
3879
  server
3446
3880
  }),
3447
3881
  servers: toInputServers(document.servers ?? []),
3448
- securitySchemes: Object.entries(document.components?.securitySchemes ?? {}).flatMap(([name, value]) => {
3449
- const scheme = refs.deref(value);
3450
- return scheme?.type ? [{
3451
- name,
3452
- type: scheme.type,
3453
- description: scheme.description,
3454
- scheme: scheme.scheme,
3455
- bearerFormat: scheme.bearerFormat,
3456
- in: scheme.in,
3457
- parameterName: scheme.name
3458
- }] : [];
3459
- }),
3882
+ ...document.tags?.length && { tags: toInputTags(document.tags) },
3883
+ ...authSchemes.length && { auth: authSchemes },
3460
3884
  extensions: pickExtensions(document)
3461
3885
  }
3462
3886
  });