ts-openapi-codegen 1.0.0-beta.8 → 1.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 (332) hide show
  1. package/README.md +221 -123
  2. package/README.rus.md +725 -0
  3. package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +12 -0
  4. package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -0
  5. package/dist/cli/checkAndUpdateConfig/checkConfig.js +66 -0
  6. package/dist/cli/checkAndUpdateConfig/constants.d.ts +13 -0
  7. package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -0
  8. package/dist/cli/checkAndUpdateConfig/constants.js +29 -0
  9. package/dist/cli/checkAndUpdateConfig/types.d.ts +20 -0
  10. package/dist/cli/checkAndUpdateConfig/types.d.ts.map +1 -0
  11. package/dist/cli/checkAndUpdateConfig/types.js +12 -0
  12. package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +12 -0
  13. package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -0
  14. package/dist/cli/checkAndUpdateConfig/updateConfig.js +56 -0
  15. package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts +2 -0
  16. package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts.map +1 -0
  17. package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.js +11 -0
  18. package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts +14 -0
  19. package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts.map +1 -0
  20. package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.js +30 -0
  21. package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts +17 -0
  22. package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -0
  23. package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.js +29 -0
  24. package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts +2 -0
  25. package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts.map +1 -0
  26. package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.js +11 -0
  27. package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts +29 -0
  28. package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -0
  29. package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +49 -0
  30. package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts +6 -0
  31. package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -0
  32. package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +22 -0
  33. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts +17 -0
  34. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -0
  35. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +53 -0
  36. package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +34 -0
  37. package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -0
  38. package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +41 -0
  39. package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts +6 -0
  40. package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -0
  41. package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +18 -0
  42. package/dist/cli/generate/runGenerateOpenApi.d.ts +2 -2
  43. package/dist/cli/generate/runGenerateOpenApi.d.ts.map +1 -1
  44. package/dist/cli/generate/runGenerateOpenApi.js +12 -14
  45. package/dist/cli/index.d.ts +1 -0
  46. package/dist/cli/index.js +56 -30
  47. package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.d.ts.map +1 -1
  48. package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.js +11 -18
  49. package/dist/cli/interactive/confirmDialog.d.ts +17 -0
  50. package/dist/cli/interactive/confirmDialog.d.ts.map +1 -0
  51. package/dist/cli/interactive/confirmDialog.js +36 -0
  52. package/dist/cli/interactive/constants.d.ts +7 -0
  53. package/dist/cli/interactive/constants.d.ts.map +1 -0
  54. package/dist/cli/interactive/constants.js +25 -0
  55. package/dist/cli/interactive/selectDialog.d.ts +17 -0
  56. package/dist/cli/interactive/selectDialog.d.ts.map +1 -0
  57. package/dist/cli/interactive/selectDialog.js +43 -0
  58. package/dist/cli/interactive/types.d.ts +40 -0
  59. package/dist/cli/interactive/types.d.ts.map +1 -0
  60. package/dist/cli/interactive/types.js +12 -0
  61. package/dist/common/Consts.d.ts +23 -0
  62. package/dist/common/Consts.d.ts.map +1 -1
  63. package/dist/common/Consts.js +28 -1
  64. package/dist/common/Enums.d.ts +4 -0
  65. package/dist/common/Enums.d.ts.map +1 -1
  66. package/dist/common/Enums.js +6 -1
  67. package/dist/common/Logger.d.ts +1 -1
  68. package/dist/common/Logger.d.ts.map +1 -1
  69. package/dist/common/Logger.js +5 -38
  70. package/dist/common/UpdateNotifier.d.ts +36 -2
  71. package/dist/common/UpdateNotifier.d.ts.map +1 -1
  72. package/dist/common/UpdateNotifier.js +150 -57
  73. package/dist/common/VersionedSchema/Types.d.ts +5 -0
  74. package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
  75. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +1 -7
  76. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
  77. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +3 -0
  78. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -0
  79. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +14 -0
  80. package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts +2 -0
  81. package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts.map +1 -0
  82. package/dist/common/VersionedSchema/Utils/getKeyByMapValue.js +11 -0
  83. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +5 -2
  84. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
  85. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +22 -15
  86. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +1 -0
  87. package/dist/common/utils/__tests__/convertArrayToObject.test.d.ts.map +1 -0
  88. package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.js +14 -14
  89. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +1 -0
  90. package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.js +5 -5
  91. package/dist/common/utils/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +1 -0
  92. package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.js +4 -4
  93. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +1 -0
  94. package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.js +4 -4
  95. package/dist/common/utils/__tests__/getUniqueObjectKeys.test.d.ts.map +1 -0
  96. package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.js +5 -5
  97. package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +1 -0
  98. package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.js +5 -5
  99. package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +1 -0
  100. package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.js +21 -15
  101. package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +1 -0
  102. package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.js +13 -9
  103. package/dist/common/utils/__tests__/pathHelpers.test.d.ts.map +1 -0
  104. package/dist/{core → common}/utils/__tests__/pathHelpers.test.js +8 -8
  105. package/dist/common/utils/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +1 -0
  106. package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.js +5 -5
  107. package/dist/common/utils/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +1 -0
  108. package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.js +5 -5
  109. package/dist/common/utils/convertArrayToObject.d.ts +2 -0
  110. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -0
  111. package/dist/common/{Utils.js → utils/convertArrayToObject.js} +0 -20
  112. package/dist/{core/utils/fileSystem.d.ts → common/utils/fileSystemHelpers.d.ts} +8 -5
  113. package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -0
  114. package/dist/common/utils/fileSystemHelpers.js +85 -0
  115. package/dist/common/utils/format.d.ts +3 -0
  116. package/dist/common/utils/format.d.ts.map +1 -0
  117. package/dist/{core → common}/utils/format.js +2 -2
  118. package/dist/common/utils/loadConfigIfExists.d.ts +2 -0
  119. package/dist/common/utils/loadConfigIfExists.d.ts.map +1 -0
  120. package/dist/common/utils/loadConfigIfExists.js +22 -0
  121. package/dist/common/utils/pathHelpers.d.ts +6 -0
  122. package/dist/common/utils/pathHelpers.d.ts.map +1 -0
  123. package/dist/{core → common}/utils/pathHelpers.js +16 -20
  124. package/dist/common/utils/safeHasOwn.d.ts +2 -0
  125. package/dist/common/utils/safeHasOwn.d.ts.map +1 -0
  126. package/dist/common/utils/safeHasOwn.js +9 -0
  127. package/dist/core/Context.d.ts.map +1 -1
  128. package/dist/core/Context.js +3 -3
  129. package/dist/core/WriteClient.d.ts.map +1 -1
  130. package/dist/core/WriteClient.js +18 -18
  131. package/dist/core/__tests__/WriteClient.test.js +61 -60
  132. package/dist/core/api/v2/Parser.d.ts.map +1 -1
  133. package/dist/core/api/v2/Parser.js +2 -9
  134. package/dist/core/api/v2/parser/__tests__/getServer.test.js +2 -2
  135. package/dist/core/api/v2/parser/__tests__/getType.test.js +3 -3
  136. package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
  137. package/dist/core/api/v2/parser/getModelProperties.js +2 -5
  138. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  139. package/dist/core/api/v2/parser/getModels.js +2 -1
  140. package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
  141. package/dist/core/api/v2/parser/getOperationParameter.js +2 -1
  142. package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
  143. package/dist/core/api/v2/parser/getOperationResponse.js +2 -5
  144. package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
  145. package/dist/core/api/v2/parser/getOperationResponses.js +2 -5
  146. package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
  147. package/dist/core/api/v2/parser/getServices.js +2 -5
  148. package/dist/core/api/v2/parser/getType.js +4 -4
  149. package/dist/core/api/v3/Parser.d.ts +1 -1
  150. package/dist/core/api/v3/Parser.d.ts.map +1 -1
  151. package/dist/core/api/v3/Parser.js +2 -9
  152. package/dist/core/api/v3/parser/__tests__/getServer.test.js +3 -3
  153. package/dist/core/api/v3/parser/__tests__/getType.test.js +3 -3
  154. package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
  155. package/dist/core/api/v3/parser/getModelProperties.js +2 -5
  156. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  157. package/dist/core/api/v3/parser/getModels.js +2 -1
  158. package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
  159. package/dist/core/api/v3/parser/getOperationResponse.js +2 -5
  160. package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
  161. package/dist/core/api/v3/parser/getOperationResponses.js +2 -5
  162. package/dist/core/api/v3/parser/getServer.d.ts.map +1 -1
  163. package/dist/core/api/v3/parser/getServer.js +2 -5
  164. package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
  165. package/dist/core/api/v3/parser/getServices.js +2 -5
  166. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  167. package/dist/core/api/v3/parser/getType.js +5 -13
  168. package/dist/core/index.d.ts +4 -0
  169. package/dist/core/index.d.ts.map +1 -1
  170. package/dist/core/index.js +34 -27
  171. package/dist/core/types/Consts.d.ts +5 -1
  172. package/dist/core/types/Consts.d.ts.map +1 -1
  173. package/dist/core/types/Consts.js +6 -2
  174. package/dist/core/types/base/Root.model.d.ts +1 -0
  175. package/dist/core/types/base/Root.model.d.ts.map +1 -1
  176. package/dist/core/utils/__tests__/escapeDescription.test.js +3 -3
  177. package/dist/core/utils/__tests__/escapeName.test.js +2 -2
  178. package/dist/core/utils/__tests__/flatMap.test.js +2 -2
  179. package/dist/core/utils/__tests__/getAbsolutePath.test.js +6 -6
  180. package/dist/core/utils/__tests__/getClassName.test.js +2 -2
  181. package/dist/core/utils/__tests__/getComment.test.js +2 -2
  182. package/dist/core/utils/__tests__/getEnumFromDescription.test.js +2 -2
  183. package/dist/core/utils/__tests__/getFileName.test.js +2 -2
  184. package/dist/core/utils/__tests__/getGatheringRefs.test.js +2 -2
  185. package/dist/core/utils/__tests__/getMappedType.test.js +2 -2
  186. package/dist/core/utils/__tests__/getModelNames.test.js +2 -2
  187. package/dist/core/utils/__tests__/getOpenApiVersion.test.js +2 -2
  188. package/dist/core/utils/__tests__/getOperationName.test.js +2 -2
  189. package/dist/core/utils/__tests__/getOperationParameterName.test.js +2 -2
  190. package/dist/core/utils/__tests__/getOperationPath.test.js +2 -2
  191. package/dist/core/utils/__tests__/getOperationResponseCode.test.js +2 -2
  192. package/dist/core/utils/__tests__/getPattern.test.js +2 -2
  193. package/dist/core/utils/__tests__/getRefFromSchema.test.js +2 -2
  194. package/dist/core/utils/__tests__/getRefs.test.js +2 -2
  195. package/dist/core/utils/__tests__/getRelativeModelPath.test.js +3 -3
  196. package/dist/core/utils/__tests__/getServiceClassName.test.js +2 -2
  197. package/dist/core/utils/__tests__/getServiceNames.test.js +2 -2
  198. package/dist/core/utils/__tests__/getServiceVersion.test.js +2 -2
  199. package/dist/core/utils/__tests__/isString.test.js +2 -2
  200. package/dist/core/utils/__tests__/isSubdirectory.test.js +10 -10
  201. package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
  202. package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +2 -2
  203. package/dist/core/utils/__tests__/replaceString.test.js +2 -2
  204. package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +360 -51
  205. package/dist/core/utils/__tests__/sort.test.js +2 -2
  206. package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +11 -11
  207. package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +11 -11
  208. package/dist/core/utils/__tests__/sortModelsByName.test.js +2 -2
  209. package/dist/core/utils/__tests__/sortServicesByName.test.js +2 -2
  210. package/dist/core/utils/__tests__/stripNamespace.test.js +2 -2
  211. package/dist/core/utils/__tests__/unique.test.js +2 -2
  212. package/dist/core/utils/__tests__/writeClientCore.test.js +52 -50
  213. package/dist/core/utils/__tests__/writeClientFullIndex.test.js +39 -37
  214. package/dist/core/utils/__tests__/writeClientModels.test.js +65 -63
  215. package/dist/core/utils/__tests__/writeClientSchemas.test.js +65 -63
  216. package/dist/core/utils/__tests__/writeClientServices.test.js +60 -58
  217. package/dist/core/utils/appendUniqueLinesToFile.js +4 -4
  218. package/dist/core/utils/createNormalizedRef.js +2 -2
  219. package/dist/core/utils/getAbsolutePath.js +3 -3
  220. package/dist/core/utils/getModelNameWithPrefix.d.ts +3 -0
  221. package/dist/core/utils/getModelNameWithPrefix.d.ts.map +1 -0
  222. package/dist/core/utils/getModelNameWithPrefix.js +15 -0
  223. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  224. package/dist/core/utils/getOpenApiSpec.js +4 -4
  225. package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
  226. package/dist/core/utils/getOutputPaths.js +6 -6
  227. package/dist/core/utils/getPattern.d.ts.map +1 -1
  228. package/dist/core/utils/getPattern.js +2 -1
  229. package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
  230. package/dist/core/utils/getRelativeModelPath.js +2 -6
  231. package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
  232. package/dist/core/utils/isSubdirectory.js +4 -3
  233. package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -1
  234. package/dist/core/utils/mapPathToTargetDirSafe.js +11 -12
  235. package/dist/core/utils/modelHelpers.d.ts.map +1 -1
  236. package/dist/core/utils/modelHelpers.js +18 -6
  237. package/dist/core/utils/normalizeString.d.ts +2 -0
  238. package/dist/core/utils/normalizeString.d.ts.map +1 -0
  239. package/dist/core/utils/normalizeString.js +14 -0
  240. package/dist/core/utils/normalizedAbsolutePath.js +3 -3
  241. package/dist/core/utils/parseRef.d.ts.map +1 -1
  242. package/dist/core/utils/parseRef.js +7 -10
  243. package/dist/core/utils/precompileTemplates.js +14 -10
  244. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  245. package/dist/core/utils/registerHandlebarHelpers.js +24 -0
  246. package/dist/core/utils/replaceString.d.ts.map +1 -1
  247. package/dist/core/utils/replaceString.js +2 -1
  248. package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
  249. package/dist/core/utils/resolveRefPath.js +3 -3
  250. package/dist/core/utils/resolveRefToImportPath.d.ts +8 -2
  251. package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -1
  252. package/dist/core/utils/resolveRefToImportPath.js +91 -31
  253. package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
  254. package/dist/core/utils/serviceHelpers.js +2 -1
  255. package/dist/core/utils/stripNamespace.js +5 -5
  256. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  257. package/dist/core/utils/writeClientCore.js +12 -12
  258. package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
  259. package/dist/core/utils/writeClientCoreIndex.js +2 -2
  260. package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
  261. package/dist/core/utils/writeClientFullIndex.js +4 -4
  262. package/dist/core/utils/writeClientModels.d.ts.map +1 -1
  263. package/dist/core/utils/writeClientModels.js +7 -7
  264. package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
  265. package/dist/core/utils/writeClientModelsIndex.js +2 -2
  266. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  267. package/dist/core/utils/writeClientSchemas.js +7 -7
  268. package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
  269. package/dist/core/utils/writeClientSchemasIndex.js +2 -2
  270. package/dist/core/utils/writeClientServices.d.ts.map +1 -1
  271. package/dist/core/utils/writeClientServices.js +5 -5
  272. package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
  273. package/dist/core/utils/writeClientServicesIndex.js +2 -2
  274. package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
  275. package/dist/core/utils/writeClientSimpleIndex.js +4 -4
  276. package/dist/templatesCompiled/client/exportModel.js +4 -4
  277. package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
  278. package/dist/templatesCompiled/client/exportService.js +12 -13
  279. package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
  280. package/dist/templatesCompiled/client/indexFull.js +35 -29
  281. package/dist/templatesCompiled/client/partials/parameters.d.ts +3 -2
  282. package/dist/templatesCompiled/client/partials/parameters.d.ts.map +1 -1
  283. package/dist/templatesCompiled/client/partials/parameters.js +25 -20
  284. package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts +4 -2
  285. package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts.map +1 -1
  286. package/dist/templatesCompiled/client/partials/parametersDefinition.js +31 -10
  287. package/package.json +15 -13
  288. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +0 -5
  289. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +0 -1
  290. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +0 -45
  291. package/dist/common/Utils.d.ts +0 -3
  292. package/dist/common/Utils.d.ts.map +0 -1
  293. package/dist/common/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
  294. package/dist/common/__tests__/convertArrayToObject.test.d.ts.map +0 -1
  295. package/dist/common/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
  296. package/dist/common/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +0 -1
  297. package/dist/common/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
  298. package/dist/common/__tests__/getUniqueObjectKeys.test.d.ts.map +0 -1
  299. package/dist/common/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
  300. package/dist/common/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
  301. package/dist/common/__tests__/migrationForOptions.test.d.ts.map +0 -1
  302. package/dist/common/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +0 -1
  303. package/dist/common/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +0 -1
  304. package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts +0 -2
  305. package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts.map +0 -1
  306. package/dist/core/utils/__tests__/getRelativeModelImportPath.test.js +0 -82
  307. package/dist/core/utils/__tests__/pathHelpers.test.d.ts.map +0 -1
  308. package/dist/core/utils/fileSystem.d.ts.map +0 -1
  309. package/dist/core/utils/fileSystem.js +0 -26
  310. package/dist/core/utils/format.d.ts +0 -2
  311. package/dist/core/utils/format.d.ts.map +0 -1
  312. package/dist/core/utils/getRelativeModelImportPath.d.ts +0 -9
  313. package/dist/core/utils/getRelativeModelImportPath.d.ts.map +0 -1
  314. package/dist/core/utils/getRelativeModelImportPath.js +0 -45
  315. package/dist/core/utils/isDirectory.d.ts +0 -2
  316. package/dist/core/utils/isDirectory.d.ts.map +0 -1
  317. package/dist/core/utils/isDirectory.js +0 -13
  318. package/dist/core/utils/pathHelpers.d.ts +0 -7
  319. package/dist/core/utils/pathHelpers.d.ts.map +0 -1
  320. /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.d.ts +0 -0
  321. /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.js +0 -0
  322. /package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.d.ts +0 -0
  323. /package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.d.ts +0 -0
  324. /package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.d.ts +0 -0
  325. /package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.d.ts +0 -0
  326. /package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.d.ts +0 -0
  327. /package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.d.ts +0 -0
  328. /package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.d.ts +0 -0
  329. /package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.d.ts +0 -0
  330. /package/dist/{core → common}/utils/__tests__/pathHelpers.test.d.ts +0 -0
  331. /package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.d.ts +0 -0
  332. /package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.d.ts +0 -0
