react-query-lightbase-codegen 2.1.0 → 2.1.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.
@@ -127,9 +127,12 @@ function generateAxiosMethod(operation, spec) {
127
127
  ]
128
128
  .filter(Boolean)
129
129
  .join("\n ");
130
+ const requestParms = hasData
131
+ ? `props: ${dataType} & { axiosConfig?: AxiosRequestConfig; }`
132
+ : "props?: { axiosConfig?: AxiosRequestConfig }";
130
133
  return `
131
134
  ${jsDocLines.join("\n ")}
132
- export async function ${(0, utils_1.camelCase)(operationId)}(props: ${hasData ? `${dataType} & { axiosConfig?: AxiosRequestConfig; }` : "{ axiosConfig?: AxiosRequestConfig }"} ): Promise<${responseType}> {
135
+ export async function ${(0, utils_1.camelCase)(operationId)}(${requestParms}): Promise<${responseType}> {
133
136
  ${methodBody}
134
137
  }`;
135
138
  }
@@ -18,6 +18,9 @@ function getTypeFromSchema(schema, context) {
18
18
  }
19
19
  switch (schema.type) {
20
20
  case "string":
21
+ if ("format" in schema && schema.format === "binary") {
22
+ return "string | { name?: string; type?: string; uri: string }";
23
+ }
21
24
  return "string";
22
25
  case "number":
23
26
  case "integer":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.1.0",
3
+ "version": "2.1.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",
@@ -154,11 +154,13 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
154
154
  .filter(Boolean)
155
155
  .join("\n ");
156
156
 
157
+ const requestParms = hasData
158
+ ? `props: ${dataType} & { axiosConfig?: AxiosRequestConfig; }`
159
+ : "props?: { axiosConfig?: AxiosRequestConfig }";
160
+
157
161
  return `
158
162
  ${jsDocLines.join("\n ")}
159
- export async function ${camelCase(operationId)}(props: ${
160
- hasData ? `${dataType} & { axiosConfig?: AxiosRequestConfig; }` : "{ axiosConfig?: AxiosRequestConfig }"
161
- } ): Promise<${responseType}> {
163
+ export async function ${camelCase(operationId)}(${requestParms}): Promise<${responseType}> {
162
164
  ${methodBody}
163
165
  }`;
164
166
  }
@@ -1,5 +1,3 @@
1
- import type { OpenAPIV3 } from "openapi-types";
2
-
3
1
  export function generateInstance(): string {
4
2
  return `import type { AxiosInstance } from 'axios';
5
3
 
@@ -27,6 +27,9 @@ function getTypeFromSchema(
27
27
 
28
28
  switch (schema.type) {
29
29
  case "string":
30
+ if ("format" in schema && schema.format === "binary") {
31
+ return "string | { name?: string; type?: string; uri: string }";
32
+ }
30
33
  return "string";
31
34
  case "number":
32
35
  case "integer":