react-query-lightbase-codegen 2.5.6 → 2.5.8

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.
@@ -51,6 +51,7 @@ function generateAxiosMethod(operation, spec) {
51
51
  jsDocLines.push(" */");
52
52
  const urlParams = parameters?.filter((p) => p.in === "path") || [];
53
53
  const queryParams = parameters?.filter((p) => p.in === "query") || [];
54
+ const headerParams = parameters?.filter((p) => p.in === "header") || [];
54
55
  const isFormData = requestBody && "content" in requestBody && requestBody.content?.["multipart/form-data"];
55
56
  const formDataSchema = isFormData
56
57
  ? resolveSchema(requestBody.content["multipart/form-data"].schema, spec)
@@ -104,6 +105,12 @@ function generateAxiosMethod(operation, spec) {
104
105
  isFormData
105
106
  ? "axiosConfig.headers = { ...axiosConfig.headers, 'Content-Type': 'multipart/form-data' };"
106
107
  : "",
108
+ headerParams.length > 0
109
+ ? `const headerData = {
110
+ ${headerParams.map((p) => `["${p.name}"]: data["${p.name}"]`).join(",\n ")}
111
+ };`
112
+ : "",
113
+ headerParams.length > 0 ? "axiosConfig.headers = { ...axiosConfig.headers, ...headerData };" : "",
107
114
  requestBody
108
115
  ? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties || requestBodySchema?.properties ? "bodyData" : "data"}, axiosConfig);`
109
116
  : `const res = await apiClient.${method}<${responseType}>(url, axiosConfig);`,
@@ -72,6 +72,8 @@ function generateTypeDefinitions(spec) {
72
72
  []);
73
73
  const queryParams = (parameters?.filter((p) => "in" in p && p.in === "query") ||
74
74
  []);
75
+ const headerParams = (parameters?.filter((p) => "in" in p && p.in === "header") ||
76
+ []);
75
77
  // Add path and query parameters
76
78
  urlParams.forEach((p) => {
77
79
  const safeName = (0, utils_1.sanitizePropertyName)(p.name);
@@ -93,6 +95,16 @@ function generateTypeDefinitions(spec) {
93
95
  : "";
94
96
  dataProps.push(`${desc}${safeName}${p.required ? "" : "?"}: ${(0, utils_1.getTypeFromSchema)(p.schema)}`);
95
97
  });
98
+ headerParams.forEach((p) => {
99
+ const safeName = (0, utils_1.sanitizePropertyName)(p.name);
100
+ const isDeprecated = "deprecated" in p && p.deprecated;
101
+ const hasDescription = "description" in p && p.description;
102
+ const desc = hasDescription || isDeprecated
103
+ ? `\n/**${hasDescription ? `\n* ${p.description}` : ""}${isDeprecated ? "\n* @deprecated" : ""}
104
+ */\n`
105
+ : "";
106
+ dataProps.push(`${desc}${safeName}${p.required ? "" : "?"}: ${(0, utils_1.getTypeFromSchema)(p.schema)}`);
107
+ });
96
108
  // Add request body type if it exists
97
109
  const hasData = (parameters && parameters.length > 0) || requestBody;
98
110
  let dataType = "undefined";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.5.6",
3
+ "version": "2.5.8",
4
4
  "license": "MIT",
5
5
  "description": "Generate Axios API clients and React Query options from OpenAPI specifications",
6
6
  "exports": "./dist/index.js",
@@ -71,6 +71,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
71
71
 
72
72
  const urlParams = parameters?.filter((p) => p.in === "path") || [];
73
73
  const queryParams = parameters?.filter((p) => p.in === "query") || [];
74
+ const headerParams = parameters?.filter((p) => p.in === "header") || [];
74
75
 
75
76
  const isFormData = requestBody && "content" in requestBody && requestBody.content?.["multipart/form-data"];
76
77
 
@@ -112,6 +113,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
112
113
  ${queryParams.map((p) => `["${p.name}"]: data["${p.name}"]`).join(",\n ")}
113
114
  };`
114
115
  : "",
116
+
115
117
  requestBodySchema?.properties
116
118
  ? `const bodyData = {
117
119
  ${Object.entries(requestBodySchema.properties)
@@ -119,6 +121,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
119
121
  .join(",\n ")}
120
122
  };`
121
123
  : "",
124
+
122
125
  formDataSchema?.properties
123
126
  ? `const bodyData = new FormData();
124
127
  ${Object.entries(formDataSchema.properties)
@@ -137,6 +140,12 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
137
140
  isFormData
138
141
  ? "axiosConfig.headers = { ...axiosConfig.headers, 'Content-Type': 'multipart/form-data' };"
139
142
  : "",
143
+ headerParams.length > 0
144
+ ? `const headerData = {
145
+ ${headerParams.map((p) => `["${p.name}"]: data["${p.name}"]`).join(",\n ")}
146
+ };`
147
+ : "",
148
+ headerParams.length > 0 ? "axiosConfig.headers = { ...axiosConfig.headers, ...headerData };" : "",
140
149
  requestBody
141
150
  ? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties || requestBodySchema?.properties ? "bodyData" : "data"}, axiosConfig);`
142
151
  : `const res = await apiClient.${method}<${responseType}>(url, axiosConfig);`,
@@ -89,6 +89,8 @@ export function generateTypeDefinitions(spec: OpenAPIV3.Document): string {
89
89
  []) as OpenAPIV3.ParameterObject[];
90
90
  const queryParams = (parameters?.filter((p) => "in" in p && p.in === "query") ||
91
91
  []) as OpenAPIV3.ParameterObject[];
92
+ const headerParams = (parameters?.filter((p) => "in" in p && p.in === "header") ||
93
+ []) as OpenAPIV3.ParameterObject[];
92
94
 
93
95
  // Add path and query parameters
94
96
  urlParams.forEach((p) => {
@@ -114,6 +116,19 @@ export function generateTypeDefinitions(spec: OpenAPIV3.Document): string {
114
116
  : "";
115
117
  dataProps.push(`${desc}${safeName}${p.required ? "" : "?"}: ${getTypeFromSchema(p.schema)}`);
116
118
  });
119
+
120
+ headerParams.forEach((p) => {
121
+ const safeName = sanitizePropertyName(p.name);
122
+ const isDeprecated = "deprecated" in p && p.deprecated;
123
+ const hasDescription = "description" in p && p.description;
124
+ const desc =
125
+ hasDescription || isDeprecated
126
+ ? `\n/**${hasDescription ? `\n* ${p.description}` : ""}${isDeprecated ? "\n* @deprecated" : ""}
127
+ */\n`
128
+ : "";
129
+ dataProps.push(`${desc}${safeName}${p.required ? "" : "?"}: ${getTypeFromSchema(p.schema)}`);
130
+ });
131
+
117
132
  // Add request body type if it exists
118
133
  const hasData = (parameters && parameters.length > 0) || requestBody;
119
134