react-query-lightbase-codegen 3.1.3 → 3.1.4
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 +11 -0
- package/package.json +1 -1
- package/src/utils.ts +11 -0
package/dist/utils.js
CHANGED
|
@@ -211,6 +211,17 @@ function getTypeFromSchema(schema) {
|
|
|
211
211
|
}
|
|
212
212
|
// Handle types based on the "type" property
|
|
213
213
|
if ("type" in schema) {
|
|
214
|
+
// OpenAPI 3.1 supports type as an array, e.g. ["string", "null"]
|
|
215
|
+
if (Array.isArray(schema.type)) {
|
|
216
|
+
const types = schema.type.filter((t) => t !== "null");
|
|
217
|
+
const hasNull = schema.type.includes("null");
|
|
218
|
+
const nullSuffix = hasNull ? " | null" : "";
|
|
219
|
+
if (types.length === 0)
|
|
220
|
+
return `unknown${nullable}`;
|
|
221
|
+
// Resolve each type individually by recursing with a single-type schema
|
|
222
|
+
const resolved = types.map((t) => getTypeFromSchema({ ...schema, type: t }));
|
|
223
|
+
return resolved.filter(Boolean).join(" | ") + nullSuffix + nullable;
|
|
224
|
+
}
|
|
214
225
|
switch (schema.type) {
|
|
215
226
|
case "string":
|
|
216
227
|
// Special case for binary format strings
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -239,6 +239,17 @@ export function getTypeFromSchema(
|
|
|
239
239
|
|
|
240
240
|
// Handle types based on the "type" property
|
|
241
241
|
if ("type" in schema) {
|
|
242
|
+
// OpenAPI 3.1 supports type as an array, e.g. ["string", "null"]
|
|
243
|
+
if (Array.isArray(schema.type)) {
|
|
244
|
+
const types = (schema.type as string[]).filter((t) => t !== "null");
|
|
245
|
+
const hasNull = (schema.type as string[]).includes("null");
|
|
246
|
+
const nullSuffix = hasNull ? " | null" : "";
|
|
247
|
+
if (types.length === 0) return `unknown${nullable}`;
|
|
248
|
+
// Resolve each type individually by recursing with a single-type schema
|
|
249
|
+
const resolved = types.map((t) => getTypeFromSchema({ ...schema, type: t } as OpenAPIV3.SchemaObject));
|
|
250
|
+
return resolved.filter(Boolean).join(" | ") + nullSuffix + nullable;
|
|
251
|
+
}
|
|
252
|
+
|
|
242
253
|
switch (schema.type) {
|
|
243
254
|
case "string":
|
|
244
255
|
// Special case for binary format strings
|