ng-openapi 0.2.10 → 0.2.12-pr-57-fix-missing-types-a3127fb.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/cli.cjs +7 -7
- package/index.d.ts +2 -1
- package/index.js +8 -6
- 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.11";
|
|
48
48
|
|
|
49
49
|
// src/lib/core/generator.ts
|
|
50
50
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -58,6 +58,10 @@ 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 pascalCaseForEnums(str) {
|
|
62
|
+
return str.replace(/[^a-zA-Z0-9]/g, "_").replace(/(?:^|_)([a-z])/g, (_, char) => char.toUpperCase()).replace(/^([0-9])/, "_$1");
|
|
63
|
+
}
|
|
64
|
+
__name(pascalCaseForEnums, "pascalCaseForEnums");
|
|
61
65
|
|
|
62
66
|
// ../shared/src/utils/type.utils.ts
|
|
63
67
|
function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, context = "type") {
|
|
@@ -78,7 +82,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
78
82
|
}
|
|
79
83
|
if (schema.$ref) {
|
|
80
84
|
const refName = schema.$ref.split("/").pop();
|
|
81
|
-
return nullableType(
|
|
85
|
+
return nullableType(pascalCaseForEnums(refName), nullable);
|
|
82
86
|
}
|
|
83
87
|
if (schema.type === "array") {
|
|
84
88
|
const itemType = schema.items ? getTypeScriptType(schema.items, config, void 0, void 0, context) : "unknown";
|
|
@@ -589,7 +593,6 @@ var TypeGenerator = class {
|
|
|
589
593
|
const definitions = this.parser.getDefinitions();
|
|
590
594
|
if (!definitions || Object.keys(definitions).length === 0) {
|
|
591
595
|
console.warn("No definitions found in swagger file");
|
|
592
|
-
return;
|
|
593
596
|
}
|
|
594
597
|
this.collectAllTypeStructures(definitions);
|
|
595
598
|
this.collectSdkTypes();
|
|
@@ -949,7 +952,7 @@ var TypeGenerator = class {
|
|
|
949
952
|
// Cached helper methods
|
|
950
953
|
getCachedPascalCase(str) {
|
|
951
954
|
if (!this.pascalCaseCache.has(str)) {
|
|
952
|
-
this.pascalCaseCache.set(str,
|
|
955
|
+
this.pascalCaseCache.set(str, pascalCaseForEnums(str));
|
|
953
956
|
}
|
|
954
957
|
return this.pascalCaseCache.get(str);
|
|
955
958
|
}
|
|
@@ -994,9 +997,6 @@ var TypeGenerator = class {
|
|
|
994
997
|
nullableType(type, isNullable) {
|
|
995
998
|
return type + (isNullable ? " | null" : "");
|
|
996
999
|
}
|
|
997
|
-
pascalCaseForEnums(str) {
|
|
998
|
-
return str.replace(/[^a-zA-Z0-9]/g, "_").replace(/(?:^|_)([a-z])/g, (_, char) => char.toUpperCase()).replace(/^([0-9])/, "_$1");
|
|
999
|
-
}
|
|
1000
1000
|
sanitizePropertyName(name) {
|
|
1001
1001
|
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
1002
1002
|
return `"${name}"`;
|
package/index.d.ts
CHANGED
|
@@ -224,6 +224,7 @@ declare function camelCase(str: string): string;
|
|
|
224
224
|
declare function kebabCase(str: string): string;
|
|
225
225
|
declare function pascalCase(str: string): string;
|
|
226
226
|
declare function screamingSnakeCase(str: string): string;
|
|
227
|
+
declare function pascalCaseForEnums(str: string): string;
|
|
227
228
|
|
|
228
229
|
/**
|
|
229
230
|
* Convert OpenAPI/Swagger types to TypeScript types
|
|
@@ -287,4 +288,4 @@ declare function validateInput(inputPath: string): void;
|
|
|
287
288
|
*/
|
|
288
289
|
declare function generateFromConfig(config: GeneratorConfig): Promise<void>;
|
|
289
290
|
|
|
290
|
-
export { BASE_INTERCEPTOR_HEADER_COMMENT, CONTENT_TYPES, type EnumValueObject, type GeneratorConfig, type GetMethodGenerationContext, HTTP_RESOURCE_GENERATOR_HEADER_COMMENT, type IPluginGenerator, type IPluginGeneratorClass, MAIN_INDEX_GENERATOR_HEADER_COMMENT, type MethodGenerationContext, type NgOpenapiClientConfig, PROVIDER_GENERATOR_HEADER_COMMENT, type Parameter, type PathInfo, type RequestBody, SERVICE_GENERATOR_HEADER_COMMENT, SERVICE_INDEX_GENERATOR_HEADER_COMMENT, type SwaggerDefinition, SwaggerParser, type SwaggerResponse, type SwaggerSpec, TYPE_GENERATOR_HEADER_COMMENT, type TypeSchema, ZOD_PLUGIN_GENERATOR_HEADER_COMMENT, ZOD_PLUGIN_INDEX_GENERATOR_HEADER_COMMENT, camelCase, escapeString, extractPaths, generateFromConfig, generateParseRequestTypeParams, getBasePathTokenName, getClientContextTokenName, getInterceptorsTokenName, getRequestBodyType, getResponseType, getResponseTypeFromResponse, getTypeScriptType, hasDuplicateFunctionNames, inferResponseTypeFromContentType, isDataTypeInterface, isPrimitiveType, kebabCase, nullableType, pascalCase, type placeHolder, screamingSnakeCase, validateInput };
|
|
291
|
+
export { BASE_INTERCEPTOR_HEADER_COMMENT, CONTENT_TYPES, type EnumValueObject, type GeneratorConfig, type GetMethodGenerationContext, HTTP_RESOURCE_GENERATOR_HEADER_COMMENT, type IPluginGenerator, type IPluginGeneratorClass, MAIN_INDEX_GENERATOR_HEADER_COMMENT, type MethodGenerationContext, type NgOpenapiClientConfig, PROVIDER_GENERATOR_HEADER_COMMENT, type Parameter, type PathInfo, type RequestBody, SERVICE_GENERATOR_HEADER_COMMENT, SERVICE_INDEX_GENERATOR_HEADER_COMMENT, type SwaggerDefinition, SwaggerParser, type SwaggerResponse, type SwaggerSpec, TYPE_GENERATOR_HEADER_COMMENT, type TypeSchema, ZOD_PLUGIN_GENERATOR_HEADER_COMMENT, ZOD_PLUGIN_INDEX_GENERATOR_HEADER_COMMENT, camelCase, escapeString, extractPaths, generateFromConfig, generateParseRequestTypeParams, getBasePathTokenName, getClientContextTokenName, getInterceptorsTokenName, getRequestBodyType, getResponseType, getResponseTypeFromResponse, getTypeScriptType, hasDuplicateFunctionNames, inferResponseTypeFromContentType, isDataTypeInterface, isPrimitiveType, kebabCase, nullableType, pascalCase, pascalCaseForEnums, type placeHolder, screamingSnakeCase, validateInput };
|
package/index.js
CHANGED
|
@@ -103,6 +103,7 @@ __export(index_exports, {
|
|
|
103
103
|
kebabCase: () => kebabCase,
|
|
104
104
|
nullableType: () => nullableType,
|
|
105
105
|
pascalCase: () => pascalCase,
|
|
106
|
+
pascalCaseForEnums: () => pascalCaseForEnums,
|
|
106
107
|
screamingSnakeCase: () => screamingSnakeCase,
|
|
107
108
|
validateInput: () => validateInput
|
|
108
109
|
});
|
|
@@ -128,6 +129,10 @@ function screamingSnakeCase(str) {
|
|
|
128
129
|
return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toUpperCase();
|
|
129
130
|
}
|
|
130
131
|
__name(screamingSnakeCase, "screamingSnakeCase");
|
|
132
|
+
function pascalCaseForEnums(str) {
|
|
133
|
+
return str.replace(/[^a-zA-Z0-9]/g, "_").replace(/(?:^|_)([a-z])/g, (_, char) => char.toUpperCase()).replace(/^([0-9])/, "_$1");
|
|
134
|
+
}
|
|
135
|
+
__name(pascalCaseForEnums, "pascalCaseForEnums");
|
|
131
136
|
|
|
132
137
|
// ../shared/src/utils/type.utils.ts
|
|
133
138
|
function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, context = "type") {
|
|
@@ -148,7 +153,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
148
153
|
}
|
|
149
154
|
if (schema.$ref) {
|
|
150
155
|
const refName = schema.$ref.split("/").pop();
|
|
151
|
-
return nullableType(
|
|
156
|
+
return nullableType(pascalCaseForEnums(refName), nullable);
|
|
152
157
|
}
|
|
153
158
|
if (schema.type === "array") {
|
|
154
159
|
const itemType = schema.items ? getTypeScriptType(schema.items, config, void 0, void 0, context) : "unknown";
|
|
@@ -703,7 +708,6 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
703
708
|
const definitions = this.parser.getDefinitions();
|
|
704
709
|
if (!definitions || Object.keys(definitions).length === 0) {
|
|
705
710
|
console.warn("No definitions found in swagger file");
|
|
706
|
-
return;
|
|
707
711
|
}
|
|
708
712
|
this.collectAllTypeStructures(definitions);
|
|
709
713
|
this.collectSdkTypes();
|
|
@@ -1074,7 +1078,7 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
1074
1078
|
// Cached helper methods
|
|
1075
1079
|
getCachedPascalCase(str) {
|
|
1076
1080
|
if (!this.pascalCaseCache.has(str)) {
|
|
1077
|
-
this.pascalCaseCache.set(str,
|
|
1081
|
+
this.pascalCaseCache.set(str, pascalCaseForEnums(str));
|
|
1078
1082
|
}
|
|
1079
1083
|
return this.pascalCaseCache.get(str);
|
|
1080
1084
|
}
|
|
@@ -1119,9 +1123,6 @@ var _TypeGenerator = class _TypeGenerator {
|
|
|
1119
1123
|
nullableType(type, isNullable) {
|
|
1120
1124
|
return type + (isNullable ? " | null" : "");
|
|
1121
1125
|
}
|
|
1122
|
-
pascalCaseForEnums(str) {
|
|
1123
|
-
return str.replace(/[^a-zA-Z0-9]/g, "_").replace(/(?:^|_)([a-z])/g, (_, char) => char.toUpperCase()).replace(/^([0-9])/, "_$1");
|
|
1124
|
-
}
|
|
1125
1126
|
sanitizePropertyName(name) {
|
|
1126
1127
|
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
1127
1128
|
return `"${name}"`;
|
|
@@ -3027,6 +3028,7 @@ __name(generateFromConfig, "generateFromConfig");
|
|
|
3027
3028
|
kebabCase,
|
|
3028
3029
|
nullableType,
|
|
3029
3030
|
pascalCase,
|
|
3031
|
+
pascalCaseForEnums,
|
|
3030
3032
|
screamingSnakeCase,
|
|
3031
3033
|
validateInput
|
|
3032
3034
|
});
|
package/package.json
CHANGED