@@ -2,66 +2,375 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const node_assert_1 = require("node:assert");
4
4
  const node_test_1 = require("node:test");
5
+ const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
6
+ const Consts_1 = require("../../types/Consts");
5
7
  const resolveRefToImportPath_1 = require("../resolveRefToImportPath");
6
8
  // Normalization of paths for cross-platform
7
- const normalizePath = (p) => p.replace(/\\/g, '/');
9
+ const normalizePath = (p) => p.replace(Consts_1.REGEX_BACKSLASH, '/');
8
10
  (0, node_test_1.describe)('@unit resolveRefToImportPath — correctly resolves links to components', () => {
9
11
  const mainSpecPath = '/Users/user/Developer/my_app/openapi/app/openapi_spec.yaml';
10
12
  const outputModelsPath = '/Users/user/Developer/openapi-codegen/generated/account/models';
11
- (0, node_test_1.test)('internal link in the child file → path to the model by schema name', () => {
12
- const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
13
- mainSpecPath,
14
- parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml#/components/schemas/AccountField',
15
- refValuePath: '#/components/schemas/AccountField',
16
- outputModelsPath,
17
- });
18
- node_assert_1.strict.equal(normalizePath(result), './spec/AccountField');
13
+ const originalIsDirectory = fileSystemHelpers_1.fileSystemHelpers.isDirectory;
14
+ const originalIsPathToFile = fileSystemHelpers_1.fileSystemHelpers.isPathToFile;
15
+ (0, node_test_1.beforeEach)(() => {
16
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn(() => false);
17
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn(() => true);
19
18
  });
20
- (0, node_test_1.test)('internal link in the main file → model in the root output', () => {
21
- const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
22
- mainSpecPath,
23
- parentFilePath: mainSpecPath,
24
- refValuePath: '#/components/schemas/MainUser',
25
- outputModelsPath,
26
- });
27
- node_assert_1.strict.equal(normalizePath(result), './MainUser');
19
+ (0, node_test_1.afterEach)(() => {
20
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = originalIsDirectory;
21
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = originalIsPathToFile;
28
22
  });
29
- (0, node_test_1.test)('external link to the file → correct name via getClassName', () => {
30
- const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
31
- mainSpecPath,
32
- parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
33
- refValuePath: './users-list.yaml',
34
- outputModelsPath,
35
- });
36
- // users-list.yaml → UsersList (по твоей логике stripNamespace + getClassName)
37
- node_assert_1.strict.equal(normalizePath(result), './spec/UsersList');
23
+ (0, node_test_1.describe)('HTTP_URL', () => {
24
+ (0, node_test_1.test)('http URL → returns URL as is', () => {
25
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
26
+ mainSpecPath,
27
+ parentFilePath: mainSpecPath,
28
+ refValuePath: 'http://example.com/schema.json',
29
+ outputModelsPath,
30
+ });
31
+ node_assert_1.strict.equal(result, 'http://example.com/schema.json');
32
+ });
33
+ (0, node_test_1.test)('https URL → returns URL as is', () => {
34
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
35
+ mainSpecPath,
36
+ parentFilePath: mainSpecPath,
37
+ refValuePath: 'https://api.example.com/schemas/user.yaml',
38
+ outputModelsPath,
39
+ });
40
+ node_assert_1.strict.equal(result, 'https://api.example.com/schemas/user.yaml');
41
+ });
42
+ });
43
+ (0, node_test_1.describe)('LOCAL_FRAGMENT', () => {
44
+ (0, node_test_1.test)('internal link in the child file → path to the model by schema name', () => {
45
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
46
+ mainSpecPath,
47
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml#/components/schemas/AccountField',
48
+ refValuePath: '#/components/schemas/AccountField',
49
+ outputModelsPath,
50
+ });
51
+ node_assert_1.strict.equal(normalizePath(result), './spec/AccountField');
52
+ });
53
+ (0, node_test_1.test)('internal link in the main file → model in the root output', () => {
54
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
55
+ mainSpecPath,
56
+ parentFilePath: mainSpecPath,
57
+ refValuePath: '#/components/schemas/MainUser',
58
+ outputModelsPath,
59
+ });
60
+ node_assert_1.strict.equal(normalizePath(result), './MainUser');
61
+ });
62
+ (0, node_test_1.test)('internal link without parentFilePath → uses mainSpecPath', () => {
63
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
64
+ mainSpecPath,
65
+ parentFilePath: '',
66
+ refValuePath: '#/components/schemas/MainUser',
67
+ outputModelsPath,
68
+ });
69
+ node_assert_1.strict.equal(normalizePath(result), './MainUser');
70
+ });
71
+ (0, node_test_1.test)('embedded internal link → folder structure is saved', () => {
72
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
73
+ mainSpecPath,
74
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/nested/admin/schemas.yaml#/components/schemas/AdminUser',
75
+ refValuePath: '#/components/schemas/AdminUser',
76
+ outputModelsPath,
77
+ });
78
+ node_assert_1.strict.equal(normalizePath(result), './spec/nested/admin/AdminUser');
79
+ });
80
+ (0, node_test_1.test)('deep nesting — the path is built correctly', () => {
81
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
82
+ mainSpecPath,
83
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/very/deep/config/models.yaml#/components/schemas/ConfigDto',
84
+ refValuePath: '#/components/schemas/ConfigDto',
85
+ outputModelsPath,
86
+ });
87
+ node_assert_1.strict.equal(normalizePath(result), './spec/very/deep/config/ConfigDto');
88
+ });
89
+ (0, node_test_1.test)('LOCAL_FRAGMENT with responses component', () => {
90
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
91
+ mainSpecPath,
92
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
93
+ refValuePath: '#/components/responses/ErrorResponse',
94
+ outputModelsPath,
95
+ });
96
+ node_assert_1.strict.equal(normalizePath(result), './spec/ErrorResponse');
97
+ });
98
+ (0, node_test_1.test)('LOCAL_FRAGMENT with parameters component', () => {
99
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
100
+ mainSpecPath,
101
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
102
+ refValuePath: '#/components/parameters/PageParam',
103
+ outputModelsPath,
104
+ });
105
+ node_assert_1.strict.equal(normalizePath(result), './spec/PageParam');
106
+ });
107
+ (0, node_test_1.test)('LOCAL_FRAGMENT with mainSpecPath as directory', () => {
108
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn(() => true);
109
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn(() => false);
110
+ const mainSpecDir = '/Users/user/Developer/my_app/openapi/app';
111
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
112
+ mainSpecPath: mainSpecDir,
113
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
114
+ refValuePath: '#/components/schemas/AccountField',
115
+ outputModelsPath,
116
+ });
117
+ node_assert_1.strict.equal(normalizePath(result), './spec/AccountField');
118
+ });
119
+ (0, node_test_1.test)('LOCAL_FRAGMENT when mapPathToTargetDirSafe maps correctly → returns relative path', () => {
120
+ // Even with different output path, mapPathToTargetDirSafe finds common parent
121
+ // and maps the path, so function returns relative path, not fallback
122
+ const externalOutputPath = '/Users/user/Developer/other_project/generated/models';
123
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
124
+ mainSpecPath,
125
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
126
+ refValuePath: '#/components/schemas/AccountField',
127
+ outputModelsPath: externalOutputPath,
128
+ });
129
+ // The path is still mapped correctly via common parent
130
+ node_assert_1.strict.equal(normalizePath(result), './spec/AccountField');
131
+ });
132
+ });
133
+ (0, node_test_1.describe)('EXTERNAL_FILE_FRAGMENT', () => {
134
+ (0, node_test_1.test)('external file with fragment → resolves to correct model path', () => {
135
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
136
+ mainSpecPath,
137
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
138
+ refValuePath: './users-list.yaml#/components/schemas/UserList',
139
+ outputModelsPath,
140
+ });
141
+ node_assert_1.strict.equal(normalizePath(result), './spec/UserList');
142
+ });
143
+ (0, node_test_1.test)('external file fragment with nested path', () => {
144
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
145
+ mainSpecPath,
146
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
147
+ refValuePath: '../shared/common.yaml#/components/schemas/CommonModel',
148
+ outputModelsPath,
149
+ });
150
+ // Should resolve relative to parent file directory
151
+ const normalized = normalizePath(result);
152
+ node_assert_1.strict.ok(normalized.includes('CommonModel') || normalized.includes('common'));
153
+ });
154
+ (0, node_test_1.test)('external file fragment without parentFilePath', () => {
155
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
156
+ mainSpecPath,
157
+ parentFilePath: '',
158
+ refValuePath: './shared/models.yaml#/components/schemas/SharedModel',
159
+ outputModelsPath,
160
+ });
161
+ const normalized = normalizePath(result);
162
+ node_assert_1.strict.ok(normalized.includes('SharedModel') || normalized.includes('shared'));
163
+ });
164
+ (0, node_test_1.test)('external file fragment with responses component', () => {
165
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
166
+ mainSpecPath,
167
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
168
+ refValuePath: './responses.yaml#/components/responses/ApiResponse',
169
+ outputModelsPath,
170
+ });
171
+ const normalized = normalizePath(result);
172
+ node_assert_1.strict.ok(normalized.includes('ApiResponse') || normalized.includes('spec'));
173
+ });
174
+ (0, node_test_1.test)('EXTERNAL_FILE_FRAGMENT when path is outside outputModelsPath → returns fallback', () => {
175
+ const externalOutputPath = '/Users/user/Developer/other_project/generated/models';
176
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
177
+ mainSpecPath,
178
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
179
+ refValuePath: './users-list.yaml#/components/schemas/UserList',
180
+ outputModelsPath: externalOutputPath,
181
+ });
182
+ // mapPathToTargetDirSafe finds common parent and still maps the path,
183
+ // so it returns relative path instead of fallback
184
+ node_assert_1.strict.equal(normalizePath(result), './spec/UserList');
185
+ });
38
186
  });
