react-query-lightbase-codegen 2.3.1 → 2.3.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.
package/dist/utils.js CHANGED
@@ -83,6 +83,11 @@ function getTypeFromSchema(schema) {
83
83
  const nullable = "nullable" in schema && schema.nullable ? " | null" : "";
84
84
  // Handle enums as union types
85
85
  if ("enum" in schema && schema.enum) {
86
+ if (Object.values(schema.enum)?.length > 0) {
87
+ return (Object.values(schema.enum)
88
+ .map((e) => (typeof e === "string" ? `'${e}'` : e))
89
+ .join(" | ") + nullable);
90
+ }
86
91
  return schema.enum.map((e) => (typeof e === "string" ? `'${e}'` : e)).join(" | ") + nullable;
87
92
  }
88
93
  // Handle types based on the "type" property
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.3.1",
3
+ "version": "2.3.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",
package/src/utils.ts CHANGED
@@ -85,6 +85,13 @@ export function getTypeFromSchema(
85
85
 
86
86
  // Handle enums as union types
87
87
  if ("enum" in schema && schema.enum) {
88
+ if (Object.values(schema.enum)?.length > 0) {
89
+ return (
90
+ Object.values(schema.enum)
91
+ .map((e) => (typeof e === "string" ? `'${e}'` : e))
92
+ .join(" | ") + nullable
93
+ );
94
+ }
88
95
  return schema.enum.map((e) => (typeof e === "string" ? `'${e}'` : e)).join(" | ") + nullable;
89
96
  }
90
97