ts-openapi-codegen 2.0.0-beta.9 → 2.0.0

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 (183) hide show
  1. package/README.md +88 -18
  2. package/README.rus.md +88 -21
  3. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
  4. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +5 -0
  5. package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
  6. package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +20 -8
  7. package/dist/cli/index.js +5 -3
  8. package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
  9. package/dist/cli/previewChanges/previewChanges.js +116 -32
  10. package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
  11. package/dist/cli/previewChanges/utils/updateOutputPaths.js +6 -0
  12. package/dist/common/Consts.d.ts.map +1 -1
  13. package/dist/common/Consts.js +4 -1
  14. package/dist/common/LoggerMessages.d.ts +1 -0
  15. package/dist/common/LoggerMessages.d.ts.map +1 -1
  16. package/dist/common/LoggerMessages.js +1 -0
  17. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +1 -1
  18. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
  19. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +14 -4
  20. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +2 -2
  21. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +2 -2
  22. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +2 -2
  23. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +42 -0
  24. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -0
  25. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +38 -0
  26. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +155 -28
  27. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
  28. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +13 -17
  29. package/dist/common/VersionedSchema/CommonSchemas.d.ts +12 -4
  30. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  31. package/dist/common/VersionedSchema/CommonSchemas.js +15 -7
  32. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +2 -2
  33. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +2 -2
  34. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +2 -2
  35. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +2 -2
  36. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +2 -2
  37. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
  38. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +19 -0
  39. package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts +2 -0
  40. package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts.map +1 -0
  41. package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +185 -0
  42. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.js +20 -3
  43. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +19 -1
  44. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +4 -0
  45. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
  46. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +68 -23
  47. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts +1 -1
  48. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.js +1 -1
  49. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +10 -0
  50. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
  51. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +33 -15
  52. package/dist/common/utils/__tests__/convertArrayToObject.test.js +64 -169
  53. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
  54. package/dist/common/utils/convertArrayToObject.js +51 -14
  55. package/dist/core/OpenApiClient.d.ts.map +1 -1
  56. package/dist/core/OpenApiClient.js +12 -1
  57. package/dist/core/WriteClient.d.ts +8 -1
  58. package/dist/core/WriteClient.d.ts.map +1 -1
  59. package/dist/core/WriteClient.js +48 -7
  60. package/dist/core/__tests__/WriteClient.test.js +2 -0
  61. package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
  62. package/dist/core/api/v2/parser/getType.js +2 -1
  63. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  64. package/dist/core/api/v3/parser/getType.js +2 -1
  65. package/dist/core/types/base/Templates.model.d.ts +1 -1
  66. package/dist/core/types/base/Templates.model.d.ts.map +1 -1
  67. package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts +6 -0
  68. package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts.map +1 -0
  69. package/dist/core/types/enums/EmptySchemaStrategy.enum.js +9 -0
  70. package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts +2 -0
  71. package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts.map +1 -0
  72. package/dist/core/utils/__tests__/getRelativeModelPath.test.js +27 -0
  73. package/dist/core/utils/__tests__/modelHelpers.test.d.ts +2 -0
  74. package/dist/core/utils/__tests__/modelHelpers.test.d.ts.map +1 -0
  75. package/dist/core/utils/__tests__/modelHelpers.test.js +151 -0
  76. package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts +2 -0
  77. package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts.map +1 -0
  78. package/dist/core/utils/__tests__/postProcessModelImports.test.js +67 -0
  79. package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts +2 -0
  80. package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts.map +1 -0
  81. package/dist/core/utils/__tests__/postProcessServiceImports.test.js +26 -0
  82. package/dist/core/utils/__tests__/resolveRefPath.test.d.ts +2 -0
  83. package/dist/core/utils/__tests__/resolveRefPath.test.d.ts.map +1 -0
  84. package/dist/core/utils/__tests__/resolveRefPath.test.js +22 -0
  85. package/dist/core/utils/__tests__/serviceHelpers.test.d.ts +2 -0
  86. package/dist/core/utils/__tests__/serviceHelpers.test.d.ts.map +1 -0
  87. package/dist/core/utils/__tests__/serviceHelpers.test.js +121 -0
  88. package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts +2 -0
  89. package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts.map +1 -0
  90. package/dist/core/utils/__tests__/writeClientExecutor.test.js +20 -0
  91. package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -0
  92. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  93. package/dist/core/utils/getOpenApiSpec.js +14 -1
  94. package/dist/core/utils/getRelativeModelPath.d.ts +9 -0
  95. package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -0
  96. package/dist/core/utils/getRelativeModelPath.js +37 -0
  97. package/dist/core/utils/modelHelpers.d.ts.map +1 -1
  98. package/dist/core/utils/modelHelpers.js +37 -3
  99. package/dist/core/utils/postProcessModelImports.d.ts.map +1 -1
  100. package/dist/core/utils/postProcessModelImports.js +14 -1
  101. package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
  102. package/dist/core/utils/postProcessServiceImports.js +1 -2
  103. package/dist/core/utils/precompileTemplates.js +1 -0
  104. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  105. package/dist/core/utils/registerHandlebarHelpers.js +25 -0
  106. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  107. package/dist/core/utils/registerHandlebarTemplates.js +42 -41
  108. package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
  109. package/dist/core/utils/resolveRefPath.js +1 -4
  110. package/dist/core/utils/writeClientExecutor.d.ts +4 -1
  111. package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
  112. package/dist/core/utils/writeClientExecutor.js +17 -2
  113. package/dist/core/utils/writeClientSchemas.d.ts +4 -1
  114. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  115. package/dist/core/utils/writeClientSchemas.js +11 -2
  116. package/dist/templatesCompiled/client/core/ApiError.js +1 -1
  117. package/dist/templatesCompiled/client/core/ApiResult.js +1 -1
  118. package/dist/templatesCompiled/client/core/axios/request.js +3 -3
  119. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +2 -0
  120. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
  121. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +13 -8
  122. package/dist/templatesCompiled/client/core/executor/requestExecutor.js +1 -1
  123. package/dist/templatesCompiled/client/core/fetch/request.js +3 -3
  124. package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
  125. package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
  126. package/dist/templatesCompiled/client/core/node/request.js +3 -3
  127. package/dist/templatesCompiled/client/core/xhr/request.js +3 -3
  128. package/dist/templatesCompiled/client/exportClient.d.ts +4 -0
  129. package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
  130. package/dist/templatesCompiled/client/exportClient.js +51 -13
  131. package/dist/templatesCompiled/client/exportSchema.d.ts +5 -1
  132. package/dist/templatesCompiled/client/exportSchema.d.ts.map +1 -1
  133. package/dist/templatesCompiled/client/exportSchema.js +37 -7
  134. package/dist/templatesCompiled/client/exportService.d.ts +2 -0
  135. package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
  136. package/dist/templatesCompiled/client/exportService.js +70 -30
  137. package/dist/templatesCompiled/client/indexFull.d.ts +1 -0
  138. package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
  139. package/dist/templatesCompiled/client/indexFull.js +4 -1
  140. package/dist/templatesCompiled/client/indexSimple.d.ts +1 -0
  141. package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
  142. package/dist/templatesCompiled/client/indexSimple.js +4 -1
  143. package/dist/templatesCompiled/client/joi/exportSchema.js +5 -5
  144. package/dist/templatesCompiled/client/joi/partials/joiSchema.js +7 -7
  145. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +4 -4
  146. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +5 -3
  147. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -1
  148. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +39 -12
  149. package/dist/templatesCompiled/client/jsonschema/exportSchema.js +5 -5
  150. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +7 -7
  151. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +5 -5
  152. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +2 -2
  153. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +5 -5
  154. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +3 -1
  155. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -1
  156. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +45 -15
  157. package/dist/templatesCompiled/client/yup/exportSchema.js +3 -3
  158. package/dist/templatesCompiled/client/yup/partials/yupSchema.js +7 -7
  159. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +4 -4
  160. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +5 -3
  161. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -1
  162. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +39 -12
  163. package/dist/templatesCompiled/client/zod/exportSchema.js +3 -3
  164. package/dist/templatesCompiled/client/zod/partials/zodSchema.js +7 -7
  165. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +5 -6
  166. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -1
  167. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +14 -28
  168. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +3 -0
  169. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -1
  170. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +32 -8
  171. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +3 -4
  172. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -1
  173. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +9 -23
  174. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +4 -2
  175. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -1
  176. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +18 -7
  177. package/package.json +2 -2
  178. package/dist/common/defaultOptions.d.ts +0 -3
  179. package/dist/common/defaultOptions.d.ts.map +0 -1
  180. package/dist/common/defaultOptions.js +0 -28
  181. package/dist/core/utils/advancedDeduplicatePath.d.ts +0 -5
  182. package/dist/core/utils/advancedDeduplicatePath.d.ts.map +0 -1
  183. package/dist/core/utils/advancedDeduplicatePath.js +0 -29
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const strict_1 = __importDefault(require("node:assert/strict"));
7
7
  const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
