ng-openapi 0.2.5 → 0.2.7
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/cli.cjs +17 -3
- package/index.js +16 -2
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var fs4 = __toESM(require("fs"));
|
|
|
44
44
|
var path12 = __toESM(require("path"));
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.2.
|
|
47
|
+
var version = "0.2.6";
|
|
48
48
|
|
|
49
49
|
// src/lib/core/generator.ts
|
|
50
50
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -82,7 +82,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
82
82
|
}
|
|
83
83
|
if (schema.type === "array") {
|
|
84
84
|
const itemType = schema.items ? getTypeScriptType(schema.items, config, void 0, void 0, context) : "unknown";
|
|
85
|
-
return nullable ? `(
|
|
85
|
+
return nullable ? `(Array<${itemType}> | null)` : `Array<${itemType}>`;
|
|
86
86
|
}
|
|
87
87
|
switch (schema.type) {
|
|
88
88
|
case "string":
|
|
@@ -618,6 +618,8 @@ var TypeGenerator = class {
|
|
|
618
618
|
this.collectEnumStructure(interfaceName, definition);
|
|
619
619
|
} else if (definition.allOf) {
|
|
620
620
|
this.collectCompositeTypeStructure(interfaceName, definition);
|
|
621
|
+
} else if (definition.items) {
|
|
622
|
+
this.collectArrayTypeStructure(interfaceName, definition);
|
|
621
623
|
} else {
|
|
622
624
|
this.collectInterfaceStructure(interfaceName, definition);
|
|
623
625
|
}
|
|
@@ -725,6 +727,18 @@ var TypeGenerator = class {
|
|
|
725
727
|
] : void 0
|
|
726
728
|
});
|
|
727
729
|
}
|
|
730
|
+
collectArrayTypeStructure(name, definition) {
|
|
731
|
+
const itemType = definition.items ? this.getArrayItemType(definition.items) : "unknown";
|
|
732
|
+
this.statements.push({
|
|
733
|
+
kind: import_ts_morph.StructureKind.TypeAlias,
|
|
734
|
+
name,
|
|
735
|
+
isExported: true,
|
|
736
|
+
docs: definition.description ? [
|
|
737
|
+
definition.description
|
|
738
|
+
] : void 0,
|
|
739
|
+
type: `Array<${itemType}>`
|
|
740
|
+
});
|
|
741
|
+
}
|
|
728
742
|
collectInterfaceStructure(name, definition) {
|
|
729
743
|
const properties = this.buildInterfaceProperties(definition);
|
|
730
744
|
this.statements.push({
|
|
@@ -815,7 +829,7 @@ var TypeGenerator = class {
|
|
|
815
829
|
}
|
|
816
830
|
if (schema.type === "array") {
|
|
817
831
|
const itemType = schema.items ? this.getArrayItemType(schema.items) : "unknown";
|
|
818
|
-
return
|
|
832
|
+
return `Array<${itemType}>`;
|
|
819
833
|
}
|
|
820
834
|
if (schema.type === "object") {
|
|
821
835
|
if (schema.properties) {
|
package/index.js
CHANGED
|
@@ -152,7 +152,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
152
152
|
}
|
|
153
153
|
if (schema.type === "array") {
|
|
154
154
|
const itemType = schema.items ? getTypeScriptType(schema.items, config, void 0, void 0, context) : "unknown";
|
|
155
|
-
return nullable ? `(
|
|
155
|
+
return nullable ? `(Array<${itemType}> | null)` : `Array<${itemType}>`;
|
|
156
156
|
}
|
|
157
157
|
switch (schema.type) {
|
|
158
158
|
case "string":
|
|
@@ -734,6 +734,8 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
734
734
|
this.collectEnumStructure(interfaceName, definition);
|
|
735
735
|
} else if (definition.allOf) {
|
|
736
736
|
this.collectCompositeTypeStructure(interfaceName, definition);
|
|
737
|
+
} else if (definition.items) {
|
|
738
|
+
this.collectArrayTypeStructure(interfaceName, definition);
|
|
737
739
|
} else {
|
|
738
740
|
this.collectInterfaceStructure(interfaceName, definition);
|
|
739
741
|
}
|
|
@@ -845,6 +847,18 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
845
847
|
] : void 0
|
|
846
848
|
});
|
|
847
849
|
}
|
|
850
|
+
collectArrayTypeStructure(name, definition) {
|
|
851
|
+
const itemType = definition.items ? this.getArrayItemType(definition.items) : "unknown";
|
|
852
|
+
this.statements.push({
|
|
853
|
+
kind: import_ts_morph.StructureKind.TypeAlias,
|
|
854
|
+
name,
|
|
855
|
+
isExported: true,
|
|
856
|
+
docs: definition.description ? [
|
|
857
|
+
definition.description
|
|
858
|
+
] : void 0,
|
|
859
|
+
type: `Array<${itemType}>`
|
|
860
|
+
});
|
|
861
|
+
}
|
|
848
862
|
collectInterfaceStructure(name, definition) {
|
|
849
863
|
const properties = this.buildInterfaceProperties(definition);
|
|
850
864
|
this.statements.push({
|
|
@@ -936,7 +950,7 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
936
950
|
}
|
|
937
951
|
if (schema.type === "array") {
|
|
938
952
|
const itemType = schema.items ? this.getArrayItemType(schema.items) : "unknown";
|
|
939
|
-
return
|
|
953
|
+
return `Array<${itemType}>`;
|
|
940
954
|
}
|
|
941
955
|
if (schema.type === "object") {
|
|
942
956
|
if (schema.properties) {
|