@kubb/plugin-zod 5.8.1 → 5.8.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 +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,22 @@ function resolveContentTypeVariants(entries, baseName) {
|
|
|
56
56
|
}
|
|
57
57
|
const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
58
58
|
/**
|
|
59
|
+
* An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
|
|
60
|
+
* per property, typed and serialized like any other.
|
|
61
|
+
* Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
|
|
62
|
+
*/
|
|
63
|
+
function spreadQuerystring(param) {
|
|
64
|
+
const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
|
|
65
|
+
const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
|
|
66
|
+
if (schema?.type !== "object" || !formEncoded) return [param];
|
|
67
|
+
return schema.properties.map((property) => _kubb_kit.ast.factory.createParameter({
|
|
68
|
+
name: property.name,
|
|
69
|
+
in: "query",
|
|
70
|
+
schema: property.schema,
|
|
71
|
+
required: param.required && property.required
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
59
75
|
* Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
|
|
60
76
|
* group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
|
|
61
77
|
* (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
|
|
@@ -64,17 +80,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
|
64
80
|
function getOperationParameters(node) {
|
|
65
81
|
const cached = operationParameterGroupsByNode.get(node);
|
|
66
82
|
if (cached) return cached;
|
|
67
|
-
const
|
|
83
|
+
const dedupe = (params) => {
|
|
68
84
|
const seen = /* @__PURE__ */ new Set();
|
|
69
|
-
return
|
|
70
|
-
if (
|
|
85
|
+
return params.filter((param) => {
|
|
86
|
+
if (seen.has(param.name)) return false;
|
|
71
87
|
seen.add(param.name);
|
|
72
88
|
return true;
|
|
73
89
|
});
|
|
74
90
|
};
|
|
91
|
+
const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
|
|
75
92
|
const groups = {
|
|
76
93
|
path: group("path"),
|
|
77
|
-
query: group("query"),
|
|
94
|
+
query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
|
|
78
95
|
header: group("header"),
|
|
79
96
|
cookie: group("cookie")
|
|
80
97
|
};
|
|
@@ -2168,11 +2185,11 @@ const zodGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
2168
2185
|
});
|
|
2169
2186
|
// kubb-extension.json
|
|
2170
2187
|
var compatibility = {
|
|
2171
|
-
"kubb": ">=5.
|
|
2188
|
+
"kubb": ">=5.16.0",
|
|
2172
2189
|
"node": ">=22.22"
|
|
2173
2190
|
};
|
|
2174
2191
|
// package.json
|
|
2175
|
-
var version = "5.8.
|
|
2192
|
+
var version = "5.8.2";
|
|
2176
2193
|
// src/resolvers/resolverZod.ts
|
|
2177
2194
|
/**
|
|
2178
2195
|
* Default resolver used by `@kubb/plugin-zod`. Decides the names and file
|