@kubb/adapter-oas 5.15.1 → 5.15.2
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 +19 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -20
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var compatibility = {
|
|
|
35
35
|
"node": ">=22.22"
|
|
36
36
|
};
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "5.15.
|
|
38
|
+
var version = "5.15.2";
|
|
39
39
|
// src/constants.ts
|
|
40
40
|
/**
|
|
41
41
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -320,6 +320,12 @@ function getErrorMessage(value) {
|
|
|
320
320
|
function escapePointerToken(token) {
|
|
321
321
|
return token.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
322
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Unescapes one JSON pointer token per RFC 6901 (`~1` → `/`, then `~0` → `~`).
|
|
325
|
+
*/
|
|
326
|
+
function unescapePointerToken(token) {
|
|
327
|
+
return token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
328
|
+
}
|
|
323
329
|
// ../../internals/utils/src/runtime.ts
|
|
324
330
|
const isBun = typeof Bun !== "undefined";
|
|
325
331
|
const isDeno = "Deno" in globalThis;
|
|
@@ -490,7 +496,7 @@ function createRefs(document) {
|
|
|
490
496
|
applicable: true,
|
|
491
497
|
value: pointerCache.get(pointer)
|
|
492
498
|
};
|
|
493
|
-
const current = pointer.split("/").filter(Boolean).map((token) => globalThis.decodeURIComponent(token)
|
|
499
|
+
const current = pointer.split("/").filter(Boolean).map((token) => unescapePointerToken(globalThis.decodeURIComponent(token))).reduce((obj, key) => obj?.[key], document);
|
|
494
500
|
if (current) pointerCache.set(pointer, current);
|
|
495
501
|
return {
|
|
496
502
|
applicable: true,
|
|
@@ -1351,14 +1357,19 @@ const PARAMETER_STYLES = /* @__PURE__ */ new Set([
|
|
|
1351
1357
|
"pipeDelimited",
|
|
1352
1358
|
"deepObject"
|
|
1353
1359
|
]);
|
|
1360
|
+
function pickStyleFields({ style, explode, allowReserved }) {
|
|
1361
|
+
return {
|
|
1362
|
+
...style !== void 0 && PARAMETER_STYLES.has(style) ? { style } : {},
|
|
1363
|
+
...explode !== void 0 ? { explode } : {},
|
|
1364
|
+
...allowReserved !== void 0 ? { allowReserved } : {}
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1354
1367
|
/** The `encoding` of a media type, reduced to the entries that set a field Kubb carries. A `style` outside the OpenAPI set is dropped. */
|
|
1355
1368
|
function getEncoding(encoding) {
|
|
1356
|
-
const entries = Object.entries(encoding ?? {}).flatMap(([property, { contentType,
|
|
1369
|
+
const entries = Object.entries(encoding ?? {}).flatMap(([property, { contentType, ...rest }]) => {
|
|
1357
1370
|
const node = {
|
|
1358
1371
|
...contentType !== void 0 ? { contentType } : {},
|
|
1359
|
-
...
|
|
1360
|
-
...explode !== void 0 ? { explode } : {},
|
|
1361
|
-
...allowReserved !== void 0 ? { allowReserved } : {}
|
|
1372
|
+
...pickStyleFields(rest)
|
|
1362
1373
|
};
|
|
1363
1374
|
return Object.keys(node).length ? [[property, node]] : [];
|
|
1364
1375
|
});
|
|
@@ -1418,9 +1429,6 @@ function parseParameter({ param, pointer, parentName, options, parseSchema }) {
|
|
|
1418
1429
|
name: schemaName
|
|
1419
1430
|
}) : _kubb_kit.ast.factory.createSchema({ type: options.unknownType });
|
|
1420
1431
|
if (rawSchema) scanSchema(schema, contentType ? `${pointer}/content/${escapePointerToken(contentType)}/schema` : `${pointer}/schema`);
|
|
1421
|
-
const style = param.style !== void 0 && PARAMETER_STYLES.has(param.style) ? param.style : void 0;
|
|
1422
|
-
const explode = param.explode;
|
|
1423
|
-
const allowReserved = param.allowReserved;
|
|
1424
1432
|
return _kubb_kit.ast.factory.createParameter({
|
|
1425
1433
|
pointer,
|
|
1426
1434
|
name: param.name,
|
|
@@ -1430,9 +1438,7 @@ function parseParameter({ param, pointer, parentName, options, parseSchema }) {
|
|
|
1430
1438
|
description: param.description ?? schema.description
|
|
1431
1439
|
},
|
|
1432
1440
|
required: param.required ?? false,
|
|
1433
|
-
...
|
|
1434
|
-
...explode !== void 0 ? { explode } : {},
|
|
1435
|
-
...allowReserved !== void 0 ? { allowReserved } : {},
|
|
1441
|
+
...pickStyleFields(param),
|
|
1436
1442
|
...contentType !== void 0 ? { contentType } : {}
|
|
1437
1443
|
});
|
|
1438
1444
|
}
|
|
@@ -2725,10 +2731,9 @@ const toRange = ([start, end]) => ({
|
|
|
2725
2731
|
start,
|
|
2726
2732
|
end
|
|
2727
2733
|
});
|
|
2728
|
-
const unescapeToken = (token) => token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
2729
2734
|
/** Walks a JSON pointer through maps and sequences; the range is the last key or item it reached. */
|
|
2730
2735
|
function findPointer(document, pointer) {
|
|
2731
|
-
return pointer.replace(/^#/, "").split("/").slice(1).map(
|
|
2736
|
+
return pointer.replace(/^#/, "").split("/").slice(1).map(unescapePointerToken).reduce((at, token) => {
|
|
2732
2737
|
if (yaml.isMap(at?.node)) {
|
|
2733
2738
|
const pair = at.node.items.find((item) => yaml.isScalar(item.key) && String(item.key.value) === token);
|
|
2734
2739
|
return pair && yaml.isScalar(pair.key) && pair.key.range ? {
|
|
@@ -2939,7 +2944,6 @@ const adapterOas = (0, _kubb_core.defineExtension)({
|
|
|
2939
2944
|
function parseInput({ document, refs, schemas, pointers, parseSchema }) {
|
|
2940
2945
|
const parsedByName = /* @__PURE__ */ new Map();
|
|
2941
2946
|
const refAliasMap = /* @__PURE__ */ new Map();
|
|
2942
|
-
const enumNames = /* @__PURE__ */ new Set();
|
|
2943
2947
|
const discriminatorParentNodes = [];
|
|
2944
2948
|
for (const [name, schema] of Object.entries(schemas)) {
|
|
2945
2949
|
const node = {
|
|
@@ -2952,10 +2956,8 @@ const adapterOas = (0, _kubb_core.defineExtension)({
|
|
|
2952
2956
|
parsedByName.set(name, node);
|
|
2953
2957
|
scanSchema(node);
|
|
2954
2958
|
if (node.type === "ref" && node.name) refAliasMap.set(name, node);
|
|
2955
|
-
if (_kubb_kit.ast.narrowSchema(node, "enum") && node.name) enumNames.add(node.name);
|
|
2956
2959
|
if (discriminator === "propagate" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
|
|
2957
2960
|
}
|
|
2958
|
-
const circularNames = _kubb_kit.ast.findCircularSchemas([...parsedByName.values()]);
|
|
2959
2961
|
const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null;
|
|
2960
2962
|
const operationNodes = getOperations(document, refs).map((operation) => parseOperation({
|
|
2961
2963
|
operation,
|
|
@@ -2965,7 +2967,6 @@ const adapterOas = (0, _kubb_core.defineExtension)({
|
|
|
2965
2967
|
parseSchema
|
|
2966
2968
|
}));
|
|
2967
2969
|
const promotedEnums = enums === "root" ? collectInlineEnums([...parsedByName.values(), ...operationNodes], new Set(Object.keys(schemas))) : null;
|
|
2968
|
-
if (promotedEnums) for (const name of promotedEnums.keys()) enumNames.add(name);
|
|
2969
2970
|
const aliasTargetOf = (name) => {
|
|
2970
2971
|
const node = refAliasMap.get(name);
|
|
2971
2972
|
return node?.ref ? _kubb_kit.ast.refName(node.ref) : node?.name;
|
|
@@ -3054,8 +3055,6 @@ const adapterOas = (0, _kubb_core.defineExtension)({
|
|
|
3054
3055
|
parameterName: scheme.name
|
|
3055
3056
|
}] : [];
|
|
3056
3057
|
}),
|
|
3057
|
-
circularNames,
|
|
3058
|
-
enumNames,
|
|
3059
3058
|
extensions: pickExtensions(document)
|
|
3060
3059
|
}
|
|
3061
3060
|
});
|