ts-openapi-codegen 1.0.0-beta.8 → 2.0.0-beta.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 (375) 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 +20 -37
  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 +4 -0
  62. package/dist/common/Consts.d.ts.map +1 -1
  63. package/dist/common/Consts.js +31 -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 +7 -39
  70. package/dist/common/LoggerMessages.d.ts +64 -0
  71. package/dist/common/LoggerMessages.d.ts.map +1 -0
  72. package/dist/common/LoggerMessages.js +82 -0
  73. package/dist/common/TRawOptions.d.ts +40 -0
  74. package/dist/common/TRawOptions.d.ts.map +1 -0
  75. package/dist/common/UpdateNotifier.d.ts +36 -2
  76. package/dist/common/UpdateNotifier.d.ts.map +1 -1
  77. package/dist/common/UpdateNotifier.js +150 -57
  78. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +8 -0
  79. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -0
  80. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +31 -0
  81. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +8 -0
  82. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -0
  83. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +33 -0
  84. package/dist/common/VersionedSchema/Enums.d.ts +2 -1
  85. package/dist/common/VersionedSchema/Enums.d.ts.map +1 -1
  86. package/dist/common/VersionedSchema/Enums.js +1 -0
  87. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -1
  88. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.js +10 -19
  89. package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
  90. package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +10 -10
  91. package/dist/common/VersionedSchema/Types.d.ts +10 -0
  92. package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
  93. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +3 -0
  94. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +1 -0
  95. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +28 -0
  96. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts +7 -0
  97. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +1 -0
  98. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.js +42 -0
  99. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +3 -0
  100. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +1 -0
  101. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +10 -0
  102. package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +11 -0
  103. package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -0
  104. package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +19 -0
  105. package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts +7 -0
  106. package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -0
  107. package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +15 -0
  108. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +1 -7
  109. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
  110. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +3 -0
  111. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -0
  112. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +14 -0
  113. package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts +2 -0
  114. package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts.map +1 -0
  115. package/dist/common/VersionedSchema/Utils/getKeyByMapValue.js +11 -0
  116. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +5 -2
  117. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
  118. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +31 -17
  119. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +1 -0
  120. package/dist/common/utils/__tests__/convertArrayToObject.test.d.ts.map +1 -0
  121. package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.js +14 -14
  122. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +1 -0
  123. package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.js +5 -5
  124. package/dist/common/utils/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +1 -0
  125. package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.js +4 -4
  126. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +1 -0
  127. package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.js +4 -4
  128. package/dist/common/utils/__tests__/getUniqueObjectKeys.test.d.ts.map +1 -0
  129. package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.js +5 -5
  130. package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +1 -0
  131. package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.js +5 -5
  132. package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +1 -0
  133. package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.js +21 -15
  134. package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +1 -0
  135. package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.js +13 -9
  136. package/dist/common/utils/__tests__/pathHelpers.test.d.ts.map +1 -0
  137. package/dist/{core → common}/utils/__tests__/pathHelpers.test.js +8 -8
  138. package/dist/common/utils/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +1 -0
  139. package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.js +5 -5
  140. package/dist/common/utils/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +1 -0
  141. package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.js +5 -5
  142. package/dist/common/utils/convertArrayToObject.d.ts +2 -0
  143. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -0
  144. package/dist/common/{Utils.js → utils/convertArrayToObject.js} +0 -20
  145. package/dist/{core/utils/fileSystem.d.ts → common/utils/fileSystemHelpers.d.ts} +8 -5
  146. package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -0
  147. package/dist/common/utils/fileSystemHelpers.js +85 -0
  148. package/dist/common/utils/format.d.ts +3 -0
  149. package/dist/common/utils/format.d.ts.map +1 -0
  150. package/dist/{core → common}/utils/format.js +2 -2
  151. package/dist/common/utils/loadConfigIfExists.d.ts +2 -0
  152. package/dist/common/utils/loadConfigIfExists.d.ts.map +1 -0
  153. package/dist/common/utils/loadConfigIfExists.js +22 -0
  154. package/dist/common/utils/pathHelpers.d.ts +6 -0
  155. package/dist/common/utils/pathHelpers.d.ts.map +1 -0
  156. package/dist/{core → common}/utils/pathHelpers.js +16 -20
  157. package/dist/common/utils/safeHasOwn.d.ts +2 -0
  158. package/dist/common/utils/safeHasOwn.d.ts.map +1 -0
  159. package/dist/common/utils/safeHasOwn.js +9 -0
  160. package/dist/core/Context.d.ts.map +1 -1
  161. package/dist/core/Context.js +3 -3
  162. package/dist/core/OpenApiClient.d.ts +13 -0
  163. package/dist/core/OpenApiClient.d.ts.map +1 -0
  164. package/dist/core/OpenApiClient.js +175 -0
  165. package/dist/core/WriteClient.d.ts +1 -1
  166. package/dist/core/WriteClient.d.ts.map +1 -1
  167. package/dist/core/WriteClient.js +20 -20
  168. package/dist/core/__tests__/WriteClient.test.js +61 -60
  169. package/dist/core/api/v2/Parser.d.ts.map +1 -1
  170. package/dist/core/api/v2/Parser.js +2 -9
  171. package/dist/core/api/v2/parser/__tests__/getServer.test.js +2 -2
  172. package/dist/core/api/v2/parser/__tests__/getType.test.js +3 -3
  173. package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
  174. package/dist/core/api/v2/parser/getModelProperties.js +2 -5
  175. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  176. package/dist/core/api/v2/parser/getModels.js +2 -1
  177. package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
  178. package/dist/core/api/v2/parser/getOperationParameter.js +2 -1
  179. package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
  180. package/dist/core/api/v2/parser/getOperationResponse.js +2 -5
  181. package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
  182. package/dist/core/api/v2/parser/getOperationResponses.js +2 -5
  183. package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
  184. package/dist/core/api/v2/parser/getServices.js +2 -5
  185. package/dist/core/api/v2/parser/getType.js +4 -4
  186. package/dist/core/api/v3/Parser.d.ts +1 -1
  187. package/dist/core/api/v3/Parser.d.ts.map +1 -1
  188. package/dist/core/api/v3/Parser.js +2 -9
  189. package/dist/core/api/v3/parser/__tests__/getServer.test.js +3 -3
  190. package/dist/core/api/v3/parser/__tests__/getType.test.js +3 -3
  191. package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
  192. package/dist/core/api/v3/parser/getModelProperties.js +2 -5
  193. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  194. package/dist/core/api/v3/parser/getModels.js +2 -1
  195. package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
  196. package/dist/core/api/v3/parser/getOperationResponse.js +2 -5
  197. package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
  198. package/dist/core/api/v3/parser/getOperationResponses.js +2 -5
  199. package/dist/core/api/v3/parser/getServer.d.ts.map +1 -1
  200. package/dist/core/api/v3/parser/getServer.js +2 -5
  201. package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
  202. package/dist/core/api/v3/parser/getServices.js +2 -5
  203. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  204. package/dist/core/api/v3/parser/getType.js +5 -13
  205. package/dist/core/index.d.ts +2 -2
  206. package/dist/core/index.d.ts.map +1 -1
  207. package/dist/core/index.js +6 -161
  208. package/dist/core/types/Consts.d.ts +5 -1
  209. package/dist/core/types/Consts.d.ts.map +1 -1
  210. package/dist/core/types/Consts.js +6 -2
  211. package/dist/core/types/base/Root.model.d.ts +1 -0
  212. package/dist/core/types/base/Root.model.d.ts.map +1 -1
  213. package/dist/core/utils/__tests__/escapeDescription.test.js +3 -3
  214. package/dist/core/utils/__tests__/escapeName.test.js +2 -2
  215. package/dist/core/utils/__tests__/flatMap.test.js +2 -2
  216. package/dist/core/utils/__tests__/getAbsolutePath.test.js +6 -6
  217. package/dist/core/utils/__tests__/getClassName.test.js +2 -2
  218. package/dist/core/utils/__tests__/getComment.test.js +2 -2
  219. package/dist/core/utils/__tests__/getEnumFromDescription.test.js +2 -2
  220. package/dist/core/utils/__tests__/getFileName.test.js +2 -2
  221. package/dist/core/utils/__tests__/getGatheringRefs.test.js +2 -2
  222. package/dist/core/utils/__tests__/getMappedType.test.js +2 -2
  223. package/dist/core/utils/__tests__/getModelNames.test.js +2 -2
  224. package/dist/core/utils/__tests__/getOpenApiVersion.test.js +2 -2
  225. package/dist/core/utils/__tests__/getOperationName.test.js +2 -2
  226. package/dist/core/utils/__tests__/getOperationParameterName.test.js +2 -2
  227. package/dist/core/utils/__tests__/getOperationPath.test.js +2 -2
  228. package/dist/core/utils/__tests__/getOperationResponseCode.test.js +2 -2
  229. package/dist/core/utils/__tests__/getPattern.test.js +2 -2
  230. package/dist/core/utils/__tests__/getRefFromSchema.test.js +2 -2
  231. package/dist/core/utils/__tests__/getRefs.test.js +2 -2
  232. package/dist/core/utils/__tests__/getRelativeModelPath.test.js +3 -3
  233. package/dist/core/utils/__tests__/getServiceClassName.test.js +2 -2
  234. package/dist/core/utils/__tests__/getServiceNames.test.js +2 -2
  235. package/dist/core/utils/__tests__/getServiceVersion.test.js +2 -2
  236. package/dist/core/utils/__tests__/isString.test.js +2 -2
  237. package/dist/core/utils/__tests__/isSubdirectory.test.js +10 -10
  238. package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
  239. package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +2 -2
  240. package/dist/core/utils/__tests__/replaceString.test.js +2 -2
  241. package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +360 -51
  242. package/dist/core/utils/__tests__/sort.test.js +2 -2
  243. package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +11 -11
  244. package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +11 -11
  245. package/dist/core/utils/__tests__/sortModelsByName.test.js +2 -2
  246. package/dist/core/utils/__tests__/sortServicesByName.test.js +2 -2
  247. package/dist/core/utils/__tests__/stripNamespace.test.js +2 -2
  248. package/dist/core/utils/__tests__/unique.test.js +2 -2
  249. package/dist/core/utils/__tests__/writeClientCore.test.js +52 -50
  250. package/dist/core/utils/__tests__/writeClientFullIndex.test.js +39 -37
  251. package/dist/core/utils/__tests__/writeClientModels.test.js +65 -63
  252. package/dist/core/utils/__tests__/writeClientSchemas.test.js +65 -63
  253. package/dist/core/utils/__tests__/writeClientServices.test.js +60 -58
  254. package/dist/core/utils/appendUniqueLinesToFile.js +4 -4
  255. package/dist/core/utils/createNormalizedRef.js +2 -2
  256. package/dist/core/utils/getAbsolutePath.js +3 -3
  257. package/dist/core/utils/getModelNameWithPrefix.d.ts +3 -0
  258. package/dist/core/utils/getModelNameWithPrefix.d.ts.map +1 -0
  259. package/dist/core/utils/getModelNameWithPrefix.js +15 -0
  260. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  261. package/dist/core/utils/getOpenApiSpec.js +4 -4
  262. package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
  263. package/dist/core/utils/getOutputPaths.js +6 -6
  264. package/dist/core/utils/getPattern.d.ts.map +1 -1
  265. package/dist/core/utils/getPattern.js +2 -1
  266. package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
  267. package/dist/core/utils/getRelativeModelPath.js +2 -6
  268. package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
  269. package/dist/core/utils/isSubdirectory.js +4 -3
  270. package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -1
  271. package/dist/core/utils/mapPathToTargetDirSafe.js +11 -12
  272. package/dist/core/utils/modelHelpers.d.ts.map +1 -1
  273. package/dist/core/utils/modelHelpers.js +18 -6
  274. package/dist/core/utils/normalizeString.d.ts +2 -0
  275. package/dist/core/utils/normalizeString.d.ts.map +1 -0
  276. package/dist/core/utils/normalizeString.js +14 -0
  277. package/dist/core/utils/normalizedAbsolutePath.js +3 -3
  278. package/dist/core/utils/parseRef.d.ts.map +1 -1
  279. package/dist/core/utils/parseRef.js +7 -10
  280. package/dist/core/utils/precompileTemplates.js +14 -10
  281. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  282. package/dist/core/utils/registerHandlebarHelpers.js +24 -0
  283. package/dist/core/utils/replaceString.d.ts.map +1 -1
  284. package/dist/core/utils/replaceString.js +2 -1
  285. package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
  286. package/dist/core/utils/resolveRefPath.js +3 -3
  287. package/dist/core/utils/resolveRefToImportPath.d.ts +8 -2
  288. package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -1
  289. package/dist/core/utils/resolveRefToImportPath.js +91 -31
  290. package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
  291. package/dist/core/utils/serviceHelpers.js +2 -1
  292. package/dist/core/utils/stripNamespace.js +5 -5
  293. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  294. package/dist/core/utils/writeClientCore.js +12 -12
  295. package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
  296. package/dist/core/utils/writeClientCoreIndex.js +2 -2
  297. package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
  298. package/dist/core/utils/writeClientFullIndex.js +4 -4
  299. package/dist/core/utils/writeClientModels.d.ts.map +1 -1
  300. package/dist/core/utils/writeClientModels.js +7 -7
  301. package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
  302. package/dist/core/utils/writeClientModelsIndex.js +2 -2
  303. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  304. package/dist/core/utils/writeClientSchemas.js +7 -7
  305. package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
  306. package/dist/core/utils/writeClientSchemasIndex.js +2 -2
  307. package/dist/core/utils/writeClientServices.d.ts.map +1 -1
  308. package/dist/core/utils/writeClientServices.js +5 -5
  309. package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
  310. package/dist/core/utils/writeClientServicesIndex.js +2 -2
  311. package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
  312. package/dist/core/utils/writeClientSimpleIndex.js +4 -4
  313. package/dist/templatesCompiled/client/exportModel.js +4 -4
  314. package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
  315. package/dist/templatesCompiled/client/exportService.js +12 -13
  316. package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
  317. package/dist/templatesCompiled/client/indexFull.js +35 -29
  318. package/dist/templatesCompiled/client/partials/parameters.d.ts +3 -2
  319. package/dist/templatesCompiled/client/partials/parameters.d.ts.map +1 -1
  320. package/dist/templatesCompiled/client/partials/parameters.js +25 -20
  321. package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts +4 -2
  322. package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts.map +1 -1
  323. package/dist/templatesCompiled/client/partials/parametersDefinition.js +31 -10
  324. package/package.json +15 -13
  325. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +0 -5
  326. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +0 -1
  327. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +0 -45
  328. package/dist/common/Options.d.ts +0 -26
  329. package/dist/common/Options.d.ts.map +0 -1
  330. package/dist/common/Utils.d.ts +0 -3
  331. package/dist/common/Utils.d.ts.map +0 -1
  332. package/dist/common/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
  333. package/dist/common/__tests__/convertArrayToObject.test.d.ts.map +0 -1
  334. package/dist/common/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
  335. package/dist/common/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +0 -1
  336. package/dist/common/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
  337. package/dist/common/__tests__/getUniqueObjectKeys.test.d.ts.map +0 -1
  338. package/dist/common/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
  339. package/dist/common/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
  340. package/dist/common/__tests__/migrationForOptions.test.d.ts.map +0 -1
  341. package/dist/common/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +0 -1
  342. package/dist/common/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +0 -1
  343. package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts +0 -2
  344. package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts.map +0 -1
  345. package/dist/core/utils/__tests__/getRelativeModelImportPath.test.js +0 -82
  346. package/dist/core/utils/__tests__/pathHelpers.test.d.ts.map +0 -1
  347. package/dist/core/utils/fileSystem.d.ts.map +0 -1
  348. package/dist/core/utils/fileSystem.js +0 -26
  349. package/dist/core/utils/format.d.ts +0 -2
  350. package/dist/core/utils/format.d.ts.map +0 -1
  351. package/dist/core/utils/getRelativeModelImportPath.d.ts +0 -9
  352. package/dist/core/utils/getRelativeModelImportPath.d.ts.map +0 -1
  353. package/dist/core/utils/getRelativeModelImportPath.js +0 -45
  354. package/dist/core/utils/isDirectory.d.ts +0 -2
  355. package/dist/core/utils/isDirectory.d.ts.map +0 -1
  356. package/dist/core/utils/isDirectory.js +0 -13
  357. package/dist/core/utils/pathHelpers.d.ts +0 -7
  358. package/dist/core/utils/pathHelpers.d.ts.map +0 -1
  359. package/dist/core/utils/prepareOptions.d.ts +0 -8
  360. package/dist/core/utils/prepareOptions.d.ts.map +0 -1
  361. package/dist/core/utils/prepareOptions.js +0 -31
  362. /package/dist/common/{Options.js → TRawOptions.js} +0 -0
  363. /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.d.ts +0 -0
  364. /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.js +0 -0
  365. /package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.d.ts +0 -0
  366. /package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.d.ts +0 -0
  367. /package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.d.ts +0 -0
  368. /package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.d.ts +0 -0
  369. /package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.d.ts +0 -0
  370. /package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.d.ts +0 -0
  371. /package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.d.ts +0 -0
  372. /package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.d.ts +0 -0
  373. /package/dist/{core → common}/utils/__tests__/pathHelpers.test.d.ts +0 -0
  374. /package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.d.ts +0 -0
  375. /package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.d.ts +0 -0