39
- (0, node_test_1.test)('embedded internal link → folder structure is saved', () => {
40
- const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
41
- mainSpecPath,
42
- parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/nested/admin/schemas.yaml#/components/schemas/AdminUser',
43
- refValuePath: '#/components/schemas/AdminUser',
44
- outputModelsPath,
45
- });
46
- node_assert_1.strict.equal(normalizePath(result), './spec/nested/admin/AdminUser');
187
+ (0, node_test_1.describe)('EXTERNAL_FILE', () => {
188
+ (0, node_test_1.test)('external link to the file → correct name via getClassName', () => {
189
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
190
+ mainSpecPath,
191
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
192
+ refValuePath: './users-list.yaml',
193
+ outputModelsPath,
194
+ });
195
+ node_assert_1.strict.equal(normalizePath(result), './spec/UsersList');
196
+ });
197
+ (0, node_test_1.test)('the link to the file without the extension → is processed correctly', () => {
198
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
199
+ mainSpecPath,
200
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/shared.yaml',
201
+ refValuePath: './common/error',
202
+ outputModelsPath,
203
+ });
204
+ node_assert_1.strict.equal(normalizePath(result), './spec/common/Error');
205
+ });
206
+ (0, node_test_1.test)('external file with relative path up directory', () => {
207
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
208
+ mainSpecPath,
209
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/nested/accountSpec.yaml',
210
+ refValuePath: '../shared/common.yaml',
211
+ outputModelsPath,
212
+ });
213
+ const normalized = normalizePath(result);
214
+ node_assert_1.strict.ok(normalized.includes('Common') || normalized.includes('spec/shared'));
215
+ });
216
+ (0, node_test_1.test)('external file with absolute path', () => {
217
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
218
+ mainSpecPath,
219
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
220
+ refValuePath: '/Users/user/Developer/my_app/openapi/shared/models.yaml',
221
+ outputModelsPath,
222
+ });
223
+ const normalized = normalizePath(result);
224
+ // Absolute paths are handled in default case
225
+ node_assert_1.strict.ok(typeof normalized === 'string');
226
+ });
227
+ (0, node_test_1.test)('EXTERNAL_FILE when path is outside outputModelsPath → returns fallback', () => {
228
+ const externalOutputPath = '/Users/user/Developer/other_project/generated/models';
229
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
230
+ mainSpecPath,
231
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
232
+ refValuePath: './users-list.yaml',
233
+ outputModelsPath: externalOutputPath,
234
+ });
235
+ // mapPathToTargetDirSafe finds common parent and still maps the path,
236
+ // so it returns relative path instead of fallback
237
+ node_assert_1.strict.equal(normalizePath(result), './spec/UsersList');
238
+ });
239
+ (0, node_test_1.test)('external file reference from main spec file', () => {
240
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
241
+ mainSpecPath,
242
+ parentFilePath: mainSpecPath,
243
+ refValuePath: './schemas/user.yaml',
244
+ outputModelsPath,
245
+ });
246
+ const normalized = normalizePath(result);
247
+ node_assert_1.strict.ok(normalized.includes('User') || normalized === './User');
248
+ });
47
249
  });
