api-sdk-gen 1.0.1 → 1.0.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/index.js +8 -9
- package/dist/index.mjs +8 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,22 +18,16 @@ function schemaToTypeLiteral(schema, doc, refPrefix) {
|
|
|
18
18
|
return (writer) => {
|
|
19
19
|
if ("$ref" in schema) {
|
|
20
20
|
writer.write((refPrefix ?? "") + resolveSchema(schema.$ref));
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (schema.enum) {
|
|
21
|
+
} else if (schema.enum) {
|
|
24
22
|
writer.write(schema.enum.map((value) => JSON.stringify(value)).join(" | "));
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
if (schema.anyOf || schema.oneOf) {
|
|
23
|
+
} else if (schema.anyOf || schema.oneOf) {
|
|
28
24
|
(schema.anyOf || schema.oneOf)?.forEach((subSchema, index) => {
|
|
29
25
|
if (index > 0) {
|
|
30
26
|
writer.write(" | ");
|
|
31
27
|
}
|
|
32
28
|
schemaToTypeLiteral(subSchema, doc, refPrefix)(writer);
|
|
33
29
|
});
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
if (schema.type) {
|
|
30
|
+
} else if (schema.type) {
|
|
37
31
|
switch (schema.type) {
|
|
38
32
|
case "object": {
|
|
39
33
|
const requiredProps = new Set(schema.required || []);
|
|
@@ -91,6 +85,11 @@ function schemaToTypeLiteral(schema, doc, refPrefix) {
|
|
|
91
85
|
default:
|
|
92
86
|
writer.write("any");
|
|
93
87
|
}
|
|
88
|
+
} else {
|
|
89
|
+
writer.write("unknown");
|
|
90
|
+
}
|
|
91
|
+
if ("nullable" in schema && schema.nullable) {
|
|
92
|
+
writer.write(" | null");
|
|
94
93
|
}
|
|
95
94
|
};
|
|
96
95
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -24,22 +24,16 @@ function schemaToTypeLiteral(schema, doc, refPrefix) {
|
|
|
24
24
|
return (writer) => {
|
|
25
25
|
if ("$ref" in schema) {
|
|
26
26
|
writer.write((refPrefix ?? "") + resolveSchema(schema.$ref));
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (schema.enum) {
|
|
27
|
+
} else if (schema.enum) {
|
|
30
28
|
writer.write(schema.enum.map((value) => JSON.stringify(value)).join(" | "));
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
if (schema.anyOf || schema.oneOf) {
|
|
29
|
+
} else if (schema.anyOf || schema.oneOf) {
|
|
34
30
|
(schema.anyOf || schema.oneOf)?.forEach((subSchema, index) => {
|
|
35
31
|
if (index > 0) {
|
|
36
32
|
writer.write(" | ");
|
|
37
33
|
}
|
|
38
34
|
schemaToTypeLiteral(subSchema, doc, refPrefix)(writer);
|
|
39
35
|
});
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if (schema.type) {
|
|
36
|
+
} else if (schema.type) {
|
|
43
37
|
switch (schema.type) {
|
|
44
38
|
case "object": {
|
|
45
39
|
const requiredProps = new Set(schema.required || []);
|
|
@@ -97,6 +91,11 @@ function schemaToTypeLiteral(schema, doc, refPrefix) {
|
|
|
97
91
|
default:
|
|
98
92
|
writer.write("any");
|
|
99
93
|
}
|
|
94
|
+
} else {
|
|
95
|
+
writer.write("unknown");
|
|
96
|
+
}
|
|
97
|
+
if ("nullable" in schema && schema.nullable) {
|
|
98
|
+
writer.write(" | null");
|
|
100
99
|
}
|
|
101
100
|
};
|
|
102
101
|
}
|