@ng-openapi/http-resource 0.0.22 → 0.0.24

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.
Files changed (3) hide show
  1. package/index.cjs +11 -7
  2. package/index.js +11 -7
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -47,6 +47,10 @@ function pascalCase(str2) {
47
47
  return str2.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^./, (char) => char.toUpperCase());
48
48
  }
49
49
  __name(pascalCase, "pascalCase");
50
+ function pascalCaseForEnums(str2) {
51
+ return str2.replace(/[^a-zA-Z0-9]/g, "_").replace(/(?:^|_)([a-z])/g, (_, char) => char.toUpperCase()).replace(/^([0-9])/, "_$1");
52
+ }
53
+ __name(pascalCaseForEnums, "pascalCaseForEnums");
50
54
 
51
55
  // ../../shared/src/utils/type.utils.ts
52
56
  function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, context = "type") {
@@ -67,7 +71,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
67
71
  }
68
72
  if (schema2.$ref) {
69
73
  const refName = schema2.$ref.split("/").pop();
70
- return nullableType(pascalCase(refName), nullable);
74
+ return nullableType(pascalCaseForEnums(refName), nullable);
71
75
  }
72
76
  if (schema2.type === "array") {
73
77
  const itemType = schema2.items ? getTypeScriptType(schema2.items, config, void 0, void 0, context) : "unknown";
@@ -3083,7 +3087,7 @@ var HttpResourceMethodBodyGenerator = class {
3083
3087
  let urlExpression = `\`\${this.basePath}${operation.path}\``;
3084
3088
  if (context.pathParams.length > 0) {
3085
3089
  context.pathParams.forEach((param) => {
3086
- urlExpression = urlExpression.replace(`{${param.name}}`, `\${typeof ${param.name} === 'function' ? ${param.name}() : ${param.name}}`);
3090
+ urlExpression = urlExpression.replace(`{${param.name}}`, `\${typeof ${camelCase(param.name)} === 'function' ? ${camelCase(param.name)}() : ${camelCase(param.name)}}`);
3087
3091
  });
3088
3092
  }
3089
3093
  return urlExpression;
@@ -3092,9 +3096,9 @@ var HttpResourceMethodBodyGenerator = class {
3092
3096
  if (context.queryParams.length === 0) {
3093
3097
  return "";
3094
3098
  }
3095
- const paramMappings = context.queryParams.map((param) => `const ${param.name}Value = typeof ${param.name} === 'function' ? ${param.name}() : ${param.name};
3096
- if (${param.name}Value != null) {
3097
- params = HttpParamsBuilder.addToHttpParams(params, ${param.name}Value, '${param.name}');
3099
+ const paramMappings = context.queryParams.map((param) => `const ${camelCase(param.name)}Value = typeof ${camelCase(param.name)} === 'function' ? ${camelCase(param.name)}() : ${camelCase(param.name)};
3100
+ if (${camelCase(param.name)}Value != null) {
3101
+ params = HttpParamsBuilder.addToHttpParams(params, ${camelCase(param.name)}Value, '${param.name}');
3098
3102
  }`).join("\n");
3099
3103
  return `
3100
3104
  let params = new HttpParams();
@@ -3213,7 +3217,7 @@ var HttpResourceMethodParamsGenerator = class {
3213
3217
  const paramType = getTypeScriptType(param.schema || param, this.config);
3214
3218
  const signalParamType = param.required ? `Signal<${paramType}>` : `Signal<${paramType} | undefined>`;
3215
3219
  params.push({
3216
- name: param.name,
3220
+ name: camelCase(param.name),
3217
3221
  type: `${signalParamType} | ${paramType}`,
3218
3222
  hasQuestionToken: !param.required
3219
3223
  });
@@ -3223,7 +3227,7 @@ var HttpResourceMethodParamsGenerator = class {
3223
3227
  const paramType = getTypeScriptType(param.schema || param, this.config);
3224
3228
  const signalParamType = param.required ? `Signal<${paramType}>` : `Signal<${paramType} | undefined>`;
3225
3229
  params.push({
3226
- name: param.name,
3230
+ name: camelCase(param.name),
3227
3231
  type: `${signalParamType} | ${paramType}`,
3228
3232
  hasQuestionToken: !param.required
3229
3233
  });
package/index.js CHANGED
@@ -13,6 +13,10 @@ function pascalCase(str2) {
13
13
  return str2.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^./, (char) => char.toUpperCase());
14
14
  }
15
15
  __name(pascalCase, "pascalCase");
16
+ function pascalCaseForEnums(str2) {
17
+ return str2.replace(/[^a-zA-Z0-9]/g, "_").replace(/(?:^|_)([a-z])/g, (_, char) => char.toUpperCase()).replace(/^([0-9])/, "_$1");
18
+ }
19
+ __name(pascalCaseForEnums, "pascalCaseForEnums");
16
20
 
17
21
  // ../../shared/src/utils/type.utils.ts
18
22
  function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, context = "type") {
@@ -33,7 +37,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
33
37
  }
34
38
  if (schema2.$ref) {
35
39
  const refName = schema2.$ref.split("/").pop();
36
- return nullableType(pascalCase(refName), nullable);
40
+ return nullableType(pascalCaseForEnums(refName), nullable);
37
41
  }
38
42
  if (schema2.type === "array") {
39
43
  const itemType = schema2.items ? getTypeScriptType(schema2.items, config, void 0, void 0, context) : "unknown";
@@ -3049,7 +3053,7 @@ var HttpResourceMethodBodyGenerator = class {
3049
3053
  let urlExpression = `\`\${this.basePath}${operation.path}\``;
3050
3054
  if (context.pathParams.length > 0) {
3051
3055
  context.pathParams.forEach((param) => {
3052
- urlExpression = urlExpression.replace(`{${param.name}}`, `\${typeof ${param.name} === 'function' ? ${param.name}() : ${param.name}}`);
3056
+ urlExpression = urlExpression.replace(`{${param.name}}`, `\${typeof ${camelCase(param.name)} === 'function' ? ${camelCase(param.name)}() : ${camelCase(param.name)}}`);
3053
3057
  });
3054
3058
  }
3055
3059
  return urlExpression;
@@ -3058,9 +3062,9 @@ var HttpResourceMethodBodyGenerator = class {
3058
3062
  if (context.queryParams.length === 0) {
3059
3063
  return "";
3060
3064
  }
3061
- const paramMappings = context.queryParams.map((param) => `const ${param.name}Value = typeof ${param.name} === 'function' ? ${param.name}() : ${param.name};
3062
- if (${param.name}Value != null) {
3063
- params = HttpParamsBuilder.addToHttpParams(params, ${param.name}Value, '${param.name}');
3065
+ const paramMappings = context.queryParams.map((param) => `const ${camelCase(param.name)}Value = typeof ${camelCase(param.name)} === 'function' ? ${camelCase(param.name)}() : ${camelCase(param.name)};
3066
+ if (${camelCase(param.name)}Value != null) {
3067
+ params = HttpParamsBuilder.addToHttpParams(params, ${camelCase(param.name)}Value, '${param.name}');
3064
3068
  }`).join("\n");
3065
3069
  return `
3066
3070
  let params = new HttpParams();
@@ -3179,7 +3183,7 @@ var HttpResourceMethodParamsGenerator = class {
3179
3183
  const paramType = getTypeScriptType(param.schema || param, this.config);
3180
3184
  const signalParamType = param.required ? `Signal<${paramType}>` : `Signal<${paramType} | undefined>`;
3181
3185
  params.push({
3182
- name: param.name,
3186
+ name: camelCase(param.name),
3183
3187
  type: `${signalParamType} | ${paramType}`,
3184
3188
  hasQuestionToken: !param.required
3185
3189
  });
@@ -3189,7 +3193,7 @@ var HttpResourceMethodParamsGenerator = class {
3189
3193
  const paramType = getTypeScriptType(param.schema || param, this.config);
3190
3194
  const signalParamType = param.required ? `Signal<${paramType}>` : `Signal<${paramType} | undefined>`;
3191
3195
  params.push({
3192
- name: param.name,
3196
+ name: camelCase(param.name),
3193
3197
  type: `${signalParamType} | ${paramType}`,
3194
3198
  hasQuestionToken: !param.required
3195
3199
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-openapi/http-resource",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "HTTP Resource plugin for ng-openapi - Angular HTTP utilities with caching and state management",
5
5
  "keywords": [
6
6
  "angular",