openapi-ts-request 0.11.0 → 0.11.1

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.
@@ -16,7 +16,7 @@ export default class ServiceGenerator {
16
16
  private getTemplate;
17
17
  private getFunctionName;
18
18
  private getType;
19
- private getTypeName;
19
+ private getFunctionParamsTypeName;
20
20
  private getBodyTP;
21
21
  private getFileTP;
22
22
  private resolveFileTP;
@@ -172,7 +172,7 @@ class ServiceGenerator {
172
172
  type: this.getType(parameter.schema),
173
173
  });
174
174
  });
175
- const typeName = this.getTypeName(Object.assign(Object.assign({}, operationObject), { method, path: pathKey }));
175
+ const typeName = this.getFunctionParamsTypeName(Object.assign(Object.assign({}, operationObject), { method, path: pathKey }));
176
176
  if (props.length > 0 && typeName) {
177
177
  lastTypes.push({
178
178
  typeName,
@@ -316,7 +316,7 @@ class ServiceGenerator {
316
316
  };
317
317
  return Object.assign(Object.assign({}, newApi), { functionName: this.config.isCamelCase
318
318
  ? (0, lodash_1.camelCase)(functionName)
319
- : functionName, typeName: this.getTypeName(newApi), path: getPrefixPath(), pathInComment: formattedPath.replace(/\*/g, '*'), apifoxRunLink: newApi === null || newApi === void 0 ? void 0 : newApi['x-run-in-apifox'], hasPathVariables: formattedPath.includes('{'), hasApiPrefix: !!this.config.apiPrefix, method: newApi.method,
319
+ : functionName, typeName: this.getFunctionParamsTypeName(newApi), path: getPrefixPath(), pathInComment: formattedPath.replace(/\*/g, '*'), apifoxRunLink: newApi === null || newApi === void 0 ? void 0 : newApi['x-run-in-apifox'], hasPathVariables: formattedPath.includes('{'), hasApiPrefix: !!this.config.apiPrefix, method: newApi.method,
320
320
  // 如果 functionName 和 summary 相同,则不显示 summary
321
321
  desc: functionName === newApi.summary
322
322
  ? (newApi.description || '').replace(config_1.lineBreakReg, '')
@@ -402,7 +402,7 @@ class ServiceGenerator {
402
402
  }
403
403
  return (0, util_1.getDefaultType)(schemaObject, namespace, schemas);
404
404
  }
405
- getTypeName(data) {
405
+ getFunctionParamsTypeName(data) {
406
406
  var _a, _b, _c;
407
407
  const namespace = this.config.namespace ? `${this.config.namespace}.` : '';
408
408
  const typeName = ((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.hook) === null || _b === void 0 ? void 0 : _b.customTypeName) === null || _c === void 0 ? void 0 : _c.call(_b, data)) || this.getFunctionName(data);
@@ -592,12 +592,18 @@ class ServiceGenerator {
592
592
  return schemaObject;
593
593
  }
594
594
  resolveArray(schemaObject) {
595
+ var _a;
595
596
  if ((0, util_1.isReferenceObject)(schemaObject.items)) {
596
597
  const refName = (0, util_1.getRefName)(schemaObject.items);
597
598
  return {
598
599
  type: `${refName}[]`,
599
600
  };
600
601
  }
602
+ else if ((_a = schemaObject.items) === null || _a === void 0 ? void 0 : _a.enum) {
603
+ return {
604
+ type: this.getType(schemaObject, this.config.namespace),
605
+ };
606
+ }
601
607
  // 这里需要解析出具体属性,但由于 parser 层还不确定,所以暂时先返回 unknown[]
602
608
  return { type: 'unknown[]' };
603
609
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-request",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Swagger2/OpenAPI3 to TypeScript, request client, request mock service, enum, type field label, JSON Schemas",
5
5
  "engines": {
6
6
  "node": ">=18.0.0",