9
+ const EmptySchemaStrategy_enum_1 = require("../types/enums/EmptySchemaStrategy.enum");
9
10
  const HttpClient_enum_1 = require("../types/enums/HttpClient.enum");
10
11
  const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
11
12
  const getOutputPaths_1 = require("../utils/getOutputPaths");
@@ -70,6 +71,7 @@ const WriteClient_1 = require("../WriteClient");
70
71
  useUnionTypes: false,
71
72
  excludeCoreServiceFiles: false,
72
73
  validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
74
+ emptySchemaStrategy: EmptySchemaStrategy_enum_1.EmptySchemaStrategy.KEEP,
73
75
  });
74
76
  strict_1.default.ok(mkdirCalls.length > 0, 'mkdir should be called at least once');
75
77
  strict_1.default.ok(writeFileCalls.length > 0, 'writeFile should be called at least once');
@@ -1 +1 @@
1
- {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA6C5E"}
1
+ {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA8C5E"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getType = getType;
4
4
  const pathHelpers_1 = require("../../../../common/utils/pathHelpers");
5
5
  const getMappedType_1 = require("../../../utils/getMappedType");
6
+ const getRelativeModelPath_1 = require("../../../utils/getRelativeModelPath");
6
7
  const getTypeName_1 = require("../../../utils/getTypeName");
7
8
  const normalizeString_1 = require("../../../utils/normalizeString");
8
9
  const stripNamespace_1 = require("../../../utils/stripNamespace");
@@ -42,7 +43,7 @@ function getType(value, parentRef) {
42
43
  const cleanedRefValuePath = (0, stripNamespace_1.stripNamespace)(refValuePath);
43
44
  valuePath = (0, pathHelpers_1.relativeHelper)(this.context.output?.outputModels, cleanedRefValuePath);
44
45
  }
45
- valuePath = !valuePath.startsWith('./') && !valuePath.startsWith('../') ? `./${valuePath}` : valuePath;
46
+ valuePath = (0, getRelativeModelPath_1.getRelativeModelPath)(this.context.output?.outputModels, valuePath);
46
47
  const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), normalizedValue, parentRef);
