@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.cjs +34 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.js +34 -63
- package/dist/index.js.map +1 -1
- package/dist/validateWorker.js +1 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let _kubb_core = require("@kubb/core");
|
|
25
24
|
let _kubb_kit = require("@kubb/kit");
|
|
26
25
|
let node_path = require("node:path");
|
|
@@ -30,16 +29,14 @@ let api_ref_bundler = require("api-ref-bundler");
|
|
|
30
29
|
let js_yaml = require("js-yaml");
|
|
31
30
|
let yaml = require("yaml");
|
|
32
31
|
yaml = __toESM(yaml, 1);
|
|
33
|
-
|
|
32
|
+
// kubb-extension.json
|
|
34
33
|
var compatibility = {
|
|
35
34
|
"kubb": ">=5.8.3",
|
|
36
35
|
"node": ">=22.22"
|
|
37
36
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/constants.ts
|
|
37
|
+
// package.json
|
|
38
|
+
var version = "5.15.0";
|
|
39
|
+
// src/constants.ts
|
|
43
40
|
/**
|
|
44
41
|
* Default parser options applied when no explicit options are provided.
|
|
45
42
|
*/
|
|
@@ -163,8 +160,7 @@ const enumExtensionKeys = ["x-enumNames", "x-enum-varnames"];
|
|
|
163
160
|
* Vendor extension keys that attach human-readable descriptions to enum values, checked in priority order.
|
|
164
161
|
*/
|
|
165
162
|
const enumDescriptionKeys = ["x-enumDescriptions", "x-enum-descriptions"];
|
|
166
|
-
|
|
167
|
-
//#region src/emit/discriminator/propagate.ts
|
|
163
|
+
// src/emit/discriminator/propagate.ts
|
|
168
164
|
/**
|
|
169
165
|
* Maps each child schema name to its discriminator patch data by scanning the given
|
|
170
166
|
* top-level AST schema nodes for union schemas that carry a `discriminatorPropertyName`.
|
|
@@ -247,8 +243,7 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
247
243
|
members: newMembers
|
|
248
244
|
};
|
|
249
245
|
}
|
|
250
|
-
|
|
251
|
-
//#region ../../internals/utils/src/casing.ts
|
|
246
|
+
// ../../internals/utils/src/casing.ts
|
|
252
247
|
/**
|
|
253
248
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
254
249
|
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
@@ -263,7 +258,7 @@ function convert(text, pascal) {
|
|
|
263
258
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
264
259
|
}
|
|
265
260
|
const cache = /* @__PURE__ */ new Map();
|
|
266
|
-
const cacheLimit =
|
|
261
|
+
const cacheLimit = 1e5;
|
|
267
262
|
function toCamelOrPascal(text, pascal) {
|
|
268
263
|
const key = `${pascal ? "P" : "c"}${text}`;
|
|
269
264
|
const cached = cache.get(key);
|
|
@@ -285,8 +280,7 @@ function toCamelOrPascal(text, pascal) {
|
|
|
285
280
|
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
286
281
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
287
282
|
}
|
|
288
|
-
|
|
289
|
-
//#region ../../internals/utils/src/errors.ts
|
|
283
|
+
// ../../internals/utils/src/errors.ts
|
|
290
284
|
/**
|
|
291
285
|
* Coerces an unknown thrown value to an `Error` instance.
|
|
292
286
|
* Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
|
|
@@ -313,8 +307,7 @@ function toError(value) {
|
|
|
313
307
|
function getErrorMessage(value) {
|
|
314
308
|
return value instanceof Error ? value.message : String(value);
|
|
315
309
|
}
|
|
316
|
-
|
|
317
|
-
//#region ../../internals/utils/src/jsonPointer.ts
|
|
310
|
+
// ../../internals/utils/src/jsonPointer.ts
|
|
318
311
|
/**
|
|
319
312
|
* Escapes a single JSON pointer reference token per RFC 6901 (`~` → `~0`, `/` → `~1`), so a
|
|
320
313
|
* name holding those characters maps to a distinct pointer.
|
|
@@ -327,8 +320,7 @@ function getErrorMessage(value) {
|
|
|
327
320
|
function escapePointerToken(token) {
|
|
328
321
|
return token.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
329
322
|
}
|
|
330
|
-
|
|
331
|
-
//#region ../../internals/utils/src/runtime.ts
|
|
323
|
+
// ../../internals/utils/src/runtime.ts
|
|
332
324
|
const isBun = typeof Bun !== "undefined";
|
|
333
325
|
const isDeno = "Deno" in globalThis;
|
|
334
326
|
/**
|
|
@@ -357,8 +349,7 @@ function detect() {
|
|
|
357
349
|
version: process.versions?.node ?? ""
|
|
358
350
|
};
|
|
359
351
|
}
|
|
360
|
-
|
|
361
|
-
//#region ../../internals/utils/src/fs.ts
|
|
352
|
+
// ../../internals/utils/src/fs.ts
|
|
362
353
|
/**
|
|
363
354
|
* Resolves to `true` when the file or directory at `path` exists.
|
|
364
355
|
* Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.
|
|
@@ -387,8 +378,7 @@ async function read(path) {
|
|
|
387
378
|
if (runtime.isBun) return Bun.file(path).text();
|
|
388
379
|
return (0, node_fs_promises.readFile)(path, { encoding: "utf8" });
|
|
389
380
|
}
|
|
390
|
-
|
|
391
|
-
//#region src/oas.ts
|
|
381
|
+
// src/oas.ts
|
|
392
382
|
/**
|
|
393
383
|
* Returns `true` when a schema should be treated as nullable.
|
|
394
384
|
*
|
|
@@ -471,8 +461,7 @@ const jsonMimeFragments = [
|
|
|
471
461
|
function isJsonMimeType(mimeType) {
|
|
472
462
|
return jsonMimeFragments.some((fragment) => mimeType.includes(fragment));
|
|
473
463
|
}
|
|
474
|
-
|
|
475
|
-
//#region src/refs.ts
|
|
464
|
+
// src/refs.ts
|
|
476
465
|
/**
|
|
477
466
|
* Creates the `$ref` resolution service for one document. One pointer walk backs every method.
|
|
478
467
|
*
|
|
@@ -579,8 +568,7 @@ function createRefs(document) {
|
|
|
579
568
|
derefKeepingRef
|
|
580
569
|
};
|
|
581
570
|
}
|
|
582
|
-
|
|
583
|
-
//#region src/load/source.ts
|
|
571
|
+
// src/load/source.ts
|
|
584
572
|
const urlRegExp = /^https?:\/+/i;
|
|
585
573
|
/**
|
|
586
574
|
* Node reports every connection failure as `TypeError: fetch failed` and keeps the useful part
|
|
@@ -684,8 +672,7 @@ async function assertInputExists(input) {
|
|
|
684
672
|
location: { kind: "config" }
|
|
685
673
|
});
|
|
686
674
|
}
|
|
687
|
-
|
|
688
|
-
//#region src/load/normalize.ts
|
|
675
|
+
// src/load/normalize.ts
|
|
689
676
|
/**
|
|
690
677
|
* True when `node` contains a `$ref` pointing outside the current document (a relative path,
|
|
691
678
|
* absolute path, or URL). An internal `#/...` fragment does not count.
|
|
@@ -931,8 +918,7 @@ async function validateDocumentInWorker(document) {
|
|
|
931
918
|
if ("thrown" in message) return reportInvalidSpec(message.thrown);
|
|
932
919
|
if (!message.valid) reportValidationErrors(message);
|
|
933
920
|
}
|
|
934
|
-
|
|
935
|
-
//#region src/model/components.ts
|
|
921
|
+
// src/model/components.ts
|
|
936
922
|
/**
|
|
937
923
|
* Extracts the inline schema from a media-type `content` map, with the media type it sits under.
|
|
938
924
|
*
|
|
@@ -1134,8 +1120,7 @@ function getSchemas(document, { contentType }, refs) {
|
|
|
1134
1120
|
pointers
|
|
1135
1121
|
};
|
|
1136
1122
|
}
|
|
1137
|
-
|
|
1138
|
-
//#region src/model/server.ts
|
|
1123
|
+
// src/model/server.ts
|
|
1139
1124
|
/**
|
|
1140
1125
|
* Reads the server URL from the document's `servers` array at `server.index`,
|
|
1141
1126
|
* interpolating any `server.variables` into the URL template.
|
|
@@ -1187,8 +1172,7 @@ function resolveServerUrl(server, overrides) {
|
|
|
1187
1172
|
}
|
|
1188
1173
|
return url;
|
|
1189
1174
|
}
|
|
1190
|
-
|
|
1191
|
-
//#region src/emit/schemaShape.ts
|
|
1175
|
+
// src/emit/schemaShape.ts
|
|
1192
1176
|
/**
|
|
1193
1177
|
* Whether `format` maps to a dedicated type; `false` is what `KUBB_UNSUPPORTED_FORMAT` flags.
|
|
1194
1178
|
*/
|
|
@@ -1241,8 +1225,7 @@ function flattenSchema(schema) {
|
|
|
1241
1225
|
for (const fragment of allOfFragments) for (const [key, value] of Object.entries(fragment)) merged[key] ??= value;
|
|
1242
1226
|
return merged;
|
|
1243
1227
|
}
|
|
1244
|
-
|
|
1245
|
-
//#region src/schemaDiagnostics.ts
|
|
1228
|
+
// src/schemaDiagnostics.ts
|
|
1246
1229
|
/**
|
|
1247
1230
|
* Links one freshly converted schema and its nested schemas to their RFC 6901 pointers
|
|
1248
1231
|
* (`#/components/schemas/Pet/properties/owner/properties/name`), and reports the advisory
|
|
@@ -1296,8 +1279,7 @@ function visit(node, pointer) {
|
|
|
1296
1279
|
for (const [index, member] of (node.members ?? []).entries()) visit(member, `${pointer}/${keyword}/${index}`);
|
|
1297
1280
|
}
|
|
1298
1281
|
}
|
|
1299
|
-
|
|
1300
|
-
//#region src/operation.ts
|
|
1282
|
+
// src/operation.ts
|
|
1301
1283
|
function slugify(value) {
|
|
1302
1284
|
return value.replace(/[^a-zA-Z0-9]/g, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
|
|
1303
1285
|
}
|
|
@@ -1566,8 +1548,7 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
1566
1548
|
extensions: pickExtensions(operation.schema)
|
|
1567
1549
|
});
|
|
1568
1550
|
}
|
|
1569
|
-
|
|
1570
|
-
//#region src/emit/createNode.ts
|
|
1551
|
+
// src/emit/createNode.ts
|
|
1571
1552
|
/**
|
|
1572
1553
|
* Builds a schema node from a converter's base context plus its type-specific fields. Every
|
|
1573
1554
|
* converter needs the same metadata fields (`title`, `description`, `examples`, ...) alongside
|
|
@@ -1588,8 +1569,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
|
|
|
1588
1569
|
...extras
|
|
1589
1570
|
});
|
|
1590
1571
|
}
|
|
1591
|
-
|
|
1592
|
-
//#region src/emit/discriminator/preserve.ts
|
|
1572
|
+
// src/emit/discriminator/preserve.ts
|
|
1593
1573
|
/**
|
|
1594
1574
|
* Turns string mapping keys into the discriminator property's type when they parse cleanly.
|
|
1595
1575
|
*/
|
|
@@ -1825,8 +1805,7 @@ function extractDiscriminatedAllOfMembers({ allOfMembers, name, refs }) {
|
|
|
1825
1805
|
discriminantValues
|
|
1826
1806
|
};
|
|
1827
1807
|
}
|
|
1828
|
-
|
|
1829
|
-
//#region src/emit/converters/annotatedEnum.ts
|
|
1808
|
+
// src/emit/converters/annotatedEnum.ts
|
|
1830
1809
|
const ANNOTATIONS = /* @__PURE__ */ new Set([
|
|
1831
1810
|
"title",
|
|
1832
1811
|
"description",
|
|
@@ -1892,8 +1871,7 @@ function convertAnnotatedEnum(context) {
|
|
|
1892
1871
|
namedEnumValues
|
|
1893
1872
|
});
|
|
1894
1873
|
}
|
|
1895
|
-
|
|
1896
|
-
//#region src/emit/converters/composition.ts
|
|
1874
|
+
// src/emit/converters/composition.ts
|
|
1897
1875
|
/**
|
|
1898
1876
|
* Collects property schemas from all `allOf` members and outer schema properties,
|
|
1899
1877
|
* recursively resolving `$ref` pointers.
|
|
@@ -2229,8 +2207,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
|
|
|
2229
2207
|
})
|
|
2230
2208
|
});
|
|
2231
2209
|
}
|
|
2232
|
-
|
|
2233
|
-
//#region src/emit/converters/scalar.ts
|
|
2210
|
+
// src/emit/converters/scalar.ts
|
|
2234
2211
|
/**
|
|
2235
2212
|
* Normalizes malformed `{ type: 'array', enum: [...] }` schemas by moving enum values into items.
|
|
2236
2213
|
*
|
|
@@ -2406,8 +2383,7 @@ function convertNumeric(context, type) {
|
|
|
2406
2383
|
...getNumericConstraints(context.schema)
|
|
2407
2384
|
});
|
|
2408
2385
|
}
|
|
2409
|
-
|
|
2410
|
-
//#region src/emit/converters/structural.ts
|
|
2386
|
+
// src/emit/converters/structural.ts
|
|
2411
2387
|
/**
|
|
2412
2388
|
* Resolves a `true` or empty-object map schema (`additionalProperties`/`patternProperties`) to
|
|
2413
2389
|
* `options.unknownType`, otherwise parses it as a regular schema.
|
|
@@ -2438,8 +2414,9 @@ function nameEnums(node, options) {
|
|
|
2438
2414
|
* Converts an object-like schema into an `ObjectSchemaNode`.
|
|
2439
2415
|
*/
|
|
2440
2416
|
function convertObject({ schema, name, nullable, defaultValue, options, parse, refs }) {
|
|
2417
|
+
const requiredNames = Array.isArray(schema.required) ? new Set(schema.required) : void 0;
|
|
2441
2418
|
const properties = schema.properties ? Object.entries(schema.properties).map(([propName, propSchema]) => {
|
|
2442
|
-
const required =
|
|
2419
|
+
const required = requiredNames ? requiredNames.has(propName) : !!schema.required;
|
|
2443
2420
|
const resolvedPropSchema = propSchema;
|
|
2444
2421
|
const propNullable = isNullable(resolvedPropSchema);
|
|
2445
2422
|
const schemaNode = nameEnums(parse({
|
|
@@ -2558,8 +2535,7 @@ function convertArray({ schema, name, nullable, defaultValue, options, parse })
|
|
|
2558
2535
|
unique: schema.uniqueItems ?? void 0
|
|
2559
2536
|
});
|
|
2560
2537
|
}
|
|
2561
|
-
|
|
2562
|
-
//#region src/emit/parseSchema.ts
|
|
2538
|
+
// src/emit/parseSchema.ts
|
|
2563
2539
|
/**
|
|
2564
2540
|
* Ordered schema rule table. Order is significant: composition keywords (`not`, `$ref`, `allOf`,
|
|
2565
2541
|
* `oneOf`/`anyOf`) take precedence over `const` (except a `$ref` with a sibling `const`, where the
|
|
@@ -2660,8 +2636,7 @@ const schemaRules = [
|
|
|
2660
2636
|
convert: ({ schema, name, nullable }) => createNullNode(schema, name, nullable)
|
|
2661
2637
|
}
|
|
2662
2638
|
];
|
|
2663
|
-
|
|
2664
|
-
//#region src/parser.ts
|
|
2639
|
+
// src/parser.ts
|
|
2665
2640
|
/**
|
|
2666
2641
|
* Creates the schema converter bound to one OpenAPI document: `parseSchema` dispatches each
|
|
2667
2642
|
* schema through the ordered `schemaRules` table, with the parser options merged once.
|
|
@@ -2698,8 +2673,7 @@ function createSchemaParser(ctx) {
|
|
|
2698
2673
|
}
|
|
2699
2674
|
return parseSchema;
|
|
2700
2675
|
}
|
|
2701
|
-
|
|
2702
|
-
//#region src/promoteEnums.ts
|
|
2676
|
+
// src/promoteEnums.ts
|
|
2703
2677
|
/**
|
|
2704
2678
|
* Collects inline enums to lift to the top level, keyed by the name the parser derived for them
|
|
2705
2679
|
* (e.g. `PetStatusEnum`). An enum already defined as a top-level component is left as-is, and a
|
|
@@ -2745,8 +2719,7 @@ function refPromotedEnums(node, promoted) {
|
|
|
2745
2719
|
});
|
|
2746
2720
|
} });
|
|
2747
2721
|
}
|
|
2748
|
-
|
|
2749
|
-
//#region src/sourceLocator.ts
|
|
2722
|
+
// src/sourceLocator.ts
|
|
2750
2723
|
let cached;
|
|
2751
2724
|
const toRange = ([start, end]) => ({
|
|
2752
2725
|
start,
|
|
@@ -2903,8 +2876,7 @@ const locate = (source, location) => {
|
|
|
2903
2876
|
const { document } = cached;
|
|
2904
2877
|
return findPointer(document, location.pointer) ?? (ref ? findRefUsage(document, ref) : void 0);
|
|
2905
2878
|
};
|
|
2906
|
-
|
|
2907
|
-
//#region src/adapter.ts
|
|
2879
|
+
// src/adapter.ts
|
|
2908
2880
|
/**
|
|
2909
2881
|
* The `name` of `@kubb/adapter-oas`, used to identify this adapter in a Kubb config.
|
|
2910
2882
|
*/
|
|
@@ -3149,7 +3121,6 @@ const adapterOas = (0, _kubb_core.defineExtension)({
|
|
|
3149
3121
|
};
|
|
3150
3122
|
}
|
|
3151
3123
|
});
|
|
3152
|
-
//#endregion
|
|
3153
3124
|
exports.adapterOas = adapterOas;
|
|
3154
3125
|
exports.adapterOasName = adapterOasName;
|
|
3155
3126
|
|