@@ -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 getOperationPath_1 = require("../getOperationPath");
9
- (0, node_test_1.describe)('getOperationPath', () => {
10
- (0, node_test_1.test)('@unit: should produce correct result', () => {
9
+ (0, node_test_1.describe)('@unit: getOperationPath', () => {
10
+ (0, node_test_1.test)('should produce correct result', () => {
11
11
  node_assert_1.default.strictEqual((0, getOperationPath_1.getOperationPath)('/api/v{api-version}/list/{id}/{type}'), '/api/v{api-version}/list/${id}/${type}');
12
12
  node_assert_1.default.strictEqual((0, getOperationPath_1.getOperationPath)('/api/v{api-version}/list/{id}'), '/api/v{api-version}/list/${id}');
13
13
  node_assert_1.default.strictEqual((0, getOperationPath_1.getOperationPath)('/api/v1/list/{id}'), '/api/v1/list/${id}');
@@ -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 getOperationResponseCode_1 = require("../getOperationResponseCode");
9
- (0, node_test_1.describe)('getOperationResponseCode', () => {
10
- (0, node_test_1.test)('@unit: should produce correct result', () => {
9
+ (0, node_test_1.describe)('@unit: getOperationResponseCode', () => {
10
+ (0, node_test_1.test)('should produce correct result', () => {
11
11
  node_assert_1.default.strictEqual((0, getOperationResponseCode_1.getOperationResponseCode)(''), null);
12
12
  node_assert_1.default.strictEqual((0, getOperationResponseCode_1.getOperationResponseCode)('default'), 200);
13
13
  node_assert_1.default.strictEqual((0, getOperationResponseCode_1.getOperationResponseCode)('200'), 200);
@@ -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 getPattern_1 = require("../getPattern");
9
- (0, node_test_1.describe)('getPattern', () => {
10
- (0, node_test_1.test)('@unit: should produce correct result', () => {
9
+ (0, node_test_1.describe)('@unit: getPattern', () => {
10
+ (0, node_test_1.test)('should produce correct result', () => {
11
11
  node_assert_1.default.strictEqual((0, getPattern_1.getPattern)(), undefined);
12
12
  node_assert_1.default.strictEqual((0, getPattern_1.getPattern)(''), '');
13
13
  node_assert_1.default.strictEqual((0, getPattern_1.getPattern)('^[a-zA-Z]'), '^[a-zA-Z]');
@@ -9,8 +9,8 @@ const getRefFromSchema_1 = require("../getRefFromSchema");
9
9
  const ContextMock = {
10
10
  get: () => undefined,
11
11
  };
12
- (0, node_test_1.describe)('getRefFromSchema', () => {
13
- node_test_1.test.skip('@unit: should obtain refs from all schemas', () => {
12
+ (0, node_test_1.describe)('@unit: getRefFromSchema', () => {
13
+ node_test_1.test.skip('should obtain refs from all schemas', () => {
14
14
  node_test_1.mock.method(ContextMock, 'get', ($ref) => {
15
15
  if ($ref === '#/components/requestBodies/SimpleRequestBodyWithModelWithCircularReference') {
16
16
  return {
@@ -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 getRefs_1 = require("../getRefs");
9
- (0, node_test_1.describe)('getRefs', () => {
10
- (0, node_test_1.test)('@unit: should return array of refs', () => {
9
+ (0, node_test_1.describe)('@unit: getRefs', () => {
10
+ (0, node_test_1.test)('should return array of refs', () => {
11
11
  const object = {
12
12
  name: 'NAME',
13
13
  $ref: '#/first/ref',
@@ -6,13 +6,13 @@ 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 getRelativeModelPath_1 = require("../getRelativeModelPath");
9
- (0, node_test_1.describe)('getRelativeModelPath', () => {
10
- (0, node_test_1.test)('@unit: hould return model relative path', () => {
9
+ node_test_1.describe.skip('@unit: getRelativeModelPath', () => {
10
+ (0, node_test_1.test)('hould return model relative path', () => {
11
11
  const modelRelativePath = '../../../models/truck';
12
12
  const result = (0, getRelativeModelPath_1.getRelativeModelPath)(undefined, modelRelativePath);
13
13
  node_assert_1.default.strictEqual(result, '../../../models/truck');
14
14
  });
15
- (0, node_test_1.test)('@unit: should return correct model relative path considering navigation symbols', () => {
15
+ (0, node_test_1.test)('should return correct model relative path considering navigation symbols', () => {
16
16
  const rootPath = '/home/generated';
17
17
  const modelRelativePath = '../../../models/truck';
18
18
  const result = (0, getRelativeModelPath_1.getRelativeModelPath)(rootPath, modelRelativePath);
@@ -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 getServiceClassName_1 = require("../getServiceClassName");
9
- (0, node_test_1.describe)('getServiceClassName', () => {
10
- (0, node_test_1.test)('@unit: should produce correct result', () => {
9
+ (0, node_test_1.describe)('@unit: getServiceClassName', () => {
10
+ (0, node_test_1.test)('should produce correct result', () => {
11
11
  node_assert_1.default.strictEqual((0, getServiceClassName_1.getServiceClassName)(''), '');
12
12
  node_assert_1.default.strictEqual((0, getServiceClassName_1.getServiceClassName)('FooBar'), 'FooBarService');
13
13
  node_assert_1.default.strictEqual((0, getServiceClassName_1.getServiceClassName)('Foo Bar'), 'FooBarService');
@@ -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 getServiceNames_1 = require("../getServiceNames");
9
- (0, node_test_1.describe)('getServiceNames', () => {
10
- (0, node_test_1.test)('@unit: should return sorted list', () => {
9
+ (0, node_test_1.describe)('@unit: getServiceNames', () => {
10
+ (0, node_test_1.test)('should return sorted list', () => {
11
11
  const john = {
12
12
  name: 'John',
13
13
  originName: 'JohnService',
@@ -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 getServiceVersion_1 = require("../getServiceVersion");
9
- (0, node_test_1.describe)('getServiceVersion', () => {
10
- (0, node_test_1.test)('@unit: should produce correct result', () => {
9
+ (0, node_test_1.describe)('@unit: getServiceVersion', () => {
10
+ (0, node_test_1.test)('should produce correct result', () => {
11
11
  node_assert_1.default.strictEqual((0, getServiceVersion_1.getServiceVersion)('1.0'), '1.0');
12
12
  node_assert_1.default.strictEqual((0, getServiceVersion_1.getServiceVersion)('v1.0'), '1.0');
13
13
  node_assert_1.default.strictEqual((0, getServiceVersion_1.getServiceVersion)('V1.0'), '1.0');
@@ -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 isString_1 = require("../isString");
9
- (0, node_test_1.describe)('isString', () => {
10
- (0, node_test_1.test)('@unit: should produce correct result', () => {
9
+ (0, node_test_1.describe)('@unit: isString', () => {
10
+ (0, node_test_1.test)('should produce correct result', () => {
11
11
  node_assert_1.default.ok((0, isString_1.isString)('foo'));
12
12
  node_assert_1.default.ok((0, isString_1.isString)('123'));
13
13
  node_assert_1.default.ok((0, isString_1.isString)('-1'));
@@ -5,16 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  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
- const path_1 = require("path");
8
+ const pathHelpers_1 = require("../../../common/utils/pathHelpers");
9
9
  const isSubdirectory_1 = require("../isSubdirectory");
10
- (0, node_test_1.describe)('isSubDirectory', () => {
11
- (0, node_test_1.test)('@unit: should return correct result', () => {
12
- node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('/'), (0, path_1.resolve)('/')), false);
13
- node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('.'), (0, path_1.resolve)('.')), false);
14
- node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('./project'), (0, path_1.resolve)('./project')), false);
15
- node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('./project'), (0, path_1.resolve)('../')), false);
16
- node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('./project'), (0, path_1.resolve)('../../')), false);
17
- node_assert_1.default.ok((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('./'), (0, path_1.resolve)('./output')));
18
- node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, path_1.resolve)('./'), (0, path_1.resolve)('../output')), false);
10
+ (0, node_test_1.describe)('@unit: isSubDirectory', () => {
11
+ node_test_1.test.skip('should return correct result', () => {
12
+ node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('/'), (0, pathHelpers_1.resolveHelper)('/')), false);
13
+ node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('.'), (0, pathHelpers_1.resolveHelper)('.')), false);
14
+ node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('./project'), (0, pathHelpers_1.resolveHelper)('./project')), false);
15
+ node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('./project'), (0, pathHelpers_1.resolveHelper)('../')), false);
16
+ node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('./project'), (0, pathHelpers_1.resolveHelper)('../../')), false);
17
+ node_assert_1.default.ok((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('./'), (0, pathHelpers_1.resolveHelper)('./output')));
18
+ node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0, pathHelpers_1.resolveHelper)('./'), (0, pathHelpers_1.resolveHelper)('../output')), false);
19
19
  });
20
20
  });
@@ -41,8 +41,8 @@ const node_test_1 = require("node:test");
41
41
  const Handlebars = __importStar(require("handlebars/runtime"));
42
42
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
43
43
  const registerHandlebarHelpers_1 = require("../registerHandlebarHelpers");
44
- (0, node_test_1.describe)('registerHandlebarHelpers', () => {
45
- (0, node_test_1.test)('@unit: should register the helpers', () => {
44
+ (0, node_test_1.describe)('@unit: registerHandlebarHelpers', () => {
45
+ (0, node_test_1.test)('should register the helpers', () => {
46
46
  (0, registerHandlebarHelpers_1.registerHandlebarHelpers)({
47
47
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
48
48
  useOptions: false,
@@ -40,8 +40,8 @@ const node_assert_1 = __importDefault(require("node:assert"));
40
40
  const node_test_1 = __importStar(require("node:test"));
41
41
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
42
42
  const registerHandlebarTemplates_1 = require("../registerHandlebarTemplates");
43
- (0, node_test_1.describe)('registerHandlebarTemplates', () => {
44
- (0, node_test_1.default)('@unit: should return correct templates', () => {
43
+ (0, node_test_1.describe)('@unit: registerHandlebarTemplates', () => {
44
+ (0, node_test_1.default)('should return correct templates', () => {
45
45
  const templates = (0, registerHandlebarTemplates_1.registerHandlebarTemplates)({
46
46
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
47
47
  useOptions: false,
@@ -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 replaceString_1 = require("../replaceString");
9
- (0, node_test_1.describe)('replaceString', () => {
10
- (0, node_test_1.test)('@unit: should replace', () => {
9
+ (0, node_test_1.describe)('@unit: replaceString', () => {
10
+ (0, node_test_1.test)('should replace', () => {
11
11
  node_assert_1.default.strictEqual((0, replaceString_1.replaceString)(''), '');
12
12
  node_assert_1.default.strictEqual((0, replaceString_1.replaceString)('fooBar'), 'fooBar');
13
13
  node_assert_1.default.strictEqual((0, replaceString_1.replaceString)('Foo/Bar'), 'Foo/Bar');
@@ -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
  });