47
48
  const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
48
49
  result.path = valuePath;
@@ -1 +1 @@
1
- {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA6C5E"}
1
+ {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA6C5E"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getType = getType;
4
4
  const pathHelpers_1 = require("../../../../common/utils/pathHelpers");
5
5
  const getMappedType_1 = require("../../../utils/getMappedType");
6
+ const getRelativeModelPath_1 = require("../../../utils/getRelativeModelPath");
6
7
  const getTypeName_1 = require("../../../utils/getTypeName");
7
8
  const normalizeString_1 = require("../../../utils/normalizeString");
8
9
  const stripNamespace_1 = require("../../../utils/stripNamespace");
@@ -42,7 +43,7 @@ function getType(value, parentRef) {
42
43
  const cleanedRefValuePath = (0, stripNamespace_1.stripNamespace)(refValuePath);
43
44
  valuePath = (0, pathHelpers_1.relativeHelper)(this.context.output?.outputModels, cleanedRefValuePath);
44
45
  }
45
- valuePath = !valuePath.startsWith('./') && !valuePath.startsWith('../') ? `./${valuePath}` : valuePath;
46
+ valuePath = (0, getRelativeModelPath_1.getRelativeModelPath)(this.context.output?.outputModels, valuePath);
46
47
  const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), normalizedValue, parentRef);
47
48
  const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
48
49
  result.path = valuePath;
