@kubb/plugin-fetch 5.7.1 → 5.7.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 +10 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -35
- package/dist/index.js.map +1 -1
- package/dist/templates/serializers.d.ts +7 -3
- package/package.json +5 -5
- package/src/plugin.ts +1 -22
- package/templates/serializers.ts +31 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Diagnostics, Resolver, Url, addGenerator,
|
|
1
|
+
import { Diagnostics, Resolver, Url, addGenerator, ast, createResolver, defineExtension, defineGenerator, injectFile, macroSimplifyUnion, setMacros, setResolver, useConfig } from "kubb/kit";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
4
4
|
import { File, Function, jsxRenderer } from "kubb/jsx";
|
|
@@ -699,25 +699,27 @@ function toKey(name, location) {
|
|
|
699
699
|
return isValidVarName(key) ? key : JSON.stringify(key);
|
|
700
700
|
}
|
|
701
701
|
/**
|
|
702
|
-
* Serializes one parameter's metadata into a `{ style, explode, allowReserved
|
|
703
|
-
* when the parameter carries none. Path and query carry the serialization
|
|
704
|
-
* use a fixed style (`simple` and `form`), so only `explode` is emitted
|
|
705
|
-
* only applies to query parameters
|
|
702
|
+
* Serializes one parameter's metadata into a `{ style, explode, allowReserved, contentType }`
|
|
703
|
+
* literal, or `null` when the parameter carries none. Path and query carry the serialization
|
|
704
|
+
* `style`; header and cookie use a fixed style (`simple` and `form`), so only `explode` is emitted
|
|
705
|
+
* for them. `allowReserved` only applies to query parameters, and `contentType` to every location
|
|
706
|
+
* except path.
|
|
706
707
|
*/
|
|
707
708
|
function serializeParameter(parameter) {
|
|
708
709
|
const parts = [];
|
|
709
710
|
if ((parameter.in === "path" || parameter.in === "query") && parameter.style) parts.push(`style: '${parameter.style}'`);
|
|
710
711
|
if (parameter.explode !== void 0) parts.push(`explode: ${parameter.explode}`);
|
|
711
712
|
if (parameter.in === "query" && parameter.allowReserved !== void 0) parts.push(`allowReserved: ${parameter.allowReserved}`);
|
|
713
|
+
if (parameter.in !== "path" && parameter.contentType) parts.push(`contentType: '${parameter.contentType}'`);
|
|
712
714
|
return parts.length > 0 ? `{ ${parts.join(", ")} }` : null;
|
|
713
715
|
}
|
|
714
716
|
/**
|
|
715
717
|
* Builds the per-operation `styles` literal from the operation's parameters, grouped by location.
|
|
716
718
|
* Path entries are keyed by the camelCased name to match the URL template placeholders; query,
|
|
717
719
|
* header, and cookie entries keep the spec name to match the keys the runtime serializes.
|
|
718
|
-
* Only parameters whose source defines `style`, `explode`, or `
|
|
719
|
-
* serialization metadata keep the runtime defaults and existing output
|
|
720
|
-
* when no parameter carries metadata.
|
|
720
|
+
* Only parameters whose source defines `style`, `explode`, `allowReserved`, or `contentType` are
|
|
721
|
+
* emitted, so calls without serialization metadata keep the runtime defaults and existing output
|
|
722
|
+
* is unchanged. Returns `null` when no parameter carries metadata.
|
|
721
723
|
*
|
|
722
724
|
* @example
|
|
723
725
|
* ```ts
|
|
@@ -1415,7 +1417,7 @@ var compatibility = {
|
|
|
1415
1417
|
};
|
|
1416
1418
|
//#endregion
|
|
1417
1419
|
//#region package.json
|
|
1418
|
-
var version = "5.7.
|
|
1420
|
+
var version = "5.7.2";
|
|
1419
1421
|
//#endregion
|
|
1420
1422
|
//#region src/templates.ts
|
|
1421
1423
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
@@ -1489,32 +1491,6 @@ const pluginFetch = defineExtension({
|
|
|
1489
1491
|
} : void 0,
|
|
1490
1492
|
resolver: userResolver ? Resolver.merge(resolverClient, userResolver) : resolverClient
|
|
1491
1493
|
};
|
|
1492
|
-
const allowedReturnTypes = [
|
|
1493
|
-
"full",
|
|
1494
|
-
"data",
|
|
1495
|
-
"plain"
|
|
1496
|
-
];
|
|
1497
|
-
assertPluginOption({
|
|
1498
|
-
plugin: pluginFetchName,
|
|
1499
|
-
option: "returnType",
|
|
1500
|
-
value: returnType,
|
|
1501
|
-
allowed: allowedReturnTypes
|
|
1502
|
-
});
|
|
1503
|
-
for (const [index, entry] of override.entries()) {
|
|
1504
|
-
if (entry.options.returnType === void 0) continue;
|
|
1505
|
-
assertPluginOption({
|
|
1506
|
-
plugin: pluginFetchName,
|
|
1507
|
-
option: `override[${index}].options.returnType`,
|
|
1508
|
-
value: entry.options.returnType,
|
|
1509
|
-
allowed: allowedReturnTypes
|
|
1510
|
-
});
|
|
1511
|
-
}
|
|
1512
|
-
if (resolved.sdk) assertPluginOption({
|
|
1513
|
-
plugin: pluginFetchName,
|
|
1514
|
-
option: "sdk.mode",
|
|
1515
|
-
value: resolved.sdk.mode,
|
|
1516
|
-
allowed: ["tag", "flat"]
|
|
1517
|
-
});
|
|
1518
1494
|
setResolver(resolved.resolver);
|
|
1519
1495
|
setMacros([...defaultMacros, ...options.macros ?? []]);
|
|
1520
1496
|
addGenerator(resolved.sdk ? createSdkGenerator() : clientGenerator);
|