react-query-lightbase-codegen 2.5.4 → 2.5.6

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.
@@ -69,14 +69,15 @@ function generateAxiosMethod(operation, spec) {
69
69
  const responseType = responseDetails?.[0] && "content" in responseDetails[1]
70
70
  ? `T.${`${namedType}Response${responseDetails[0]}`}`
71
71
  : "unknown";
72
- const urlWithParams = urlParams.length > 0 ? `\`${path.replace(/{(\w+)}/g, "encodeURIComponent(data.$1)")}\`` : `"${path}"`;
72
+ const urlWithParams = urlParams.length > 0 ? `\`${path.replace(/{(\w+)}/g, "${encodeURIComponent(data.$1)}")}\`` : `"${path}"`;
73
73
  const methodBody = [
74
74
  `${hasData ? "const { axiosConfig = {}, ...data } = props || {};" : "const { axiosConfig } = props || {};"}`,
75
75
  "const apiClient = getApiClient();",
76
76
  `const url = ${urlWithParams};`,
77
77
  queryParams.length > 0
78
- ? `const queryData = new URLSearchParams();
79
- ${queryParams.map((p) => `queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));`).join("\n ")}`
78
+ ? `const queryData = {
79
+ ${queryParams.map((p) => `["${p.name}"]: data["${p.name}"]`).join(",\n ")}
80
+ };`
80
81
  : "",
81
82
  requestBodySchema?.properties
82
83
  ? `const bodyData = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "license": "MIT",
5
5
  "description": "Generate Axios API clients and React Query options from OpenAPI specifications",
6
6
  "exports": "./dist/index.js",
@@ -101,15 +101,16 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
101
101
  : "unknown";
102
102
 
103
103
  const urlWithParams =
104
- urlParams.length > 0 ? `\`${path.replace(/{(\w+)}/g, "encodeURIComponent(data.$1)")}\`` : `"${path}"`;
104
+ urlParams.length > 0 ? `\`${path.replace(/{(\w+)}/g, "${encodeURIComponent(data.$1)}")}\`` : `"${path}"`;
105
105
 
106
106
  const methodBody = [
107
107
  `${hasData ? "const { axiosConfig = {}, ...data } = props || {};" : "const { axiosConfig } = props || {};"}`,
108
108
  "const apiClient = getApiClient();",
109
109
  `const url = ${urlWithParams};`,
110
110
  queryParams.length > 0
111
- ? `const queryData = new URLSearchParams();
112
- ${queryParams.map((p) => `queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));`).join("\n ")}`
111
+ ? `const queryData = {
112
+ ${queryParams.map((p) => `["${p.name}"]: data["${p.name}"]`).join(",\n ")}
113
+ };`
113
114
  : "",
114
115
  requestBodySchema?.properties
115
116
  ? `const bodyData = {