48
- (0, node_test_1.test)('deep nesting — the path is built correctly', () => {
49
- const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
50
- mainSpecPath,
51
- parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/very/deep/config/models.yaml#/components/schemas/ConfigDto',
52
- refValuePath: '#/components/schemas/ConfigDto',
53
- outputModelsPath,
54
- });
55
- node_assert_1.strict.equal(normalizePath(result), './spec/very/deep/config/ConfigDto');
250
+ (0, node_test_1.describe)('ABSOLUTE_PATH (default case)', () => {
251
+ (0, node_test_1.test)('absolute path to file → resolves correctly', () => {
252
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
253
+ mainSpecPath,
254
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
255
+ refValuePath: '/Users/user/Developer/my_app/openapi/shared/models/user.yaml',
256
+ outputModelsPath,
257
+ });
258
+ const normalized = normalizePath(result);
259
+ node_assert_1.strict.ok(typeof normalized === 'string' && normalized.length > 0);
260
+ });
261
+ (0, node_test_1.test)('absolute path when isPathToFile returns true', () => {
262
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn(() => false);
263
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn((path) => {
264
+ return path.includes('user.yaml');
265
+ });
266
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
267
+ mainSpecPath,
268
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
269
+ refValuePath: '/Users/user/Developer/my_app/openapi/shared/models/user.yaml',
270
+ outputModelsPath,
271
+ });
272
+ const normalized = normalizePath(result);
273
+ node_assert_1.strict.ok(typeof normalized === 'string');
274
+ });
275
+ (0, node_test_1.test)('absolute path when isPathToFile returns false (directory)', () => {
276
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn((path) => {
277
+ return path.includes('models');
278
+ });
279
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn(() => false);
280
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
281
+ mainSpecPath,
282
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
283
+ refValuePath: '/Users/user/Developer/my_app/openapi/shared/models',
284
+ outputModelsPath,
285
+ });
286
+ const normalized = normalizePath(result);
287
+ node_assert_1.strict.ok(typeof normalized === 'string');
288
+ });
289
+ (0, node_test_1.test)('absolute path when path is outside outputModelsPath → returns fallback', () => {
290
+ const externalOutputPath = '/Users/user/Developer/other_project/generated/models';
291
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn(() => false);
292
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn(() => true);
293
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
294
+ mainSpecPath,
295
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
296
+ refValuePath: '/Users/user/Developer/my_app/openapi/shared/models/user.yaml',
297
+ outputModelsPath: externalOutputPath,
298
+ });
299
+ // Should return fallback with basename
300
+ const normalized = normalizePath(result);
301
+ node_assert_1.strict.ok(normalized.includes('User') || normalized === './User');
302
+ });
303
+ (0, node_test_1.test)('absolute path with parentFilePath as directory', () => {
304
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn((path) => {
305
+ return path.includes('app');
306
+ });
307
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn((path) => {
308
+ return !path.includes('app');
309
+ });
310
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
311
+ mainSpecPath,
312
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app',
313
+ refValuePath: '/Users/user/Developer/my_app/openapi/shared/models/user.yaml',
314
+ outputModelsPath,
315
+ });
316
+ const normalized = normalizePath(result);
317
+ node_assert_1.strict.ok(typeof normalized === 'string');
318
+ });
56
319
  });
