ng-openapi 0.2.6 → 0.2.8

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/cli.cjs +20 -6
  2. package/index.js +19 -5
  3. 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.5";
47
+ var version = "0.2.7";
48
48
 
49
49
  // src/lib/core/generator.ts
50
50
  var import_ts_morph7 = require("ts-morph");
@@ -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({
@@ -2057,7 +2071,7 @@ var ServiceMethodBodyGenerator = class {
2057
2071
  let urlExpression = `\`\${this.basePath}${operation.path}\``;
2058
2072
  if (context.pathParams.length > 0) {
2059
2073
  context.pathParams.forEach((param) => {
2060
- urlExpression = urlExpression.replace(`{${param.name}}`, `\${${param.name}}`);
2074
+ urlExpression = urlExpression.replace(`{${param.name}}`, `\${${camelCase(param.name)}}`);
2061
2075
  });
2062
2076
  }
2063
2077
  return `const url = ${urlExpression};`;
@@ -2066,8 +2080,8 @@ var ServiceMethodBodyGenerator = class {
2066
2080
  if (context.queryParams.length === 0) {
2067
2081
  return "";
2068
2082
  }
2069
- const paramMappings = context.queryParams.map((param) => `if (${param.name} != null) {
2070
- params = HttpParamsBuilder.addToHttpParams(params, ${param.name}, '${param.name}');
2083
+ const paramMappings = context.queryParams.map((param) => `if (${camelCase(param.name)} != null) {
2084
+ params = HttpParamsBuilder.addToHttpParams(params, ${camelCase(param.name)}, '${param.name}');
2071
2085
  }`).join("\n");
2072
2086
  return `
2073
2087
  let params = new HttpParams();
@@ -2278,7 +2292,7 @@ var ServiceMethodParamsGenerator = class {
2278
2292
  const pathParams = operation.parameters?.filter((p) => p.in === "path") || [];
2279
2293
  pathParams.forEach((param) => {
2280
2294
  params.push({
2281
- name: param.name,
2295
+ name: camelCase(param.name),
2282
2296
  type: getTypeScriptType(param.schema || param, this.config),
2283
2297
  hasQuestionToken: !param.required
2284
2298
  });
@@ -2309,7 +2323,7 @@ var ServiceMethodParamsGenerator = class {
2309
2323
  const queryParams = operation.parameters?.filter((p) => p.in === "query") || [];
2310
2324
  queryParams.forEach((param) => {
2311
2325
  params.push({
2312
- name: param.name,
2326
+ name: camelCase(param.name),
2313
2327
  type: getTypeScriptType(param.schema || param, this.config),
2314
2328
  hasQuestionToken: !param.required
2315
2329
  });
package/index.js CHANGED
@@ -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({
@@ -2182,7 +2196,7 @@ var _ServiceMethodBodyGenerator = class _ServiceMethodBodyGenerator {
2182
2196
  let urlExpression = `\`\${this.basePath}${operation.path}\``;
2183
2197
  if (context.pathParams.length > 0) {
2184
2198
  context.pathParams.forEach((param) => {
2185
- urlExpression = urlExpression.replace(`{${param.name}}`, `\${${param.name}}`);
2199
+ urlExpression = urlExpression.replace(`{${param.name}}`, `\${${camelCase(param.name)}}`);
2186
2200
  });
2187
2201
  }
2188
2202
  return `const url = ${urlExpression};`;
@@ -2191,8 +2205,8 @@ var _ServiceMethodBodyGenerator = class _ServiceMethodBodyGenerator {
2191
2205
  if (context.queryParams.length === 0) {
2192
2206
  return "";
2193
2207
  }
2194
- const paramMappings = context.queryParams.map((param) => `if (${param.name} != null) {
2195
- params = HttpParamsBuilder.addToHttpParams(params, ${param.name}, '${param.name}');
2208
+ const paramMappings = context.queryParams.map((param) => `if (${camelCase(param.name)} != null) {
2209
+ params = HttpParamsBuilder.addToHttpParams(params, ${camelCase(param.name)}, '${param.name}');
2196
2210
  }`).join("\n");
2197
2211
  return `
2198
2212
  let params = new HttpParams();
@@ -2407,7 +2421,7 @@ var _ServiceMethodParamsGenerator = class _ServiceMethodParamsGenerator {
2407
2421
  const pathParams = ((_a = operation.parameters) == null ? void 0 : _a.filter((p) => p.in === "path")) || [];
2408
2422
  pathParams.forEach((param) => {
2409
2423
  params.push({
2410
- name: param.name,
2424
+ name: camelCase(param.name),
2411
2425
  type: getTypeScriptType(param.schema || param, this.config),
2412
2426
  hasQuestionToken: !param.required
2413
2427
  });
@@ -2438,7 +2452,7 @@ var _ServiceMethodParamsGenerator = class _ServiceMethodParamsGenerator {
2438
2452
  const queryParams = ((_e = operation.parameters) == null ? void 0 : _e.filter((p) => p.in === "query")) || [];
2439
2453
  queryParams.forEach((param) => {
2440
2454
  params.push({
2441
- name: param.name,
2455
+ name: camelCase(param.name),
2442
2456
  type: getTypeScriptType(param.schema || param, this.config),
2443
2457
  hasQuestionToken: !param.required
2444
2458
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-openapi",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Generate Angular services and TypeScript types from OpenAPI/Swagger specifications",
5
5
  "keywords": [
6
6
  "ng-openapi",