@kubb/adapter-oas 5.23.3 → 5.23.4
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 +37 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var compatibility = {
|
|
|
15
15
|
"node": ">=22.22"
|
|
16
16
|
};
|
|
17
17
|
// package.json
|
|
18
|
-
var version = "5.23.
|
|
18
|
+
var version = "5.23.4";
|
|
19
19
|
// src/constants.ts
|
|
20
20
|
/**
|
|
21
21
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -430,6 +430,7 @@ function getExternalDocs(source) {
|
|
|
430
430
|
* Returns the `x-*` keys of `source` as-is, or `undefined` when there are none.
|
|
431
431
|
*/
|
|
432
432
|
function pickExtensions(source) {
|
|
433
|
+
if (!source) return void 0;
|
|
433
434
|
const entries = Object.entries(source).filter(([key]) => key.startsWith("x-"));
|
|
434
435
|
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
435
436
|
}
|
|
@@ -2280,7 +2281,8 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
|
|
|
2280
2281
|
...mediaType?.encoding && { encoding: getEncodingFields({ encoding: mediaType.encoding }).encoding },
|
|
2281
2282
|
...getExamples(mediaType ?? param, refs),
|
|
2282
2283
|
...param.deprecated && { deprecated: true },
|
|
2283
|
-
...param.allowEmptyValue && { allowEmptyValue: true }
|
|
2284
|
+
...param.allowEmptyValue && { allowEmptyValue: true },
|
|
2285
|
+
extensions: pickExtensions(param)
|
|
2284
2286
|
});
|
|
2285
2287
|
}
|
|
2286
2288
|
function spreadQuerystring(param) {
|
|
@@ -2298,7 +2300,8 @@ function spreadQuerystring(param) {
|
|
|
2298
2300
|
required: param.required && property.required,
|
|
2299
2301
|
...style !== void 0 && { style },
|
|
2300
2302
|
...explode !== void 0 && { explode },
|
|
2301
|
-
...allowReserved !== void 0 && { allowReserved }
|
|
2303
|
+
...allowReserved !== void 0 && { allowReserved },
|
|
2304
|
+
...param.extensions && { extensions: param.extensions }
|
|
2302
2305
|
});
|
|
2303
2306
|
});
|
|
2304
2307
|
}
|
|
@@ -2356,14 +2359,16 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2356
2359
|
refs,
|
|
2357
2360
|
document,
|
|
2358
2361
|
node
|
|
2359
|
-
})
|
|
2362
|
+
}),
|
|
2363
|
+
extensions: pickExtensions(mediaType)
|
|
2360
2364
|
})];
|
|
2361
2365
|
});
|
|
2362
2366
|
const requestBody = content.length > 0 || body?.description ? {
|
|
2363
2367
|
pointer: `${pointer}/requestBody`,
|
|
2364
2368
|
description: body?.description,
|
|
2365
2369
|
required: bodyRequired || void 0,
|
|
2366
|
-
content: content.length > 0 ? content : void 0
|
|
2370
|
+
content: content.length > 0 ? content : void 0,
|
|
2371
|
+
extensions: pickExtensions(body)
|
|
2367
2372
|
} : void 0;
|
|
2368
2373
|
const responses = getResponseStatusCodes(operation).map((key) => {
|
|
2369
2374
|
const response = getResponseByStatusCode({
|
|
@@ -2401,7 +2406,8 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2401
2406
|
refs,
|
|
2402
2407
|
document,
|
|
2403
2408
|
node
|
|
2404
|
-
}) : {}
|
|
2409
|
+
}) : {},
|
|
2410
|
+
extensions: pickExtensions(mediaType)
|
|
2405
2411
|
};
|
|
2406
2412
|
};
|
|
2407
2413
|
const declaredContentTypes = Object.keys(response?.content ?? {});
|
|
@@ -2438,7 +2444,8 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2438
2444
|
description: response?.description,
|
|
2439
2445
|
content: responseContent,
|
|
2440
2446
|
...headers.length && { headers },
|
|
2441
|
-
...links && { links }
|
|
2447
|
+
...links && { links },
|
|
2448
|
+
extensions: pickExtensions(response)
|
|
2442
2449
|
});
|
|
2443
2450
|
});
|
|
2444
2451
|
const pickDoc = (key) => {
|
|
@@ -2500,6 +2507,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
|
|
|
2500
2507
|
examples: extractExamples(schema),
|
|
2501
2508
|
format: schema.format,
|
|
2502
2509
|
externalDocs: getExternalDocs(schema.externalDocs),
|
|
2510
|
+
extensions: pickExtensions(schema),
|
|
2503
2511
|
...extras
|
|
2504
2512
|
});
|
|
2505
2513
|
}
|
|
@@ -2917,7 +2925,11 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
|
|
|
2917
2925
|
writeOnly: schema.writeOnly ?? resolvedSchema.writeOnly,
|
|
2918
2926
|
default: defaultValue ?? resolvedSchema.default,
|
|
2919
2927
|
name: name ?? resolvedSchema.name,
|
|
2920
|
-
nullable: nullable ?? resolvedSchema.nullable
|
|
2928
|
+
nullable: nullable ?? resolvedSchema.nullable,
|
|
2929
|
+
extensions: pickExtensions({
|
|
2930
|
+
...resolvedSchema.extensions,
|
|
2931
|
+
...schema
|
|
2932
|
+
})
|
|
2921
2933
|
});
|
|
2922
2934
|
const targetName = renames?.get(schema.$ref);
|
|
2923
2935
|
return createNode(ctx, {
|
|
@@ -3009,6 +3021,10 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
|
|
|
3009
3021
|
examples: extractExamples(schema) ?? memberNode.examples,
|
|
3010
3022
|
pattern: schema.pattern ?? ("pattern" in memberNode ? memberNode.pattern : void 0),
|
|
3011
3023
|
format: schema.format ?? memberNode.format,
|
|
3024
|
+
extensions: pickExtensions({
|
|
3025
|
+
...memberNode.extensions,
|
|
3026
|
+
...schema
|
|
3027
|
+
}),
|
|
3012
3028
|
externalDocs: getExternalDocs(schema.externalDocs) ?? memberNode.externalDocs
|
|
3013
3029
|
});
|
|
3014
3030
|
}
|
|
@@ -3166,7 +3182,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
|
|
|
3166
3182
|
members: nonNullTypes.map((t) => {
|
|
3167
3183
|
return parse({
|
|
3168
3184
|
schema: {
|
|
3169
|
-
...schema,
|
|
3185
|
+
...Object.fromEntries(Object.entries(schema).filter(([key]) => !key.startsWith("x-"))),
|
|
3170
3186
|
type: t
|
|
3171
3187
|
},
|
|
3172
3188
|
name
|
|
@@ -3257,7 +3273,8 @@ function createNullNode(schema, name, nullable) {
|
|
|
3257
3273
|
description: schema.description,
|
|
3258
3274
|
deprecated: schema.deprecated,
|
|
3259
3275
|
nullable,
|
|
3260
|
-
format: schema.format
|
|
3276
|
+
format: schema.format,
|
|
3277
|
+
extensions: pickExtensions(schema)
|
|
3261
3278
|
});
|
|
3262
3279
|
}
|
|
3263
3280
|
/**
|
|
@@ -3301,6 +3318,7 @@ function convertFormat(context) {
|
|
|
3301
3318
|
});
|
|
3302
3319
|
}
|
|
3303
3320
|
const specialType = formatMap[schema.format];
|
|
3321
|
+
if (specialType === "blob") return convertBlob(context);
|
|
3304
3322
|
if (specialType === "string") {
|
|
3305
3323
|
if (type === "integer" || type === "number") return convertNumeric(context, type);
|
|
3306
3324
|
return convertString(context);
|
|
@@ -3406,6 +3424,14 @@ function convertString(context) {
|
|
|
3406
3424
|
...getStringContent(context)
|
|
3407
3425
|
});
|
|
3408
3426
|
}
|
|
3427
|
+
/** Converts a binary schema into a `BlobSchemaNode`, keeping `contentMediaType` and `contentEncoding`. */
|
|
3428
|
+
function convertBlob(context) {
|
|
3429
|
+
return createNode(context, {
|
|
3430
|
+
type: "blob",
|
|
3431
|
+
primitive: "string",
|
|
3432
|
+
...getStringContent(context)
|
|
3433
|
+
});
|
|
3434
|
+
}
|
|
3409
3435
|
/**
|
|
3410
3436
|
* Converts a `type: 'number'` or `type: 'integer'` schema.
|
|
3411
3437
|
*/
|
|
@@ -3648,10 +3674,7 @@ const schemaRules = [
|
|
|
3648
3674
|
},
|
|
3649
3675
|
{
|
|
3650
3676
|
match: ({ schema }) => isBinary(schema),
|
|
3651
|
-
convert:
|
|
3652
|
-
type: "blob",
|
|
3653
|
-
primitive: "string"
|
|
3654
|
-
})
|
|
3677
|
+
convert: convertBlob
|
|
3655
3678
|
},
|
|
3656
3679
|
{
|
|
3657
3680
|
match: ({ schema, type }) => !type && !schema.enum?.length && (schema.contentMediaType !== void 0 || schema.contentSchema !== void 0),
|