57
- (0, node_test_1.test)('the link to the file without the extension → is processed correctly', () => {
58
- const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
59
- mainSpecPath,
60
- parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/shared.yaml',
61
- refValuePath: './common/error',
62
- outputModelsPath,
63
- });
64
- // error → Error (getClassName)
65
- node_assert_1.strict.equal(normalizePath(result), './spec/common/Error');
320
+ (0, node_test_1.describe)('Edge cases', () => {
321
+ (0, node_test_1.test)('parentFilePath with fragment but refValuePath is external file', () => {
322
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
323
+ mainSpecPath,
324
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml#/components/schemas/Account',
325
+ refValuePath: './users-list.yaml',
326
+ outputModelsPath,
327
+ });
328
+ node_assert_1.strict.equal(normalizePath(result), './spec/UsersList');
329
+ });
330
+ (0, node_test_1.test)('refValuePath starts with parent baseName → removes prefix correctly', () => {
331
+ fileSystemHelpers_1.fileSystemHelpers.isDirectory = node_test_1.mock.fn(() => false);
332
+ fileSystemHelpers_1.fileSystemHelpers.isPathToFile = node_test_1.mock.fn(() => true);
333
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
334
+ mainSpecPath,
335
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
336
+ refValuePath: 'accountSpec.yaml/nested/model.yaml',
337
+ outputModelsPath,
338
+ });
339
+ const normalized = normalizePath(result);
340
+ node_assert_1.strict.ok(typeof normalized === 'string');
341
+ });
342
+ (0, node_test_1.test)('empty refValuePath with default handling', () => {
343
+ // parseRef returns LOCAL_FRAGMENT for empty/invalid refs
344
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
345
+ mainSpecPath,
346
+ parentFilePath: mainSpecPath,
347
+ refValuePath: '',
348
+ outputModelsPath,
349
+ });
350
+ const normalized = normalizePath(result);
351
+ node_assert_1.strict.ok(typeof normalized === 'string');
352
+ });
353
+ (0, node_test_1.test)('parentFilePath without filePath in parsed result', () => {
354
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
355
+ mainSpecPath,
356
+ parentFilePath: '#/components/schemas/Parent',
357
+ refValuePath: './child.yaml',
358
+ outputModelsPath,
359
+ });
360
+ const normalized = normalizePath(result);
361
+ node_assert_1.strict.ok(typeof normalized === 'string');
362
+ });
363
+ (0, node_test_1.test)('when absModelPath equals absOutputModelsPath', () => {
364
+ // This tests the condition: absModelPath !== absOutputModelsPath
365
+ const customOutputPath = '/Users/user/Developer/openapi-codegen/generated/models';
366
+ const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
367
+ mainSpecPath: '/Users/user/Developer/my_app/openapi/app/openapi_spec.yaml',
368
+ parentFilePath: '/Users/user/Developer/my_app/openapi/app/openapi_spec.yaml',
369
+ refValuePath: '#/components/schemas/MainUser',
370
+ outputModelsPath: customOutputPath,
371
+ });
372
+ const normalized = normalizePath(result);
373
+ node_assert_1.strict.ok(typeof normalized === 'string');
374
+ });
66
375
  });
