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