@@ -11,7 +11,7 @@ export interface Templates {
11
11
  exports: {
12
12
  client: Handlebars.TemplateDelegate;
13
13
  model: Handlebars.TemplateDelegate;
14
- schema: Handlebars.TemplateDelegate | undefined;
14
+ schema: Handlebars.TemplateDelegate;
15
15
  service: Handlebars.TemplateDelegate;
16
16
  };
17
17
  core: {
@@ -1 +1 @@
1
- {"version":3,"file":"Templates.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/Templates.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAC;IACF,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAChD,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,qBAAqB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnD,YAAY,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC1C,mBAAmB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACjD,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACjD,CAAC;CACL"}
1
+ {"version":3,"file":"Templates.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/Templates.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAC;IACF,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,qBAAqB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnD,YAAY,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC1C,mBAAmB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACjD,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACjD,CAAC;CACL"}
@@ -0,0 +1,6 @@
1
+ export declare enum EmptySchemaStrategy {
2
+ SEMANTIC = "semantic",
3
+ SKIP = "skip",
4
+ KEEP = "keep"
5
+ }
6
+ //# sourceMappingURL=EmptySchemaStrategy.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptySchemaStrategy.enum.d.ts","sourceRoot":"","sources":["../../../../src/core/types/enums/EmptySchemaStrategy.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB;IAC3B,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CAChB"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmptySchemaStrategy = void 0;
4
+ var EmptySchemaStrategy;
5
+ (function (EmptySchemaStrategy) {
6
+ EmptySchemaStrategy["SEMANTIC"] = "semantic";
7
+ EmptySchemaStrategy["SKIP"] = "skip";
8
+ EmptySchemaStrategy["KEEP"] = "keep";
9
+ })(EmptySchemaStrategy || (exports.EmptySchemaStrategy = EmptySchemaStrategy = {}));
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getRelativeModelPath.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRelativeModelPath.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/getRelativeModelPath.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const getRelativeModelPath_1 = require("../getRelativeModelPath");
9
+ (0, node_test_1.describe)('@unit: getRelativeModelPath', () => {
10
+ (0, node_test_1.test)('should return model relative path when root is undefined', () => {
11
+ const modelRelativePath = '../../../models/truck';
12
+ const result = (0, getRelativeModelPath_1.getRelativeModelPath)(undefined, modelRelativePath);
13
+ node_assert_1.default.strictEqual(result, '../../../models/truck');
14
+ });
15
+ (0, node_test_1.test)('should return correct model relative path considering navigation symbols', () => {
16
+ const rootPath = '/home/generated';
17
+ const modelRelativePath = '../../../models/truck';
18
+ const result = (0, getRelativeModelPath_1.getRelativeModelPath)(rootPath, modelRelativePath);
19
+ node_assert_1.default.strictEqual(result, 'models/truck');
20
+ });
21
+ (0, node_test_1.test)('should collapse absolute path to type name', () => {
22
+ const rootPath = '/home/generated';
23
+ const modelAbsolutePath = '/home/other/models/truck';
24
+ const result = (0, getRelativeModelPath_1.getRelativeModelPath)(rootPath, modelAbsolutePath);
25
+ node_assert_1.default.strictEqual(result, 'truck');
26
+ });
27
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=modelHelpers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelHelpers.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/modelHelpers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const modelHelpers_1 = require("../modelHelpers");
9
+ function createModel(overrides = {}) {
10
+ return {
11
+ name: 'Model',
12
+ alias: '',
13
+ path: 'Model',
14
+ export: 'reference',
15
+ type: 'Model',
16
+ base: 'Model',
17
+ template: null,
18
+ link: null,
19
+ description: null,
20
+ isDefinition: false,
21
+ isReadOnly: false,
22
+ isRequired: false,
23
+ isNullable: false,
24
+ imports: [],
25
+ enum: [],
26
+ enums: [],
27
+ properties: [],
28
+ ...overrides,
29
+ };
30
+ }
31
+ (0, node_test_1.describe)('@unit: modelHelpers', () => {
32
+ (0, node_test_1.test)('resolveModelImports should propagate duplicate aliases to nested model types', () => {
33
+ const importFooA = { name: 'Foo', alias: '', path: './a/Foo' };
34
+ const importFooB = { name: 'Foo', alias: '', path: './b/Foo' };
35
+ const propertyFooA = createModel({
36
+ name: 'fooA',
37
+ path: './a/Foo',
38
+ type: 'Foo',
39
+ base: 'Foo',
40
+ imports: [importFooA],
41
+ });
42
+ const propertyFooBArray = createModel({
43
+ name: 'fooBArray',
44
+ export: 'array',
45
+ type: 'Foo',
46
+ base: 'Foo',
47
+ imports: [importFooB],
48
+ link: createModel({
49
+ path: './b/Foo',
50
+ type: 'Foo',
51
+ base: 'Foo',
52
+ imports: [importFooB],
53
+ }),
54
+ });
55
+ const enumRefFooA = createModel({
56
+ name: 'FooEnumRef',
57
+ path: './a/Foo',
58
+ type: 'Foo',
59
+ base: 'Foo',
60
+ imports: [importFooA],
61
+ });
62
+ const fooModelA = createModel({
63
+ name: 'Foo',
64
+ path: 'a/Foo',
65
+ type: 'Foo',
66
+ base: 'Foo',
67
+ export: 'interface',
68
+ });
69
+ const fooModelB = createModel({
70
+ name: 'Foo',
71
+ path: 'b/Foo',
72
+ type: 'Foo',
73
+ base: 'Foo',
74
+ export: 'interface',
75
+ });
76
+ const wrapper = createModel({
77
+ name: 'Wrapper',
78
+ path: 'wrapper/Wrapper',
79
+ export: 'interface',
80
+ type: 'any',
81
+ base: 'any',
82
+ imports: [importFooA, importFooB],
83
+ properties: [propertyFooA, propertyFooBArray],
84
+ enums: [enumRefFooA],
85
+ });
86
+ const models = [fooModelA, fooModelB, wrapper];
87
+ (0, modelHelpers_1.setDuplicateModelAliases)(models);
88
+ (0, modelHelpers_1.resolveModelImports)(models, '/tmp/generated/models');
89
+ const wrapperImportAliases = wrapper.imports.map(item => item.alias).filter(Boolean);
90
+ node_assert_1.default.deepStrictEqual(wrapperImportAliases, ['Foo$1', 'Foo$2']);
91
+ node_assert_1.default.equal(propertyFooA.base, 'Foo$1');
92
+ node_assert_1.default.equal(propertyFooA.type, 'Foo$1');
93
+ node_assert_1.default.equal(propertyFooBArray.base, 'Foo$2');
94
+ node_assert_1.default.equal(propertyFooBArray.type, 'Foo$2');
95
+ node_assert_1.default.equal(propertyFooBArray.link?.base, 'Foo$2');
96
+ node_assert_1.default.equal(propertyFooBArray.link?.type, 'Foo$2');
97
+ node_assert_1.default.equal(enumRefFooA.base, 'Foo$1');
98
+ node_assert_1.default.equal(enumRefFooA.type, 'Foo$1');
99
+ node_assert_1.default.equal(wrapper.alias, '');
100
+ });
101
+ (0, node_test_1.test)('resolveModelImports should propagate alias when nested import object is not reused after dedup', () => {
102
+ const importFooRoot = { name: 'Foo', alias: '', path: './a/Foo' };
103
+ const importFooNested = { name: 'Foo', alias: '', path: './a/Foo' };
104
+ const fooModel = createModel({
105
+ name: 'Foo',
106
+ path: 'a/Foo',
107
+ export: 'interface',
108
+ type: 'Foo',
109
+ base: 'Foo',
110
+ });
111
+ const duplicateFooModel = createModel({
112
+ name: 'Foo',
113
+ path: 'b/Foo',
114
+ export: 'interface',
115
+ type: 'Foo',
116
+ base: 'Foo',
117
+ });
118
+ const nestedRef = createModel({
119
+ name: 'nestedRef',
120
+ path: './a/Foo',
121
+ export: 'reference',
122
+ type: 'Foo',
123
+ base: 'Foo',
124
+ imports: [importFooNested],
125
+ });
126
+ const wrapper = createModel({
127
+ name: 'Wrapper',
128
+ path: 'wrapper/Wrapper',
129
+ export: 'all-of',
130
+ type: 'any',
131
+ base: 'any',
132
+ imports: [importFooRoot],
133
+ properties: [
134
+ createModel({
135
+ name: 'properties',
136
+ export: 'interface',
137
+ type: 'any',
138
+ base: 'any',
139
+ properties: [nestedRef],
140
+ }),
141
+ ],
142
+ });
143
+ const models = [fooModel, duplicateFooModel, wrapper];
144
+ (0, modelHelpers_1.setDuplicateModelAliases)(models);
145
+ (0, modelHelpers_1.resolveModelImports)(models, '/tmp/generated/models');
146
+ node_assert_1.default.equal(wrapper.imports[0].path, '../a/Foo');
147
+ node_assert_1.default.equal(wrapper.imports[0].alias, 'Foo$1');
148
+ node_assert_1.default.equal(nestedRef.base, 'Foo$1');
149
+ node_assert_1.default.equal(nestedRef.type, 'Foo$1');
150
+ });
151
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=postProcessModelImports.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postProcessModelImports.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/postProcessModelImports.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const postProcessModelImports_1 = require("../postProcessModelImports");
9
+ function createModel(overrides = {}) {
10
+ return {
11
+ name: 'ISimpleDto',
12
+ alias: '',
13
+ path: 'path/alias_request/SimpleDto',
14
+ export: 'interface',
15
+ type: 'ISimpleDto',
16
+ base: 'ISimpleDto',
17
+ template: null,
18
+ link: null,
19
+ description: null,
20
+ isDefinition: true,
21
+ isReadOnly: false,
22
+ isRequired: false,
23
+ isNullable: false,
24
+ imports: [],
25
+ enum: [],
26
+ enums: [],
27
+ properties: [],
28
+ ...overrides,
29
+ };
30
+ }
31
+ (0, node_test_1.describe)('@unit: postProcessModelImports', () => {
32
+ (0, node_test_1.test)('keeps same-name imports when path differs and removes only self import', () => {
33
+ const model = createModel({
34
+ imports: [
35
+ { name: 'ISimpleDto', alias: 'ISimpleDto$1', path: './path/alias_response/SimpleDto' },
36
+ { name: 'ISimpleDto', alias: 'ISimpleDto$2', path: './path/common_request/SimpleDto' },
37
+ { name: 'ISimpleDto', alias: '', path: './SimpleDto' },
38
+ ],
39
+ });
40
+ const result = (0, postProcessModelImports_1.postProcessModelImports)(model);
41
+ node_assert_1.default.deepStrictEqual(result.map(item => `${item.name}:${item.alias}:${item.path}`), [
42
+ 'ISimpleDto:ISimpleDto$1:./path/alias_response/SimpleDto',
43
+ 'ISimpleDto:ISimpleDto$2:./path/common_request/SimpleDto',
44
+ ]);
45
+ });
46
+ (0, node_test_1.test)('removes self import by path even if import name differs from model name', () => {
47
+ const model = createModel({
48
+ name: 'IModelWithCircularReference',
49
+ path: 'ModelWithCircularReference',
50
+ imports: [
51
+ { name: 'SomeOtherName', alias: '', path: './ModelWithCircularReference' },
52
+ { name: 'IAnotherModel', alias: '', path: './AnotherModel' },
53
+ ],
54
+ });
55
+ const result = (0, postProcessModelImports_1.postProcessModelImports)(model);
56
+ node_assert_1.default.deepStrictEqual(result.map(item => `${item.name}:${item.path}`), ['IAnotherModel:./AnotherModel']);
57
+ });
58
+ (0, node_test_1.test)('removes self import when model path has nested directory', () => {
59
+ const model = createModel({
60
+ name: 'IModelWithCircularReference',
61
+ path: 'schemas/base/ModelWithCircularReference',
62
+ imports: [{ name: 'IModelWithCircularReference', alias: '', path: './ModelWithCircularReference' }],
63
+ });
64
+ const result = (0, postProcessModelImports_1.postProcessModelImports)(model);
65
+ node_assert_1.default.deepStrictEqual(result, []);
66
+ });
67
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=postProcessServiceImports.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postProcessServiceImports.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/postProcessServiceImports.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const postProcessServiceImports_1 = require("../postProcessServiceImports");
9
+ (0, node_test_1.describe)('@unit: postProcessServiceImports', () => {
10
+ (0, node_test_1.test)('keeps import when model name equals service name', () => {
11
+ const service = {
12
+ name: 'UserService',
13
+ originName: 'UserService',
14
+ operations: [],
15
+ imports: [
16
+ { name: 'UserService', alias: '', path: '../models/UserService' },
17
+ { name: 'UserService', alias: 'UserService$1', path: '../models/path/UserService' },
18
+ ],
19
+ };
20
+ const result = (0, postProcessServiceImports_1.postProcessServiceImports)(service);
21
+ node_assert_1.default.deepStrictEqual(result.map(item => `${item.name}:${item.alias}:${item.path}`), [
22
+ 'UserService:UserService$1:../models/path/UserService',
23
+ 'UserService::../models/UserService',
24
+ ]);
25
+ });
26
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resolveRefPath.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveRefPath.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/resolveRefPath.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const parseRef_1 = require("../parseRef");
9
+ const resolveRefPath_1 = require("../resolveRefPath");
10
+ (0, node_test_1.describe)('@unit: resolveRefPath', () => {
11
+ (0, node_test_1.test)('should keep repeated folder names in absolute path', () => {
12
+ const parsedRef = {
13
+ type: parseRef_1.RefType.EXTERNAL_FILE,
14
+ originalRef: 'schemas/base/ModelWithString.yml',
15
+ filePath: 'schemas/base/ModelWithString.yml',
16
+ fragment: undefined,
17
+ };
18
+ const parentFilePath = '/home/runner/work/openapi-codegen/openapi-codegen/test/spec/v3.withDifferentRefs.yml';
19
+ const result = (0, resolveRefPath_1.resolveRefPath)(parsedRef, parentFilePath);
20
+ node_assert_1.default.strictEqual(result, '/home/runner/work/openapi-codegen/openapi-codegen/test/spec/schemas/base/ModelWithString.yml');
21
+ });
22
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=serviceHelpers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceHelpers.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/serviceHelpers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const serviceHelpers_1 = require("../serviceHelpers");
9
+ function createModel(overrides = {}) {
10
+ return {
11
+ name: 'Model',
12
+ alias: '',
13
+ path: 'Model',
14
+ export: 'reference',
15
+ type: 'Model',
16
+ base: 'Model',
17
+ template: null,
18
+ link: null,
19
+ description: null,
20
+ isDefinition: false,
21
+ isReadOnly: false,
22
+ isRequired: false,
23
+ isNullable: false,
24
+ imports: [],
25
+ enum: [],
26
+ enums: [],
27
+ properties: [],
28
+ ...overrides,
29
+ };
30
+ }
31
+ function createOperationParameter(overrides = {}) {
32
+ return {
33
+ ...createModel(overrides),
34
+ in: 'query',
35
+ prop: 'value',
36
+ mediaType: null,
37
+ ...overrides,
38
+ };
39
+ }
40
+ function createOperationResponse(overrides = {}) {
41
+ return {
42
+ ...createModel(overrides),
43
+ in: 'response',
44
+ code: 200,
45
+ ...overrides,
46
+ };
47
+ }
48
+ (0, node_test_1.describe)('@unit: serviceHelpers', () => {
49
+ (0, node_test_1.test)('finalizeServiceImports should assign duplicate aliases and propagate to params/results', () => {
50
+ const importFooA = { name: 'Foo', alias: '', path: 'models/a/Foo' };
51
+ const importFooB = { name: 'Foo', alias: '', path: 'models/b/Foo' };
52
+ const paramFooA = createOperationParameter({
53
+ name: 'paramFooA',
54
+ path: './models/a/Foo',
55
+ type: 'Foo',
56
+ base: 'Foo',
57
+ imports: [{ ...importFooA }],
58
+ });
59
+ const paramFooBArray = createOperationParameter({
60
+ name: 'paramFooBArray',
61
+ export: 'array',
62
+ type: 'Foo',
63
+ base: 'Foo',
64
+ imports: [{ ...importFooB }],
65
+ link: createModel({
66
+ path: './models/b/Foo',
67
+ type: 'Foo',
68
+ base: 'Foo',
69
+ imports: [{ ...importFooB }],
70
+ }),
71
+ });
72
+ const resultFooB = createOperationResponse({
73
+ name: 'resultFooB',
74
+ path: './models/b/Foo',
75
+ type: 'Foo',
76
+ base: 'Foo',
77
+ imports: [{ ...importFooB }],
78
+ });
79
+ const operation = {
80
+ service: 'PetService',
81
+ name: 'getPet',
82
+ summary: null,
83
+ description: null,
84
+ deprecated: false,
85
+ method: 'GET',
86
+ path: '/pets/{id}',
87
+ imports: [],
88
+ parameters: [paramFooA, paramFooBArray],
89
+ parametersPath: [],
90
+ parametersQuery: [],
91
+ parametersForm: [],
92
+ parametersCookie: [],
93
+ parametersHeader: [],
94
+ parametersBody: null,
95
+ errors: [],
96
+ results: [resultFooB],
97
+ responseHeader: null,
98
+ };
99
+ const service = {
100
+ name: 'PetService',
101
+ originName: 'PetService',
102
+ operations: [operation],
103
+ imports: [importFooA, importFooB],
104
+ };
105
+ (0, serviceHelpers_1.finalizeServiceImports)(service);
106
+ const aliasByPath = new Map(service.imports.map(item => [item.path, item.alias]));
107
+ const aliasA = aliasByPath.get('models/a/Foo');
108
+ const aliasB = aliasByPath.get('models/b/Foo');
109
+ node_assert_1.default.ok(aliasA);
110
+ node_assert_1.default.ok(aliasB);
111
+ node_assert_1.default.notEqual(aliasA, aliasB);
112
+ node_assert_1.default.equal(paramFooA.base, aliasA);
113
+ node_assert_1.default.equal(paramFooA.type, aliasA);
114
+ node_assert_1.default.equal(paramFooBArray.base, aliasB);
115
+ node_assert_1.default.equal(paramFooBArray.type, aliasB);
116
+ node_assert_1.default.equal(paramFooBArray.link?.base, aliasB);
117
+ node_assert_1.default.equal(paramFooBArray.link?.type, aliasB);
118
+ node_assert_1.default.equal(operation.results[0].base, aliasB);
119
+ node_assert_1.default.equal(operation.results[0].type, aliasB);
120
+ });
121
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=writeClientExecutor.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeClientExecutor.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/writeClientExecutor.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_test_1 = require("node:test");
8
+ const writeClientExecutor_1 = require("../writeClientExecutor");
9
+ (0, node_test_1.describe)('@unit: writeClientExecutor', () => {
10
+ (0, node_test_1.test)('deduplicateServicesByName should keep first service by name', () => {
11
+ const services = [
12
+ { name: 'V2Service', originName: 'V2Service', operations: [], imports: [] },
13
+ { name: 'V2Service', originName: 'V2ServiceCopy', operations: [], imports: [] },
14
+ { name: 'SimpleService', originName: 'SimpleService', operations: [], imports: [] },
15
+ ];
16
+ const result = (0, writeClientExecutor_1.deduplicateServicesByName)(services);
17
+ node_assert_1.default.deepStrictEqual(result.map(item => item.name), ['V2Service', 'SimpleService']);
18
+ node_assert_1.default.equal(result[0].originName, 'V2Service');
19
+ });
20
+ });
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const node_assert_1 = __importDefault(require("node:assert"));
7
7
  const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
+ const EmptySchemaStrategy_enum_1 = require("../../types/enums/EmptySchemaStrategy.enum");
9
10
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
11
  const ValidationLibrary_enum_1 = require("../../types/enums/ValidationLibrary.enum");
11
12
  const WriteClient_1 = require("../../WriteClient");
@@ -47,6 +48,7 @@ const templates_1 = require("../__mocks__/templates");
47
48
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
48
49
  useUnionTypes: false,
49
50
  validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
51
+ emptySchemaStrategy: EmptySchemaStrategy_enum_1.EmptySchemaStrategy.KEEP,
50
52
  });
51
53
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyModelSchema.ts') && content.toString().includes('schema')), 'Expected writeFile to be called with schema content for MyModelSchema.ts');
52
54
  // Restoring the original function
@@ -1 +1 @@
1
- {"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB5F"}
1
+ {"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqC5F"}