@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.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var compatibility = {
|
|
|
16
16
|
"node": ">=22.22"
|
|
17
17
|
};
|
|
18
18
|
// package.json
|
|
19
|
-
var version = "5.23.
|
|
19
|
+
var version = "5.23.4";
|
|
20
20
|
// src/constants.ts
|
|
21
21
|
/**
|
|
22
22
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -431,6 +431,7 @@ function getExternalDocs(source) {
|
|
|
431
431
|
* Returns the `x-*` keys of `source` as-is, or `undefined` when there are none.
|
|
432
432
|
*/
|
|
433
433
|
function pickExtensions(source) {
|
|
434
|
+
if (!source) return void 0;
|
|
434
435
|
const entries = Object.entries(source).filter(([key]) => key.startsWith("x-"));
|
|
435
436
|
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
436
437
|
}
|
|
@@ -2282,7 +2283,8 @@ function parseParameter({ param, pointer, parentName, options, parseSchema, refs
|
|
|
2282
2283
|
...mediaType?.encoding && { encoding: getEncodingFields({ encoding: mediaType.encoding }).encoding },
|
|
2283
2284
|
...getExamples(mediaType ?? param, refs),
|
|
2284
2285
|
...param.deprecated && { deprecated: true },
|
|
2285
|
-
...param.allowEmptyValue && { allowEmptyValue: true }
|
|
2286
|
+
...param.allowEmptyValue && { allowEmptyValue: true },
|
|
2287
|
+
extensions: pickExtensions(param)
|
|
2286
2288
|
});
|
|
2287
2289
|
}
|
|
2288
2290
|
function spreadQuerystring(param) {
|
|
@@ -2300,7 +2302,8 @@ function spreadQuerystring(param) {
|
|
|
2300
2302
|
required: param.required && property.required,
|
|
2301
2303
|
...style !== void 0 && { style },
|
|
2302
2304
|
...explode !== void 0 && { explode },
|
|
2303
|
-
...allowReserved !== void 0 && { allowReserved }
|
|
2305
|
+
...allowReserved !== void 0 && { allowReserved },
|
|
2306
|
+
...param.extensions && { extensions: param.extensions }
|
|
2304
2307
|
});
|
|
2305
2308
|
});
|
|
2306
2309
|
}
|
|
@@ -2358,14 +2361,16 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2358
2361
|
refs,
|
|
2359
2362
|
document,
|
|
2360
2363
|
node
|
|
2361
|
-
})
|
|
2364
|
+
}),
|
|
2365
|
+
extensions: pickExtensions(mediaType)
|
|
2362
2366
|
})];
|
|
2363
2367
|
});
|
|
2364
2368
|
const requestBody = content.length > 0 || body?.description ? {
|
|
2365
2369
|
pointer: `${pointer}/requestBody`,
|
|
2366
2370
|
description: body?.description,
|
|
2367
2371
|
required: bodyRequired || void 0,
|
|
2368
|
-
content: content.length > 0 ? content : void 0
|
|
2372
|
+
content: content.length > 0 ? content : void 0,
|
|
2373
|
+
extensions: pickExtensions(body)
|
|
2369
2374
|
} : void 0;
|
|
2370
2375
|
const responses = getResponseStatusCodes(operation).map((key) => {
|
|
2371
2376
|
const response = getResponseByStatusCode({
|
|
@@ -2403,7 +2408,8 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2403
2408
|
refs,
|
|
2404
2409
|
document,
|
|
2405
2410
|
node
|
|
2406
|
-
}) : {}
|
|
2411
|
+
}) : {},
|
|
2412
|
+
extensions: pickExtensions(mediaType)
|
|
2407
2413
|
};
|
|
2408
2414
|
};
|
|
2409
2415
|
const declaredContentTypes = Object.keys(response?.content ?? {});
|
|
@@ -2440,7 +2446,8 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2440
2446
|
description: response?.description,
|
|
2441
2447
|
content: responseContent,
|
|
2442
2448
|
...headers.length && { headers },
|
|
2443
|
-
...links && { links }
|
|
2449
|
+
...links && { links },
|
|
2450
|
+
extensions: pickExtensions(response)
|
|
2444
2451
|
});
|
|
2445
2452
|
});
|
|
2446
2453
|
const pickDoc = (key) => {
|
|
@@ -2502,6 +2509,7 @@ function createNode({ schema, name, nullable, defaultValue }, extras) {
|
|
|
2502
2509
|
examples: extractExamples(schema),
|
|
2503
2510
|
format: schema.format,
|
|
2504
2511
|
externalDocs: getExternalDocs(schema.externalDocs),
|
|
2512
|
+
extensions: pickExtensions(schema),
|
|
2505
2513
|
...extras
|
|
2506
2514
|
});
|
|
2507
2515
|
}
|
|
@@ -2919,7 +2927,11 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
|
|
|
2919
2927
|
writeOnly: schema.writeOnly ?? resolvedSchema.writeOnly,
|
|
2920
2928
|
default: defaultValue ?? resolvedSchema.default,
|
|
2921
2929
|
name: name ?? resolvedSchema.name,
|
|
2922
|
-
nullable: nullable ?? resolvedSchema.nullable
|
|
2930
|
+
nullable: nullable ?? resolvedSchema.nullable,
|
|
2931
|
+
extensions: pickExtensions({
|
|
2932
|
+
...resolvedSchema.extensions,
|
|
2933
|
+
...schema
|
|
2934
|
+
})
|
|
2923
2935
|
});
|
|
2924
2936
|
const targetName = renames?.get(schema.$ref);
|
|
2925
2937
|
return createNode(ctx, {
|
|
@@ -3011,6 +3023,10 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
|
|
|
3011
3023
|
examples: extractExamples(schema) ?? memberNode.examples,
|
|
3012
3024
|
pattern: schema.pattern ?? ("pattern" in memberNode ? memberNode.pattern : void 0),
|
|
3013
3025
|
format: schema.format ?? memberNode.format,
|
|
3026
|
+
extensions: pickExtensions({
|
|
3027
|
+
...memberNode.extensions,
|
|
3028
|
+
...schema
|
|
3029
|
+
}),
|
|
3014
3030
|
externalDocs: getExternalDocs(schema.externalDocs) ?? memberNode.externalDocs
|
|
3015
3031
|
});
|
|
3016
3032
|
}
|
|
@@ -3168,7 +3184,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
|
|
|
3168
3184
|
members: nonNullTypes.map((t) => {
|
|
3169
3185
|
return parse({
|
|
3170
3186
|
schema: {
|
|
3171
|
-
...schema,
|
|
3187
|
+
...Object.fromEntries(Object.entries(schema).filter(([key]) => !key.startsWith("x-"))),
|
|
3172
3188
|
type: t
|
|
3173
3189
|
},
|
|
3174
3190
|
name
|
|
@@ -3259,7 +3275,8 @@ function createNullNode(schema, name, nullable) {
|
|
|
3259
3275
|
description: schema.description,
|
|
3260
3276
|
deprecated: schema.deprecated,
|
|
3261
3277
|
nullable,
|
|
3262
|
-
format: schema.format
|
|
3278
|
+
format: schema.format,
|
|
3279
|
+
extensions: pickExtensions(schema)
|
|
3263
3280
|
});
|
|
3264
3281
|
}
|
|
3265
3282
|
/**
|
|
@@ -3303,6 +3320,7 @@ function convertFormat(context) {
|
|
|
3303
3320
|
});
|
|
3304
3321
|
}
|
|
3305
3322
|
const specialType = formatMap[schema.format];
|
|
3323
|
+
if (specialType === "blob") return convertBlob(context);
|
|
3306
3324
|
if (specialType === "string") {
|
|
3307
3325
|
if (type === "integer" || type === "number") return convertNumeric(context, type);
|
|
3308
3326
|
return convertString(context);
|
|
@@ -3408,6 +3426,14 @@ function convertString(context) {
|
|
|
3408
3426
|
...getStringContent(context)
|
|
3409
3427
|
});
|
|
3410
3428
|
}
|
|
3429
|
+
/** Converts a binary schema into a `BlobSchemaNode`, keeping `contentMediaType` and `contentEncoding`. */
|
|
3430
|
+
function convertBlob(context) {
|
|
3431
|
+
return createNode(context, {
|
|
3432
|
+
type: "blob",
|
|
3433
|
+
primitive: "string",
|
|
3434
|
+
...getStringContent(context)
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3411
3437
|
/**
|
|
3412
3438
|
* Converts a `type: 'number'` or `type: 'integer'` schema.
|
|
3413
3439
|
*/
|
|
@@ -3650,10 +3676,7 @@ const schemaRules = [
|
|
|
3650
3676
|
},
|
|
3651
3677
|
{
|
|
3652
3678
|
match: ({ schema }) => isBinary(schema),
|
|
3653
|
-
convert:
|
|
3654
|
-
type: "blob",
|
|
3655
|
-
primitive: "string"
|
|
3656
|
-
})
|
|
3679
|
+
convert: convertBlob
|
|
3657
3680
|
},
|
|
3658
3681
|
{
|
|
3659
3682
|
match: ({ schema, type }) => !type && !schema.enum?.length && (schema.contentMediaType !== void 0 || schema.contentSchema !== void 0),
|