react-query-lightbase-codegen 2.5.0 → 2.5.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.
@@ -105,7 +105,7 @@ function generateAxiosMethod(operation, spec) {
105
105
  ? "axiosConfig.headers = { ...axiosConfig.headers, 'Content-Type': 'multipart/form-data' };"
106
106
  : "",
107
107
  requestBody
108
- ? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties ? "bodyData" : "data"}, axiosConfig);`
108
+ ? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties || requestBodySchema?.properties ? "bodyData" : "data"}, axiosConfig);`
109
109
  : `const res = await apiClient.${method}<${responseType}>(url, axiosConfig);`,
110
110
  "return res.data;",
111
111
  ]
package/dist/utils.js CHANGED
@@ -52,7 +52,11 @@ function sanitizeTypeName(name) {
52
52
  return pascalCase(name.replace(/[^a-zA-Z0-9_]/g, "_").replace(/_+$/, ""));
53
53
  }
54
54
  function specTitle(spec) {
55
- return camelCase(spec.info.title.toLowerCase().replace(/\s+/g, "-"));
55
+ const title = spec.info.title ?? "openAPi";
56
+ if (!spec.info.title) {
57
+ console.warn("No title found in OpenAPI spec, using 'openAPi' as default");
58
+ }
59
+ return camelCase(title.toLowerCase().replace(/\s+/g, "-"));
56
60
  }
57
61
  /**
58
62
  * Converts an OpenAPI schema object into a TypeScript type string.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "license": "MIT",
5
5
  "description": "Generate Axios API clients and React Query options from OpenAPI specifications",
6
6
  "exports": "./dist/index.js",
@@ -137,7 +137,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
137
137
  ? "axiosConfig.headers = { ...axiosConfig.headers, 'Content-Type': 'multipart/form-data' };"
138
138
  : "",
139
139
  requestBody
140
- ? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties ? "bodyData" : "data"}, axiosConfig);`
140
+ ? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties || requestBodySchema?.properties ? "bodyData" : "data"}, axiosConfig);`
141
141
  : `const res = await apiClient.${method}<${responseType}>(url, axiosConfig);`,
142
142
  "return res.data;",
143
143
  ]
package/src/utils.ts CHANGED
@@ -50,7 +50,11 @@ export function sanitizeTypeName(name: string): string {
50
50
  }
51
51
 
52
52
  export function specTitle(spec: OpenAPIV3.Document): string {
53
- return camelCase(spec.info.title.toLowerCase().replace(/\s+/g, "-"));
53
+ const title = spec.info.title ?? "openAPi";
54
+ if (!spec.info.title) {
55
+ console.warn("No title found in OpenAPI spec, using 'openAPi' as default");
56
+ }
57
+ return camelCase(title.toLowerCase().replace(/\s+/g, "-"));
54
58
  }
55
59
 
56
60
  /**