react-query-lightbase-codegen 3.1.3 → 3.1.5

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