67
376
  });
@@ -6,8 +6,8 @@ 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 sort_1 = require("../sort");
9
- (0, node_test_1.describe)('sort', () => {
10
- (0, node_test_1.test)('@unit: should return correct index', () => {
9
+ (0, node_test_1.describe)('@unit: sort', () => {
10
+ (0, node_test_1.test)('should return correct index', () => {
11
11
  node_assert_1.default.strictEqual((0, sort_1.sort)('a', 'b'), -1);
12
12
  node_assert_1.default.strictEqual((0, sort_1.sort)('b', 'a'), 1);
13
13
  node_assert_1.default.strictEqual((0, sort_1.sort)('a', 'a'), 0);
@@ -7,9 +7,9 @@ const node_assert_1 = __importDefault(require("node:assert"));
7
7
  const node_test_1 = require("node:test");
8
8
  const createOperationParameter_1 = require("../__mocks__/createOperationParameter");
9
9
  const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
10
- (0, node_test_1.describe)('sortByRequiredExtended', () => {
10
+ (0, node_test_1.describe)('@unit: sortByRequiredExtended', () => {
11
11
  // Tests for comparison between different groups
12
- (0, node_test_1.test)('@unit: must sort the groups in order: required, required-with-default, optional, optional-with-default', () => {
12
+ (0, node_test_1.test)('must sort the groups in order: required, required-with-default, optional, optional-with-default', () => {
13
13
  const params = [
14
14
  (0, createOperationParameter_1.createOperationParameter)('optional', { isRequired: false }),
15
15
  (0, createOperationParameter_1.createOperationParameter)('required', { isRequired: true }),
@@ -26,7 +26,7 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
26
26
  ]);
27
27
  });
28
28
  // Comparison tests within groups
29
- (0, node_test_1.test)('@unit: must sort by name within the required group', () => {
29
+ (0, node_test_1.test)('must sort by name within the required group', () => {
30
30
  const params = [
31
31
  (0, createOperationParameter_1.createOperationParameter)('Beta', { isRequired: true }),
32
32
  (0, createOperationParameter_1.createOperationParameter)('Alpha', { isRequired: true }),
@@ -36,7 +36,7 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
36
36
  const sortedNames = params.map(p => p.name);
37
37
  node_assert_1.default.deepStrictEqual(sortedNames, ['Alpha', 'Beta', 'Gamma']);
38
38
  });
39
- (0, node_test_1.test)('@unit: must sort by name within the required-with-default group', () => {
39
+ (0, node_test_1.test)('must sort by name within the required-with-default group', () => {
40
40
  const params = [
41
41
  (0, createOperationParameter_1.createOperationParameter)('Zeta', { isRequired: true, default: 'def' }),
42
42
  (0, createOperationParameter_1.createOperationParameter)('Beta', { isRequired: true, default: 'def' }),
@@ -46,7 +46,7 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
46
46
  const sortedNames = params.map(p => p.name);
47
47
  node_assert_1.default.deepStrictEqual(sortedNames, ['Alpha', 'Beta', 'Zeta']);
48
48
  });
49
- (0, node_test_1.test)('@unit: it should sort by name within the optional group', () => {
49
+ (0, node_test_1.test)('it should sort by name within the optional group', () => {
50
50
  const params = [
51
51
  (0, createOperationParameter_1.createOperationParameter)('Second', { isRequired: false }),
52
52
  (0, createOperationParameter_1.createOperationParameter)('First', { isRequired: false }),
@@ -56,7 +56,7 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
56
56
  const sortedNames = params.map(p => p.name);
57
57
  node_assert_1.default.deepStrictEqual(sortedNames, ['First', 'Second', 'Third']);
58
58
  });
59
- (0, node_test_1.test)('@unit: it must sort by name within the optional-with-default group', () => {
59
+ (0, node_test_1.test)('it must sort by name within the optional-with-default group', () => {
60
60
  const params = [
61
61
  (0, createOperationParameter_1.createOperationParameter)('Dog', { isRequired: false, default: 'def' }),
62
62
  (0, createOperationParameter_1.createOperationParameter)('Cat', { isRequired: false, default: 'def' }),
@@ -76,7 +76,7 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
76
76
  ['optional', 'optional-with-default']
77
77
  ];
78
78
  for (const [groupA, groupB] of groupPairs) {
79
- (0, node_test_1.test)(`@unit: must place "${groupA}" before "${groupB}"`, () => {
79
+ (0, node_test_1.test)(`must place "${groupA}" before "${groupB}"`, () => {
80
80
  const paramA = (0, createOperationParameter_1.createOperationParameter)('A', createOptionsForGroup(groupA));
81
81
  const paramB = (0, createOperationParameter_1.createOperationParameter)('B', createOptionsForGroup(groupB));
82
82
  // A should go before B
@@ -99,19 +99,19 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
99
99
  }
100
100
  }
101
101
  // Tests for equal groups
102
- (0, node_test_1.test)('@unit: it should return 0 for identical parameters.', () => {
102
+ (0, node_test_1.test)('it should return 0 for identical parameters.', () => {
103
103
  const param1 = (0, createOperationParameter_1.createOperationParameter)('Test', { isRequired: true });
104
104
  const param2 = (0, createOperationParameter_1.createOperationParameter)('Test', { isRequired: true });
105
105
  node_assert_1.default.strictEqual((0, sortByRequiredExtended_1.sortByRequiredExtended)(param1, param2), 0);
106
106
  });
107
107
  // A test for processing parameters with the same name
108
- (0, node_test_1.test)('@unit: it should return 0 for parameters with the same name in the same group.', () => {
108
+ (0, node_test_1.test)('it should return 0 for parameters with the same name in the same group.', () => {
109
109
  const param1 = (0, createOperationParameter_1.createOperationParameter)('Same', { isRequired: false, default: 'def' });
110
110
  const param2 = (0, createOperationParameter_1.createOperationParameter)('Same', { isRequired: false, default: 'def' });
111
111
  node_assert_1.default.strictEqual((0, sortByRequiredExtended_1.sortByRequiredExtended)(param1, param2), 0);
112
112
  });
113
113
  // A test for mixed groups with the same priorities
114
- (0, node_test_1.test)('@unit: It should sort only by name for identical groups.', () => {
114
+ (0, node_test_1.test)('It should sort only by name for identical groups.', () => {
115
115
  const params = [
116
116
  (0, createOperationParameter_1.createOperationParameter)('Beta', { isRequired: false }), // optional
117
117
  (0, createOperationParameter_1.createOperationParameter)('Alpha', { isRequired: true }), // required
@@ -132,7 +132,7 @@ const sortByRequiredExtended_1 = require("../sortByRequiredExtended");
132
132
  ]);
133
133
  });
134
134
  // A test for borderline cases
135
- (0, node_test_1.test)('@unit: It must handle empty names correctly.', () => {
135
+ (0, node_test_1.test)('It must handle empty names correctly.', () => {
136
136
  const params = [
137
137
  (0, createOperationParameter_1.createOperationParameter)('', { isRequired: true }),
138
138
  (0, createOperationParameter_1.createOperationParameter)('B', { isRequired: true }),
@@ -7,57 +7,57 @@ const strict_1 = __importDefault(require("node:assert/strict"));
7
7
  const node_test_1 = require("node:test");
8
8
  const createOperationParameter_1 = require("../__mocks__/createOperationParameter");
9
9
  const sortByRequiredSimple_1 = require("../sortByRequiredSimple");
10
- (0, node_test_1.describe)('sortByRequiredSimple', () => {
11
- (0, node_test_1.test)('@unit: must put required parameters without default before optional ones.', () => {
10
+ (0, node_test_1.describe)('@unit: sortByRequiredSimple', () => {
11
+ (0, node_test_1.test)('must put required parameters without default before optional ones.', () => {
12
12
  const a = (0, createOperationParameter_1.createOperationParameter)('required', { isRequired: true });
13
13
  const b = (0, createOperationParameter_1.createOperationParameter)('optional', { isRequired: false });
14
14
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), -1);
15
15
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(b, a), 1);
16
16
  });
17
- (0, node_test_1.test)('@unit: it must consider two required parameters equal without default', () => {
17
+ (0, node_test_1.test)('it must consider two required parameters equal without default', () => {
18
18
  const a = (0, createOperationParameter_1.createOperationParameter)('A', { isRequired: true });
19
19
  const b = (0, createOperationParameter_1.createOperationParameter)('B', { isRequired: true });
20
20
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), 0);
21
21
  });
22
- (0, node_test_1.test)('@unit: It must consider two optional parameters equal.', () => {
22
+ (0, node_test_1.test)('It must consider two optional parameters equal.', () => {
23
23
  const a = (0, createOperationParameter_1.createOperationParameter)('A', { isRequired: false });
24
24
  const b = (0, createOperationParameter_1.createOperationParameter)('B', { isRequired: false });
25
25
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), 0);
26
26
  });
27
- (0, node_test_1.test)('@unit: must place the required ones without default before the required ones with default', () => {
27
+ (0, node_test_1.test)('must place the required ones without default before the required ones with default', () => {
28
28
  const a = (0, createOperationParameter_1.createOperationParameter)('required', { isRequired: true });
29
29
  const b = (0, createOperationParameter_1.createOperationParameter)('required-with-default', { isRequired: true, default: 'test' });
30
30
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), -1);
31
31
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(b, a), 1);
32
32
  });
33
- (0, node_test_1.test)('@unit: it must consider two required parameters with default equal.', () => {
33
+ (0, node_test_1.test)('it must consider two required parameters with default equal.', () => {
34
34
  const a = (0, createOperationParameter_1.createOperationParameter)('A', { isRequired: true, default: 'a' });
35
35
  const b = (0, createOperationParameter_1.createOperationParameter)('B', { isRequired: true, default: 'b' });
36
36
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), 0);
37
37
  });
38
- (0, node_test_1.test)('@unit: must place the required ones without default before the optional ones with default', () => {
38
+ (0, node_test_1.test)('must place the required ones without default before the optional ones with default', () => {
39
39
  const a = (0, createOperationParameter_1.createOperationParameter)('required', { isRequired: true });
40
40
  const b = (0, createOperationParameter_1.createOperationParameter)('optional-with-default', { isRequired: false, default: 'test' });
41
41
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), -1);
42
42
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(b, a), 1);
43
43
  });
44
- (0, node_test_1.test)('@unit: it must consider two optional parameters with default equal.', () => {
44
+ (0, node_test_1.test)('it must consider two optional parameters with default equal.', () => {
45
45
  const a = (0, createOperationParameter_1.createOperationParameter)('A', { isRequired: false, default: 'a' });
46
46
  const b = (0, createOperationParameter_1.createOperationParameter)('B', { isRequired: false, default: 'b' });
47
47
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), 0);
48
48
  });
49
- (0, node_test_1.test)('@unit: it should consider mandatory with default and optional without default to be equal', () => {
49
+ (0, node_test_1.test)('it should consider mandatory with default and optional without default to be equal', () => {
50
50
  const a = (0, createOperationParameter_1.createOperationParameter)('required-with-default', { isRequired: true, default: 'test' });
51
51
  const b = (0, createOperationParameter_1.createOperationParameter)('optional', { isRequired: false });
52
52
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), 0);
53
53
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(b, a), 0);
54
54
  });
55
- (0, node_test_1.test)('@unit: it must work correctly with undefined values.', () => {
55
+ (0, node_test_1.test)('it must work correctly with undefined values.', () => {
56
56
  const a = (0, createOperationParameter_1.createOperationParameter)('required', { isRequired: true });
57
57
  const b = (0, createOperationParameter_1.createOperationParameter)('required-with-default', { isRequired: true, default: undefined });
58
58
  strict_1.default.strictEqual((0, sortByRequiredSimple_1.sortByRequiredSimple)(a, b), 0);
59
59
  });
60
- (0, node_test_1.test)('@unit: should sort params', () => {
60
+ (0, node_test_1.test)('should sort params', () => {
61
61
  const optionalParameter = (0, createOperationParameter_1.createOperationParameter)('optional', { description: '3. Optional parameter with no default value', isRequired: false });
62
62
  const optionalParameterWithDefault = (0, createOperationParameter_1.createOperationParameter)('optional-with-default', {
63
63
  description: '4. An optional parameter with a default value',
@@ -6,8 +6,8 @@ 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 sortModelsByName_1 = require("../sortModelsByName");
9
- (0, node_test_1.describe)('sortModelsByName', () => {
10
- (0, node_test_1.test)('@unit: should return sorted list', () => {
9
+ (0, node_test_1.describe)('@unit: sortModelsByName', () => {
10
+ (0, node_test_1.test)('should return sorted list', () => {
11
11
  const john = {
12
12
  alias: '',
13
13
  path: '',
@@ -6,8 +6,8 @@ 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 sortServicesByName_1 = require("../sortServicesByName");
9
- (0, node_test_1.describe)('sortServicesByName', () => {
10
- (0, node_test_1.test)('@unit: should return sorted list', () => {
9
+ (0, node_test_1.describe)('@unit: sortServicesByName', () => {
10
+ (0, node_test_1.test)('should return sorted list', () => {
11
11
  const john = {
12
12
  name: 'John',
13
13
  originName: 'JohnService',