ng-openapi 0.2.10 → 0.2.11

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 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.9";
47
+ var version = "0.2.10";
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(pascalCase(refName), nullable);
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";
@@ -949,7 +953,7 @@ var TypeGenerator = class {
949
953
  // Cached helper methods
950
954
  getCachedPascalCase(str) {
951
955
  if (!this.pascalCaseCache.has(str)) {
952
- this.pascalCaseCache.set(str, this.pascalCaseForEnums(str));
956
+ this.pascalCaseCache.set(str, pascalCaseForEnums(str));
953
957
  }
954
958
  return this.pascalCaseCache.get(str);
955
959
  }
@@ -994,9 +998,6 @@ var TypeGenerator = class {
994
998
  nullableType(type, isNullable) {
995
999
  return type + (isNullable ? " | null" : "");
996
1000
  }
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
1001
  sanitizePropertyName(name) {
1001
1002
  if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
1002
1003
  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(pascalCase(refName), nullable);
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";
@@ -1074,7 +1079,7 @@ var _TypeGenerator = class _TypeGenerator {
1074
1079
  // Cached helper methods
1075
1080
  getCachedPascalCase(str) {
1076
1081
  if (!this.pascalCaseCache.has(str)) {
1077
- this.pascalCaseCache.set(str, this.pascalCaseForEnums(str));
1082
+ this.pascalCaseCache.set(str, pascalCaseForEnums(str));
1078
1083
  }
1079
1084
  return this.pascalCaseCache.get(str);
1080
1085
  }
@@ -1119,9 +1124,6 @@ var _TypeGenerator = class _TypeGenerator {
1119
1124
  nullableType(type, isNullable) {
1120
1125
  return type + (isNullable ? " | null" : "");
1121
1126
  }
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
1127
  sanitizePropertyName(name) {
1126
1128
  if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
1127
1129
  return `"${name}"`;
@@ -3027,6 +3029,7 @@ __name(generateFromConfig, "generateFromConfig");
3027
3029
  kebabCase,
3028
3030
  nullableType,
3029
3031
  pascalCase,
3032
+ pascalCaseForEnums,
3030
3033
  screamingSnakeCase,
3031
3034
  validateInput
3032
3035
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-openapi",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Generate Angular services and TypeScript types from OpenAPI/Swagger specifications",
5
5
  "keywords": [
6
6
  "ng-openapi",