@kubb/adapter-oas 5.14.6 → 5.15.0

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.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { AdapterFactoryOptions, ast } from "@kubb/kit";
2
- //#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
3
2
  // ==================================================================================================
4
3
  // JSON Schema Draft 04
5
4
  // ==================================================================================================
@@ -596,8 +595,6 @@ interface JSONSchema7 {
596
595
  writeOnly?: boolean | undefined;
597
596
  examples?: JSONSchema7Type | undefined;
598
597
  }
599
- //#endregion
600
- //#region ../../node_modules/.pnpm/openapi-types@12.1.3/node_modules/openapi-types/dist/index.d.ts
601
598
  declare namespace OpenAPIV3_1 {
602
599
  type Modify<T, R> = Omit<T, keyof R> & R;
603
600
  type PathsWebhooksComponents<T extends {} = {}> = {
@@ -1053,8 +1050,6 @@ declare namespace OpenAPIV3 {
1053
1050
  externalDocs?: ExternalDocumentationObject;
1054
1051
  }
1055
1052
  }
1056
- //#endregion
1057
- //#region src/types.d.ts
1058
1053
  /**
1059
1054
  * Media type used to pick a schema from an operation's request or response.
1060
1055
  *
@@ -1254,8 +1249,6 @@ type AdapterOasResolvedOptions = {
1254
1249
  * `@kubb/core` adapter factory type for the OpenAPI adapter.
1255
1250
  */
1256
1251
  type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>;
1257
- //#endregion
1258
- //#region src/adapter.d.ts
1259
1252
  /**
1260
1253
  * The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
1261
1254
  */
@@ -1288,8 +1281,6 @@ export declare const adapterOasName = "oas";
1288
1281
  * ```
1289
1282
  */
1290
1283
  export declare const adapterOas: import("@kubb/core").AdapterFactory<AdapterOas>;
1291
- //#endregion
1292
- //#region src/operation.d.ts
1293
1284
  /**
1294
1285
  * A single OpenAPI operation: its path, method, raw operation object and resolved path item.
1295
1286
  */
@@ -1299,6 +1290,5 @@ type Operation = {
1299
1290
  schema: OperationObject$1;
1300
1291
  pathItem: PathItemObject$1;
1301
1292
  };
1302
- //#endregion
1303
1293
  export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
1304
1294
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { AdapterFactoryOptions, ast } from "@kubb/kit";
2
- //#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
3
2
  // ==================================================================================================
4
3
  // JSON Schema Draft 04
5
4
  // ==================================================================================================
@@ -596,8 +595,6 @@ interface JSONSchema7 {
596
595
  writeOnly?: boolean | undefined;
597
596
  examples?: JSONSchema7Type | undefined;
598
597
  }
599
- //#endregion
600
- //#region ../../node_modules/.pnpm/openapi-types@12.1.3/node_modules/openapi-types/dist/index.d.ts
601
598
  declare namespace OpenAPIV3_1 {
602
599
  type Modify<T, R> = Omit<T, keyof R> & R;
603
600
  type PathsWebhooksComponents<T extends {} = {}> = {
@@ -1053,8 +1050,6 @@ declare namespace OpenAPIV3 {
1053
1050
  externalDocs?: ExternalDocumentationObject;
1054
1051
  }
1055
1052
  }
1056
- //#endregion
1057
- //#region src/types.d.ts
1058
1053
  /**
1059
1054
  * Media type used to pick a schema from an operation's request or response.
1060
1055
  *
@@ -1254,8 +1249,6 @@ type AdapterOasResolvedOptions = {
1254
1249
  * `@kubb/core` adapter factory type for the OpenAPI adapter.
1255
1250
  */
1256
1251
  type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>;
1257
- //#endregion
1258
- //#region src/adapter.d.ts
1259
1252
  /**
1260
1253
  * The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
1261
1254
  */
@@ -1288,8 +1281,6 @@ export declare const adapterOasName = "oas";
1288
1281
  * ```
1289
1282
  */
1290
1283
  export declare const adapterOas: import("@kubb/core").AdapterFactory<AdapterOas>;
1291
- //#endregion
1292
- //#region src/operation.d.ts
1293
1284
  /**
1294
1285
  * A single OpenAPI operation: its path, method, raw operation object and resolved path item.
1295
1286
  */
@@ -1299,6 +1290,5 @@ type Operation = {
1299
1290
  schema: OperationObject$1;
1300
1291
  pathItem: PathItemObject$1;
1301
1292
  };
1302
- //#endregion
1303
1293
  export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
1304
1294
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -7,23 +7,20 @@ import { bundle } from "api-ref-bundler";
7
7
  import { CORE_SCHEMA, load } from "js-yaml";
8
8
  import * as yaml from "yaml";
9
9
  import { parse } from "yaml";
10
- //#region \0rolldown/runtime.js
10
+ // \0rolldown/runtime.js
11
11
  var __defProp = Object.defineProperty;
12
12
  var __name = (target, value) => __defProp(target, "name", {
13
13
  value,
14
14
  configurable: true
15
15
  });
16
- //#endregion
17
- //#region kubb-extension.json
16
+ // kubb-extension.json
18
17
  var compatibility = {
19
18
  "kubb": ">=5.8.3",
20
19
  "node": ">=22.22"
21
20
  };
22
- //#endregion
23
- //#region package.json
24
- var version = "5.14.6";
25
- //#endregion
26
- //#region src/constants.ts
21
+ // package.json
22
+ var version = "5.15.0";
23
+ // src/constants.ts
27
24
  /**
28
25
  * Default parser options applied when no explicit options are provided.
29
26
  */
@@ -147,8 +144,7 @@ const enumExtensionKeys = ["x-enumNames", "x-enum-varnames"];
147
144
  * Vendor extension keys that attach human-readable descriptions to enum values, checked in priority order.
148
145
  */
149
146
  const enumDescriptionKeys = ["x-enumDescriptions", "x-enum-descriptions"];
150
- //#endregion
151
- //#region src/emit/discriminator/propagate.ts
147
+ // src/emit/discriminator/propagate.ts
152
148
  /**
153
149
  * Maps each child schema name to its discriminator patch data by scanning the given
154
150
  * top-level AST schema nodes for union schemas that carry a `discriminatorPropertyName`.
@@ -231,8 +227,7 @@ function patchDiscriminatorNode(node, entry) {
231
227
  members: newMembers
232
228
  };
233
229
  }
234
- //#endregion
235
- //#region ../../internals/utils/src/casing.ts
230
+ // ../../internals/utils/src/casing.ts
236
231
  /**
237
232
  * Shared implementation for camelCase and PascalCase conversion.
238
233
  * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
@@ -247,7 +242,7 @@ function convert(text, pascal) {
247
242
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
248
243
  }
249
244
  const cache = /* @__PURE__ */ new Map();
250
- const cacheLimit = 1e4;
245
+ const cacheLimit = 1e5;
251
246
  function toCamelOrPascal(text, pascal) {
252
247
  const key = `${pascal ? "P" : "c"}${text}`;
253
248
  const cached = cache.get(key);
@@ -269,8 +264,7 @@ function toCamelOrPascal(text, pascal) {
269
264
  function pascalCase(text, { prefix = "", suffix = "" } = {}) {
270
265
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
271
266
  }
272
- //#endregion
273
- //#region ../../internals/utils/src/errors.ts
267
+ // ../../internals/utils/src/errors.ts
274
268
  /**
275
269
  * Coerces an unknown thrown value to an `Error` instance.
276
270
  * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
@@ -297,8 +291,7 @@ function toError(value) {
297
291
  function getErrorMessage(value) {
298
292
  return value instanceof Error ? value.message : String(value);
299
293
  }
300
- //#endregion
301
- //#region ../../internals/utils/src/jsonPointer.ts
294
+ // ../../internals/utils/src/jsonPointer.ts
302
295
  /**
303
296
  * Escapes a single JSON pointer reference token per RFC 6901 (`~` → `~0`, `/` → `~1`), so a
304
297
  * name holding those characters maps to a distinct pointer.
@@ -311,8 +304,7 @@ function getErrorMessage(value) {
311
304
  function escapePointerToken(token) {
312
305
  return token.replaceAll("~", "~0").replaceAll("/", "~1");
313
306
  }
314
- //#endregion
315
- //#region ../../internals/utils/src/runtime.ts
307
+ // ../../internals/utils/src/runtime.ts
316
308
  const isBun = typeof Bun !== "undefined";
317
309
  const isDeno = "Deno" in globalThis;
318
310
  /**
@@ -341,8 +333,7 @@ function detect() {
341
333
  version: process.versions?.node ?? ""
342
334
  };
343
335
  }
344
- //#endregion
345
- //#region ../../internals/utils/src/fs.ts
336
+ // ../../internals/utils/src/fs.ts
346
337
  /**
347
338
  * Resolves to `true` when the file or directory at `path` exists.
348
339
  * Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.
@@ -371,8 +362,7 @@ async function read(path) {
371
362
  if (runtime.isBun) return Bun.file(path).text();
372
363
  return readFile(path, { encoding: "utf8" });
373
364
  }
374
- //#endregion
375
- //#region src/oas.ts
365
+ // src/oas.ts
376
366
  /**
377
367
  * Returns `true` when a schema should be treated as nullable.
378
368
  *
@@ -455,8 +445,7 @@ const jsonMimeFragments = [
455
445
  function isJsonMimeType(mimeType) {
456
446
  return jsonMimeFragments.some((fragment) => mimeType.includes(fragment));
457
447
  }
458
- //#endregion
459
- //#region src/refs.ts
448
+ // src/refs.ts
460
449
  /**
461
450
  * Creates the `$ref` resolution service for one document. One pointer walk backs every method.
462
451
  *
@@ -563,8 +552,7 @@ function createRefs(document) {
563
552
  derefKeepingRef
564
553
  };
565
554
  }
566
- //#endregion
567
- //#region src/load/source.ts
555
+ // src/load/source.ts
568
556
  const urlRegExp = /^https?:\/+/i;
569
557
  /**
570
558
  * Node reports every connection failure as `TypeError: fetch failed` and keeps the useful part
@@ -668,8 +656,7 @@ async function assertInputExists(input) {
668
656
  location: { kind: "config" }
669
657
  });
670
658
  }
671
- //#endregion
672
- //#region src/load/normalize.ts
659
+ // src/load/normalize.ts
673
660
  /**
674
661
  * True when `node` contains a `$ref` pointing outside the current document (a relative path,
675
662
  * absolute path, or URL). An internal `#/...` fragment does not count.
@@ -915,8 +902,7 @@ async function validateDocumentInWorker(document) {
915
902
  if ("thrown" in message) return reportInvalidSpec(message.thrown);
916
903
  if (!message.valid) reportValidationErrors(message);
917
904
  }
918
- //#endregion
919
- //#region src/model/components.ts
905
+ // src/model/components.ts
920
906
  /**
921
907
  * Extracts the inline schema from a media-type `content` map, with the media type it sits under.
922
908
  *
@@ -1118,8 +1104,7 @@ function getSchemas(document, { contentType }, refs) {
1118
1104
  pointers
1119
1105
  };
1120
1106
  }
1121
- //#endregion
1122
- //#region src/model/server.ts
1107
+ // src/model/server.ts
1123
1108
  /**
1124
1109
  * Reads the server URL from the document's `servers` array at `server.index`,
1125
1110
  * interpolating any `server.variables` into the URL template.
@@ -1171,8 +1156,7 @@ function resolveServerUrl(server, overrides) {
1171
1156
  }
1172
1157
  return url;
1173
1158
  }
1174
- //#endregion
1175
- //#region src/emit/schemaShape.ts
1159
+ // src/emit/schemaShape.ts
1176
1160
  /**
1177
1161
  * Whether `format` maps to a dedicated type; `false` is what `KUBB_UNSUPPORTED_FORMAT` flags.
1178
1162
  */
@@ -1225,8 +1209,7 @@ function flattenSchema(schema) {
1225
1209
  for (const fragment of allOfFragments) for (const [key, value] of Object.entries(fragment)) merged[key] ??= value;
1226
1210
  return merged;
1227
1211
  }
1228
- //#endregion
1229
- //#region src/schemaDiagnostics.ts
1212
+ // src/schemaDiagnostics.ts
1230
1213
  /**
1231
1214
  * Links one freshly converted schema and its nested schemas to their RFC 6901 pointers
1232
1215
  * (`#/components/schemas/Pet/properties/owner/properties/name`), and reports the advisory
@@ -1280,8 +1263,7 @@ function visit(node, pointer) {
1280
1263
  for (const [index, member] of (node.members ?? []).entries()) visit(member, `${pointer}/${keyword}/${index}`);
1281
1264
  }
1282
1265
  }
1283
- //#endregion
1284
- //#region src/operation.ts
1266
+ // src/operation.ts
1285
1267
  function slugify(value) {
1286
1268
  return value.replace(/[^a-zA-Z0-9]/g, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
1287
1269
  }
@@ -1550,8 +1532,7 @@ function parseOperation({ operation, ...ctx }) {
1550
1532
  extensions: pickExtensions(operation.schema)
1551
1533
  });
1552
1534
  }
1553
- //#endregion
1554
- //#region src/emit/createNode.ts
1535
+ // src/emit/createNode.ts
1555
1536
  /**
1556
1537
  * Builds a schema node from a converter's base context plus its type-specific fields. Every
1557
1538
  * converter needs the same metadata fields (`title`, `description`, `examples`, ...) alongside
@@ -1572,8 +1553,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
1572
1553
  ...extras
1573
1554
  });
1574
1555
  }
1575
- //#endregion
1576
- //#region src/emit/discriminator/preserve.ts
1556
+ // src/emit/discriminator/preserve.ts
1577
1557
  /**
1578
1558
  * Turns string mapping keys into the discriminator property's type when they parse cleanly.
1579
1559
  */
@@ -1809,8 +1789,7 @@ function extractDiscriminatedAllOfMembers({ allOfMembers, name, refs }) {
1809
1789
  discriminantValues
1810
1790
  };
1811
1791
  }
1812
- //#endregion
1813
- //#region src/emit/converters/annotatedEnum.ts
1792
+ // src/emit/converters/annotatedEnum.ts
1814
1793
  const ANNOTATIONS = /* @__PURE__ */ new Set([
1815
1794
  "title",
1816
1795
  "description",
@@ -1876,8 +1855,7 @@ function convertAnnotatedEnum(context) {
1876
1855
  namedEnumValues
1877
1856
  });
1878
1857
  }
1879
- //#endregion
1880
- //#region src/emit/converters/composition.ts
1858
+ // src/emit/converters/composition.ts
1881
1859
  /**
1882
1860
  * Collects property schemas from all `allOf` members and outer schema properties,
1883
1861
  * recursively resolving `$ref` pointers.
@@ -2213,8 +2191,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
2213
2191
  })
2214
2192
  });
2215
2193
  }
2216
- //#endregion
2217
- //#region src/emit/converters/scalar.ts
2194
+ // src/emit/converters/scalar.ts
2218
2195
  /**
2219
2196
  * Normalizes malformed `{ type: 'array', enum: [...] }` schemas by moving enum values into items.
2220
2197
  *
@@ -2390,8 +2367,7 @@ function convertNumeric(context, type) {
2390
2367
  ...getNumericConstraints(context.schema)
2391
2368
  });
2392
2369
  }
2393
- //#endregion
2394
- //#region src/emit/converters/structural.ts
2370
+ // src/emit/converters/structural.ts
2395
2371
  /**
2396
2372
  * Resolves a `true` or empty-object map schema (`additionalProperties`/`patternProperties`) to
2397
2373
  * `options.unknownType`, otherwise parses it as a regular schema.
@@ -2422,8 +2398,9 @@ function nameEnums(node, options) {
2422
2398
  * Converts an object-like schema into an `ObjectSchemaNode`.
2423
2399
  */
2424
2400
  function convertObject({ schema, name, nullable, defaultValue, options, parse, refs }) {
2401
+ const requiredNames = Array.isArray(schema.required) ? new Set(schema.required) : void 0;
2425
2402
  const properties = schema.properties ? Object.entries(schema.properties).map(([propName, propSchema]) => {
2426
- const required = Array.isArray(schema.required) ? schema.required.includes(propName) : !!schema.required;
2403
+ const required = requiredNames ? requiredNames.has(propName) : !!schema.required;
2427
2404
  const resolvedPropSchema = propSchema;
2428
2405
  const propNullable = isNullable(resolvedPropSchema);
2429
2406
  const schemaNode = nameEnums(parse({
@@ -2542,8 +2519,7 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
2542
2519
  unique: schema.uniqueItems ?? void 0
2543
2520
  });
2544
2521
  }
2545
- //#endregion
2546
- //#region src/emit/parseSchema.ts
2522
+ // src/emit/parseSchema.ts
2547
2523
  /**
2548
2524
  * Ordered schema rule table. Order is significant: composition keywords (`not`, `$ref`, `allOf`,
2549
2525
  * `oneOf`/`anyOf`) take precedence over `const` (except a `$ref` with a sibling `const`, where the
@@ -2644,8 +2620,7 @@ const schemaRules = [
2644
2620
  convert: ({ schema, name, nullable }) => createNullNode(schema, name, nullable)
2645
2621
  }
2646
2622
  ];
2647
- //#endregion
2648
- //#region src/parser.ts
2623
+ // src/parser.ts
2649
2624
  /**
2650
2625
  * Creates the schema converter bound to one OpenAPI document: `parseSchema` dispatches each
2651
2626
  * schema through the ordered `schemaRules` table, with the parser options merged once.
@@ -2682,8 +2657,7 @@ function createSchemaParser(ctx) {
2682
2657
  }
2683
2658
  return parseSchema;
2684
2659
  }
2685
- //#endregion
2686
- //#region src/promoteEnums.ts
2660
+ // src/promoteEnums.ts
2687
2661
  /**
2688
2662
  * Collects inline enums to lift to the top level, keyed by the name the parser derived for them
2689
2663
  * (e.g. `PetStatusEnum`). An enum already defined as a top-level component is left as-is, and a
@@ -2729,8 +2703,7 @@ function refPromotedEnums(node, promoted) {
2729
2703
  });
2730
2704
  } });
2731
2705
  }
2732
- //#endregion
2733
- //#region src/sourceLocator.ts
2706
+ // src/sourceLocator.ts
2734
2707
  let cached;
2735
2708
  const toRange = ([start, end]) => ({
2736
2709
  start,
@@ -2888,8 +2861,7 @@ const locate = (source, location) => {
2888
2861
  const { document } = cached;
2889
2862
  return findPointer(document, location.pointer) ?? (ref ? findRefUsage(document, ref) : void 0);
2890
2863
  };
2891
- //#endregion
2892
- //#region src/adapter.ts
2864
+ // src/adapter.ts
2893
2865
  /**
2894
2866
  * The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
2895
2867
  */
@@ -3134,7 +3106,6 @@ const adapterOas = defineExtension({
3134
3106
  };
3135
3107
  }
3136
3108
  });
3137
- //#endregion
3138
3109
  export { adapterOas, adapterOasName };
3139
3110
 
3140
3111
  //# sourceMappingURL=index.js.map