@kubb/plugin-ts 5.4.0 → 5.4.1
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 +5 -5
package/dist/index.js
CHANGED
|
@@ -879,6 +879,22 @@ function resolveContentTypeVariants(entries, baseName) {
|
|
|
879
879
|
}
|
|
880
880
|
const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
881
881
|
/**
|
|
882
|
+
* An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
|
|
883
|
+
* per property, typed and serialized like any other.
|
|
884
|
+
* Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
|
|
885
|
+
*/
|
|
886
|
+
function spreadQuerystring(param) {
|
|
887
|
+
const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
|
|
888
|
+
const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
|
|
889
|
+
if (schema?.type !== "object" || !formEncoded) return [param];
|
|
890
|
+
return schema.properties.map((property) => ast.factory.createParameter({
|
|
891
|
+
name: property.name,
|
|
892
|
+
in: "query",
|
|
893
|
+
schema: property.schema,
|
|
894
|
+
required: param.required && property.required
|
|
895
|
+
}));
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
882
898
|
* Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
|
|
883
899
|
* group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
|
|
884
900
|
* (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
|
|
@@ -887,17 +903,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
|
887
903
|
function getOperationParameters(node) {
|
|
888
904
|
const cached = operationParameterGroupsByNode.get(node);
|
|
889
905
|
if (cached) return cached;
|
|
890
|
-
const
|
|
906
|
+
const dedupe = (params) => {
|
|
891
907
|
const seen = /* @__PURE__ */ new Set();
|
|
892
|
-
return
|
|
893
|
-
if (
|
|
908
|
+
return params.filter((param) => {
|
|
909
|
+
if (seen.has(param.name)) return false;
|
|
894
910
|
seen.add(param.name);
|
|
895
911
|
return true;
|
|
896
912
|
});
|
|
897
913
|
};
|
|
914
|
+
const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
|
|
898
915
|
const groups = {
|
|
899
916
|
path: group("path"),
|
|
900
|
-
query: group("query"),
|
|
917
|
+
query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
|
|
901
918
|
header: group("header"),
|
|
902
919
|
cookie: group("cookie")
|
|
903
920
|
};
|
|
@@ -1902,11 +1919,11 @@ const typeGenerator = defineGenerator({
|
|
|
1902
1919
|
});
|
|
1903
1920
|
// kubb-extension.json
|
|
1904
1921
|
var compatibility = {
|
|
1905
|
-
"kubb": ">=5.
|
|
1922
|
+
"kubb": ">=5.16.0",
|
|
1906
1923
|
"node": ">=22.22"
|
|
1907
1924
|
};
|
|
1908
1925
|
// package.json
|
|
1909
|
-
var version = "5.4.
|
|
1926
|
+
var version = "5.4.1";
|
|
1910
1927
|
// src/resolvers/resolverTs.ts
|
|
1911
1928
|
/**
|
|
1912
1929
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|