react-query-lightbase-codegen 2.5.10 → 2.5.11

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.d.ts CHANGED
@@ -40,6 +40,7 @@ export declare function specTitle(spec: OpenAPIV3.Document): string;
40
40
  * - References ($ref) by extracting the type name
41
41
  * - Nullable types by appending "| null"
42
42
  * - Enums by creating union types of the values
43
+ * - OneOf schemas as union types
43
44
  * - Basic types (string, number, boolean)
44
45
  * - Binary format strings as a union with file metadata object
45
46
  * - Arrays by recursively getting the item type
package/dist/utils.js CHANGED
@@ -65,6 +65,7 @@ function specTitle(spec) {
65
65
  * - References ($ref) by extracting the type name
66
66
  * - Nullable types by appending "| null"
67
67
  * - Enums by creating union types of the values
68
+ * - OneOf schemas as union types
68
69
  * - Basic types (string, number, boolean)
69
70
  * - Binary format strings as a union with file metadata object
70
71
  * - Arrays by recursively getting the item type
@@ -94,6 +95,13 @@ function getTypeFromSchema(schema) {
94
95
  }
95
96
  return schema.enum.map((e) => (typeof e === "string" ? `'${e}'` : e)).join(" | ") + nullable;
96
97
  }
98
+ // Handle oneOf as union types
99
+ if ("oneOf" in schema && schema.oneOf) {
100
+ const unionTypes = schema.oneOf
101
+ .map((subSchema) => getTypeFromSchema(subSchema))
102
+ .filter((type) => type !== undefined);
103
+ return unionTypes.length > 0 ? `${unionTypes.join(" | ")}${nullable}` : `any${nullable}`;
104
+ }
97
105
  // Handle types based on the "type" property
98
106
  if ("type" in schema) {
99
107
  switch (schema.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.5.10",
3
+ "version": "2.5.11",
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
@@ -64,6 +64,7 @@ export function specTitle(spec: OpenAPIV3.Document): string {
64
64
  * - References ($ref) by extracting the type name
65
65
  * - Nullable types by appending "| null"
66
66
  * - Enums by creating union types of the values
67
+ * - OneOf schemas as union types
67
68
  * - Basic types (string, number, boolean)
68
69
  * - Binary format strings as a union with file metadata object
69
70
  * - Arrays by recursively getting the item type
@@ -99,6 +100,14 @@ export function getTypeFromSchema(
99
100
  return schema.enum.map((e) => (typeof e === "string" ? `'${e}'` : e)).join(" | ") + nullable;
100
101
  }
101
102
 
103
+ // Handle oneOf as union types
104
+ if ("oneOf" in schema && schema.oneOf) {
105
+ const unionTypes = schema.oneOf
106
+ .map((subSchema) => getTypeFromSchema(subSchema))
107
+ .filter((type): type is string => type !== undefined);
108
+ return unionTypes.length > 0 ? `${unionTypes.join(" | ")}${nullable}` : `any${nullable}`;
109
+ }
110
+
102
111
  // Handle types based on the "type" property
103
112
  if ("type" in schema) {
104
113
  switch (schema.type) {