openapi-ts-request 0.4.6 → 0.4.7

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.
@@ -79,11 +79,14 @@ class ServiceGenerator {
79
79
  list: interfaceTPConfigs,
80
80
  });
81
81
  // 生成枚举翻译
82
- this.genFileFromTemplate(`${config_1.displayEnumLabelFileName}.ts`, config_1.TypescriptFileType.displayEnumLabel, {
83
- list: (0, lodash_1.filter)(interfaceTPConfigs, (item) => item.isEnum),
84
- namespace: this.config.namespace,
85
- interfaceFileName: config_1.interfaceFileName,
86
- });
82
+ const enums = (0, lodash_1.filter)(interfaceTPConfigs, (item) => item.isEnum);
83
+ if (!(0, lodash_1.isEmpty)(enums)) {
84
+ this.genFileFromTemplate(`${config_1.displayEnumLabelFileName}.ts`, config_1.TypescriptFileType.displayEnumLabel, {
85
+ list: enums,
86
+ namespace: this.config.namespace,
87
+ interfaceFileName: config_1.interfaceFileName,
88
+ });
89
+ }
87
90
  // 生成 type 翻译
88
91
  if (this.config.isDisplayTypeLabel) {
89
92
  this.genFileFromTemplate(`${config_1.displayTypeLabelFileName}.ts`, config_1.TypescriptFileType.displayTypeLabel, {
@@ -206,7 +209,7 @@ class ServiceGenerator {
206
209
  }
207
210
  // 判断哪些 schema 需要添加进 type, schemas 渲染数组
208
211
  if ((0, lodash_1.isEmpty)(this.config.allowedTags) ||
209
- schema.isAllowed) {
212
+ (schema === null || schema === void 0 ? void 0 : schema.isAllowed)) {
210
213
  const isEnum = result.isEnum;
211
214
  const typeName = (0, util_1.resolveTypeName)(schemaKey);
212
215
  lastTypes.push({
@@ -279,7 +279,7 @@ function markAllowSchema(schemaStr, schemas) {
279
279
  (0, lodash_1.forEach)(refs, (ref) => {
280
280
  const refPaths = ref.split('/');
281
281
  const schema = schemas === null || schemas === void 0 ? void 0 : schemas[refPaths[refPaths.length - 1]];
282
- if (!(schema === null || schema === void 0 ? void 0 : schema.isAllowed)) {
282
+ if (schema && !schema.isAllowed) {
283
283
  schema.isAllowed = true;
284
284
  markAllowSchema(JSON.stringify(schema), schemas);
285
285
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-request",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Swagger2/OpenAPI3 to TypeScript, request client, request mock service, enum, type field label, JSON Schemas",
5
5
  "repository": {
6
6
  "type": "git",