openapi-ts-request 0.13.0 → 0.13.2

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.
@@ -86,6 +86,9 @@ class ServiceGenerator {
86
86
  const tags = hookCustomFileNames(operationObject, pathKey, method);
87
87
  // 这里判断tags
88
88
  tags.forEach((tag) => {
89
+ if (!tag) {
90
+ return;
91
+ }
89
92
  const tagLowerCase = tag.toLowerCase();
90
93
  if (priorityRule === type_1.PriorityRule.include) {
91
94
  // includeTags 为空,不会匹配任何path,故跳过
@@ -697,8 +700,11 @@ class ServiceGenerator {
697
700
  const enumArray = schemaObject.enum;
698
701
  let enumStr = '';
699
702
  let enumLabelTypeStr = '';
700
- if (config_1.numberEnum.includes(schemaObject.type) || (0, util_1.isAllNumeric)(enumArray)) {
701
- enumStr = `{${(0, lodash_1.map)(enumArray, (value) => `NUMBER_${value}=${Number(value)}`).join(',')}}`;
703
+ if (config_1.numberEnum.includes(schemaObject.type) || (0, util_1.isAllNumber)(enumArray)) {
704
+ enumStr = `{${(0, lodash_1.map)(enumArray, (value) => `"NUMBER_${value}"=${Number(value)}`).join(',')}}`;
705
+ }
706
+ else if ((0, util_1.isAllNumeric)(enumArray)) {
707
+ enumStr = `{${(0, lodash_1.map)(enumArray, (value) => `"STRING_NUMBER_${value}"="${value}"`).join(',')}}`;
702
708
  }
703
709
  else {
704
710
  enumStr = `{${(0, lodash_1.map)(enumArray, (value) => `${value}="${value}"`).join(',')}}`;
@@ -717,8 +723,11 @@ class ServiceGenerator {
717
723
  }).join(',')}}`;
718
724
  }
719
725
  else {
720
- if (config_1.numberEnum.includes(schemaObject.type) || (0, util_1.isAllNumeric)(enumArray)) {
721
- enumLabelTypeStr = `{${(0, lodash_1.map)(enumArray, (value) => `NUMBER_${value}:${Number(value)}`).join(',')}}`;
726
+ if (config_1.numberEnum.includes(schemaObject.type) || (0, util_1.isAllNumber)(enumArray)) {
727
+ enumLabelTypeStr = `{${(0, lodash_1.map)(enumArray, (value) => `"NUMBER_${value}":${Number(value)}`).join(',')}}`;
728
+ }
729
+ else if ((0, util_1.isAllNumeric)(enumArray)) {
730
+ enumLabelTypeStr = `{${(0, lodash_1.map)(enumArray, (value) => `"STRING_NUMBER_${value}":"${value}"`).join(',')}}`;
722
731
  }
723
732
  else {
724
733
  enumLabelTypeStr = `{${(0, lodash_1.map)(enumArray, (value) => `${value}:"${value}"`).join(',')}}`;
@@ -20,3 +20,4 @@ export declare function isArraySchemaObject(schema: unknown): schema is ArraySch
20
20
  export declare function isBinaryArraySchemaObject(schema: unknown): schema is BinaryArraySchemaObject;
21
21
  export declare function resolveRefs(obj: OpenAPIObject, fields: string[]): unknown;
22
22
  export declare function isAllNumeric(arr: any): boolean;
23
+ export declare function isAllNumber(arr: any): boolean;
@@ -20,6 +20,7 @@ exports.isArraySchemaObject = isArraySchemaObject;
20
20
  exports.isBinaryArraySchemaObject = isBinaryArraySchemaObject;
21
21
  exports.resolveRefs = resolveRefs;
22
22
  exports.isAllNumeric = isAllNumeric;
23
+ exports.isAllNumber = isAllNumber;
23
24
  const tslib_1 = require("tslib");
24
25
  const lodash_1 = require("lodash");
25
26
  const reserved_words_1 = tslib_1.__importDefault(require("reserved-words"));
@@ -331,5 +332,9 @@ function resolveRefs(obj, fields) {
331
332
  }, obj);
332
333
  }
333
334
  function isAllNumeric(arr) {
334
- return (0, lodash_1.every)(arr, (item) => (0, lodash_1.isString)(item) && /^[0-9]+$/.test(item));
335
+ return (0, lodash_1.every)(arr, (item) => (0, lodash_1.isString)(item) && /^-?[0-9]+$/.test(item));
336
+ }
337
+ // 检查数组每一项是否都是数字
338
+ function isAllNumber(arr) {
339
+ return (0, lodash_1.every)(arr, (item) => (0, lodash_1.isNumber)(item));
335
340
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-request",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
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",