@sebspark/openapi-typegen 1.6.0 → 1.7.0
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 +14 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -257,7 +257,10 @@ var generateDiscriminator = (discriminator, name) => {
|
|
|
257
257
|
};
|
|
258
258
|
var generateArray = (parsed) => {
|
|
259
259
|
const lines = [];
|
|
260
|
-
|
|
260
|
+
let items = generateType(parsed.items);
|
|
261
|
+
if (parsed.items.type === "enum") {
|
|
262
|
+
items = `(${items})`;
|
|
263
|
+
}
|
|
261
264
|
lines.push(`${preamble(parsed)}${items}[]`);
|
|
262
265
|
return lines.join("\n");
|
|
263
266
|
};
|
|
@@ -595,12 +598,12 @@ var parseObjectSchema = (name, schema) => {
|
|
|
595
598
|
return type;
|
|
596
599
|
};
|
|
597
600
|
var parseArraySchema = (name, schema) => {
|
|
598
|
-
if (schema.type !== "array"
|
|
601
|
+
if (schema.type !== "array")
|
|
599
602
|
throw new Error("Not an array");
|
|
600
603
|
return {
|
|
601
604
|
name,
|
|
602
605
|
type: "array",
|
|
603
|
-
items: parsePropertyType(schema.items)[0],
|
|
606
|
+
items: schema.items ? parsePropertyType(schema.items)[0] : { type: "unknown" },
|
|
604
607
|
...parseDocumentation(schema)
|
|
605
608
|
};
|
|
606
609
|
};
|
|
@@ -619,6 +622,14 @@ var parsePropertyType = (property) => {
|
|
|
619
622
|
return [{ type: parseRef(ref) }];
|
|
620
623
|
}
|
|
621
624
|
const schemaObject = property;
|
|
625
|
+
if (schemaObject.enum) {
|
|
626
|
+
const enumType = {
|
|
627
|
+
type: "enum",
|
|
628
|
+
values: schemaObject.enum,
|
|
629
|
+
...parseDocumentation(schemaObject)
|
|
630
|
+
};
|
|
631
|
+
return [enumType];
|
|
632
|
+
}
|
|
622
633
|
if (schemaObject.type) {
|
|
623
634
|
return (Array.isArray(schemaObject.type) ? schemaObject.type : [schemaObject.type]).map((type) => {
|
|
624
635
|
switch (type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/openapi-typegen",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"chalk": "<5",
|
|
29
29
|
"change-case": "4.1.2",
|
|
30
30
|
"prettier": "3.2.5",
|
|
31
|
-
"yaml": "2.
|
|
31
|
+
"yaml": "2.4.0",
|
|
32
32
|
"yargs": "17.7.2",
|
|
33
33
|
"yarn": "1.22.21"
|
|
34
34
|
}
|