react-query-lightbase-codegen 2.5.4 → 2.5.5

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,14 @@ 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
78
  ? `const queryData = new URLSearchParams();
79
- ${queryParams.map((p) => `queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));`).join("\n ")}`
79
+ ${queryParams.map((p) => `if (p.name) { queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));}`)}`
80
80
  : "",
81
81
  requestBodySchema?.properties
82
82
  ? `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.5",
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,7 +101,7 @@ 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 || {};"}`,
@@ -109,7 +109,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
109
109
  `const url = ${urlWithParams};`,
110
110
  queryParams.length > 0
111
111
  ? `const queryData = new URLSearchParams();
112
- ${queryParams.map((p) => `queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));`).join("\n ")}`
112
+ ${queryParams.map((p) => `if (p.name) { queryData.append("${p.name}", encodeURIComponent(data["${p.name}"]));}`)}`
113
113
  : "",
114
114
  requestBodySchema?.properties
115
115
  ? `const bodyData = {