ng-openapi 0.1.15 → 0.1.17
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 +6 -12
- package/index.js +5 -7
- 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.1.
|
|
47
|
+
var version = "0.1.16";
|
|
48
48
|
|
|
49
49
|
// src/lib/core/generator.ts
|
|
50
50
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -58,10 +58,6 @@ function pascalCase(str) {
|
|
|
58
58
|
return str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^./, (char) => char.toUpperCase());
|
|
59
59
|
}
|
|
60
60
|
__name(pascalCase, "pascalCase");
|
|
61
|
-
function screamingSnakeCase(str) {
|
|
62
|
-
return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toUpperCase();
|
|
63
|
-
}
|
|
64
|
-
__name(screamingSnakeCase, "screamingSnakeCase");
|
|
65
61
|
|
|
66
62
|
// ../shared/src/utils/type.utils.ts
|
|
67
63
|
function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, context = "type") {
|
|
@@ -115,7 +111,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
115
111
|
case "null":
|
|
116
112
|
return "null";
|
|
117
113
|
default:
|
|
118
|
-
return nullableType("
|
|
114
|
+
return nullableType("any", nullable);
|
|
119
115
|
}
|
|
120
116
|
}
|
|
121
117
|
__name(getTypeScriptType, "getTypeScriptType");
|
|
@@ -992,7 +988,6 @@ var TypeGenerator = class {
|
|
|
992
988
|
}
|
|
993
989
|
// Original helper methods
|
|
994
990
|
mapSwaggerTypeToTypeScript(type, format, isNullable) {
|
|
995
|
-
if (!type) return "unknown";
|
|
996
991
|
switch (type) {
|
|
997
992
|
case "string":
|
|
998
993
|
if (format === "date" || format === "date-time") {
|
|
@@ -1010,14 +1005,13 @@ var TypeGenerator = class {
|
|
|
1010
1005
|
case "boolean":
|
|
1011
1006
|
return this.nullableType("boolean", isNullable);
|
|
1012
1007
|
case "array":
|
|
1013
|
-
return this.nullableType("
|
|
1008
|
+
return this.nullableType("any[]", isNullable);
|
|
1014
1009
|
case "object":
|
|
1015
1010
|
return this.nullableType("Record<string, unknown>", isNullable);
|
|
1016
1011
|
case "null":
|
|
1017
1012
|
return this.nullableType("null", isNullable);
|
|
1018
1013
|
default:
|
|
1019
|
-
|
|
1020
|
-
return this.nullableType("unknown", isNullable);
|
|
1014
|
+
return this.nullableType("any", isNullable);
|
|
1021
1015
|
}
|
|
1022
1016
|
}
|
|
1023
1017
|
nullableType(type, isNullable) {
|
|
@@ -1035,8 +1029,8 @@ var TypeGenerator = class {
|
|
|
1035
1029
|
toEnumKey(value) {
|
|
1036
1030
|
const str = value.toString();
|
|
1037
1031
|
const hasLeadingMinus = str.startsWith("-");
|
|
1038
|
-
const
|
|
1039
|
-
return hasLeadingMinus ?
|
|
1032
|
+
const pascalCased = pascalCase(str);
|
|
1033
|
+
return hasLeadingMinus ? pascalCased.replace(/^([0-9])/, "_n$1") : pascalCased.replace(/^([0-9])/, "_$1");
|
|
1040
1034
|
}
|
|
1041
1035
|
getArrayItemType(items) {
|
|
1042
1036
|
if (Array.isArray(items)) {
|
package/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
178
178
|
case "null":
|
|
179
179
|
return "null";
|
|
180
180
|
default:
|
|
181
|
-
return nullableType("
|
|
181
|
+
return nullableType("any", nullable);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
__name(getTypeScriptType, "getTypeScriptType");
|
|
@@ -1107,7 +1107,6 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
// Original helper methods
|
|
1109
1109
|
mapSwaggerTypeToTypeScript(type, format, isNullable) {
|
|
1110
|
-
if (!type) return "unknown";
|
|
1111
1110
|
switch (type) {
|
|
1112
1111
|
case "string":
|
|
1113
1112
|
if (format === "date" || format === "date-time") {
|
|
@@ -1125,14 +1124,13 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
1125
1124
|
case "boolean":
|
|
1126
1125
|
return this.nullableType("boolean", isNullable);
|
|
1127
1126
|
case "array":
|
|
1128
|
-
return this.nullableType("
|
|
1127
|
+
return this.nullableType("any[]", isNullable);
|
|
1129
1128
|
case "object":
|
|
1130
1129
|
return this.nullableType("Record<string, unknown>", isNullable);
|
|
1131
1130
|
case "null":
|
|
1132
1131
|
return this.nullableType("null", isNullable);
|
|
1133
1132
|
default:
|
|
1134
|
-
|
|
1135
|
-
return this.nullableType("unknown", isNullable);
|
|
1133
|
+
return this.nullableType("any", isNullable);
|
|
1136
1134
|
}
|
|
1137
1135
|
}
|
|
1138
1136
|
nullableType(type, isNullable) {
|
|
@@ -1150,8 +1148,8 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
1150
1148
|
toEnumKey(value) {
|
|
1151
1149
|
const str = value.toString();
|
|
1152
1150
|
const hasLeadingMinus = str.startsWith("-");
|
|
1153
|
-
const
|
|
1154
|
-
return hasLeadingMinus ?
|
|
1151
|
+
const pascalCased = pascalCase(str);
|
|
1152
|
+
return hasLeadingMinus ? pascalCased.replace(/^([0-9])/, "_n$1") : pascalCased.replace(/^([0-9])/, "_$1");
|
|
1155
1153
|
}
|
|
1156
1154
|
getArrayItemType(items) {
|
|
1157
1155
|
if (Array.isArray(items)) {
|