react-query-lightbase-codegen 3.1.1 → 3.1.3
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 +8 -6
- package/package.json +1 -1
- package/src/utils.ts +7 -8
package/dist/utils.js
CHANGED
|
@@ -200,12 +200,14 @@ function getTypeFromSchema(schema) {
|
|
|
200
200
|
}
|
|
201
201
|
// Handle enums as union types
|
|
202
202
|
if ("enum" in schema && schema.enum) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
203
|
+
// Filter out null/undefined enum values (some specs include null for nullable enums)
|
|
204
|
+
const enumValues = Object.values(schema.enum);
|
|
205
|
+
const hasNull = enumValues.some((e) => e === null);
|
|
206
|
+
const nullSuffix = hasNull ? " | null" : "";
|
|
207
|
+
const values = enumValues.filter((e) => e != null).map((e) => (typeof e === "string" ? `'${e}'` : e));
|
|
208
|
+
if (values.length === 0)
|
|
209
|
+
return `unknown${nullable}`;
|
|
210
|
+
return values.join(" | ") + nullSuffix + nullable;
|
|
209
211
|
}
|
|
210
212
|
// Handle types based on the "type" property
|
|
211
213
|
if ("type" in schema) {
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -228,14 +228,13 @@ export function getTypeFromSchema(
|
|
|
228
228
|
|
|
229
229
|
// Handle enums as union types
|
|
230
230
|
if ("enum" in schema && schema.enum) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return schema.enum.map((e) => (typeof e === "string" ? `'${e}'` : e)).join(" | ") + nullable;
|
|
231
|
+
// Filter out null/undefined enum values (some specs include null for nullable enums)
|
|
232
|
+
const enumValues = Object.values(schema.enum);
|
|
233
|
+
const hasNull = enumValues.some((e) => e === null);
|
|
234
|
+
const nullSuffix = hasNull ? " | null" : "";
|
|
235
|
+
const values = enumValues.filter((e) => e != null).map((e) => (typeof e === "string" ? `'${e}'` : e));
|
|
236
|
+
if (values.length === 0) return `unknown${nullable}`;
|
|
237
|
+
return values.join(" | ") + nullSuffix + nullable;
|
|
239
238
|
}
|
|
240
239
|
|
|
241
240
|
// Handle types based on the "type" property
|