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.
- package/README.md +221 -123
- package/README.rus.md +725 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +12 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +66 -0
- package/dist/cli/checkAndUpdateConfig/constants.d.ts +13 -0
- package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/constants.js +29 -0
- package/dist/cli/checkAndUpdateConfig/types.d.ts +20 -0
- package/dist/cli/checkAndUpdateConfig/types.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/types.js +12 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +12 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +56 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.js +11 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts +14 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.js +30 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts +17 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.js +29 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.js +11 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts +29 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +49 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +22 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts +17 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +53 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +34 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +41 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +18 -0
- package/dist/cli/generate/runGenerateOpenApi.d.ts +2 -2
- package/dist/cli/generate/runGenerateOpenApi.d.ts.map +1 -1
- package/dist/cli/generate/runGenerateOpenApi.js +12 -14
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +56 -30
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.js +11 -18
- package/dist/cli/interactive/confirmDialog.d.ts +17 -0
- package/dist/cli/interactive/confirmDialog.d.ts.map +1 -0
- package/dist/cli/interactive/confirmDialog.js +36 -0
- package/dist/cli/interactive/constants.d.ts +7 -0
- package/dist/cli/interactive/constants.d.ts.map +1 -0
- package/dist/cli/interactive/constants.js +25 -0
- package/dist/cli/interactive/selectDialog.d.ts +17 -0
- package/dist/cli/interactive/selectDialog.d.ts.map +1 -0
- package/dist/cli/interactive/selectDialog.js +43 -0
- package/dist/cli/interactive/types.d.ts +40 -0
- package/dist/cli/interactive/types.d.ts.map +1 -0
- package/dist/cli/interactive/types.js +12 -0
- package/dist/common/Consts.d.ts +23 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +28 -1
- package/dist/common/Enums.d.ts +4 -0
- package/dist/common/Enums.d.ts.map +1 -1
- package/dist/common/Enums.js +6 -1
- package/dist/common/Logger.d.ts +1 -1
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +5 -38
- package/dist/common/UpdateNotifier.d.ts +36 -2
- package/dist/common/UpdateNotifier.d.ts.map +1 -1
- package/dist/common/UpdateNotifier.js +150 -57
- package/dist/common/VersionedSchema/Types.d.ts +5 -0
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +1 -7
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +3 -0
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +14 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.js +11 -0
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +5 -2
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +22 -15
- package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +1 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.js +14 -14
- package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.js +5 -5
- package/dist/common/utils/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.js +4 -4
- package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.js +4 -4
- package/dist/common/utils/__tests__/getUniqueObjectKeys.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.js +5 -5
- package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.js +5 -5
- package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.js +21 -15
- package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.js +13 -9
- package/dist/common/utils/__tests__/pathHelpers.test.d.ts.map +1 -0
- package/dist/{core → common}/utils/__tests__/pathHelpers.test.js +8 -8
- package/dist/common/utils/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.js +5 -5
- package/dist/common/utils/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.js +5 -5
- package/dist/common/utils/convertArrayToObject.d.ts +2 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -0
- package/dist/common/{Utils.js → utils/convertArrayToObject.js} +0 -20
- package/dist/{core/utils/fileSystem.d.ts → common/utils/fileSystemHelpers.d.ts} +8 -5
- package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -0
- package/dist/common/utils/fileSystemHelpers.js +85 -0
- package/dist/common/utils/format.d.ts +3 -0
- package/dist/common/utils/format.d.ts.map +1 -0
- package/dist/{core → common}/utils/format.js +2 -2
- package/dist/common/utils/loadConfigIfExists.d.ts +2 -0
- package/dist/common/utils/loadConfigIfExists.d.ts.map +1 -0
- package/dist/common/utils/loadConfigIfExists.js +22 -0
- package/dist/common/utils/pathHelpers.d.ts +6 -0
- package/dist/common/utils/pathHelpers.d.ts.map +1 -0
- package/dist/{core → common}/utils/pathHelpers.js +16 -20
- package/dist/common/utils/safeHasOwn.d.ts +2 -0
- package/dist/common/utils/safeHasOwn.d.ts.map +1 -0
- package/dist/common/utils/safeHasOwn.js +9 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +3 -3
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +18 -18
- package/dist/core/__tests__/WriteClient.test.js +61 -60
- package/dist/core/api/v2/Parser.d.ts.map +1 -1
- package/dist/core/api/v2/Parser.js +2 -9
- package/dist/core/api/v2/parser/__tests__/getServer.test.js +2 -2
- package/dist/core/api/v2/parser/__tests__/getType.test.js +3 -3
- package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModelProperties.js +2 -5
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +2 -1
- package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.js +2 -1
- package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.js +2 -5
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +2 -5
- package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getServices.js +2 -5
- package/dist/core/api/v2/parser/getType.js +4 -4
- package/dist/core/api/v3/Parser.d.ts +1 -1
- package/dist/core/api/v3/Parser.d.ts.map +1 -1
- package/dist/core/api/v3/Parser.js +2 -9
- package/dist/core/api/v3/parser/__tests__/getServer.test.js +3 -3
- package/dist/core/api/v3/parser/__tests__/getType.test.js +3 -3
- package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModelProperties.js +2 -5
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +2 -1
- package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponse.js +2 -5
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +2 -5
- package/dist/core/api/v3/parser/getServer.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServer.js +2 -5
- package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServices.js +2 -5
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +5 -13
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +34 -27
- package/dist/core/types/Consts.d.ts +5 -1
- package/dist/core/types/Consts.d.ts.map +1 -1
- package/dist/core/types/Consts.js +6 -2
- package/dist/core/types/base/Root.model.d.ts +1 -0
- package/dist/core/types/base/Root.model.d.ts.map +1 -1
- package/dist/core/utils/__tests__/escapeDescription.test.js +3 -3
- package/dist/core/utils/__tests__/escapeName.test.js +2 -2
- package/dist/core/utils/__tests__/flatMap.test.js +2 -2
- package/dist/core/utils/__tests__/getAbsolutePath.test.js +6 -6
- package/dist/core/utils/__tests__/getClassName.test.js +2 -2
- package/dist/core/utils/__tests__/getComment.test.js +2 -2
- package/dist/core/utils/__tests__/getEnumFromDescription.test.js +2 -2
- package/dist/core/utils/__tests__/getFileName.test.js +2 -2
- package/dist/core/utils/__tests__/getGatheringRefs.test.js +2 -2
- package/dist/core/utils/__tests__/getMappedType.test.js +2 -2
- package/dist/core/utils/__tests__/getModelNames.test.js +2 -2
- package/dist/core/utils/__tests__/getOpenApiVersion.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationName.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationParameterName.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationPath.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationResponseCode.test.js +2 -2
- package/dist/core/utils/__tests__/getPattern.test.js +2 -2
- package/dist/core/utils/__tests__/getRefFromSchema.test.js +2 -2
- package/dist/core/utils/__tests__/getRefs.test.js +2 -2
- package/dist/core/utils/__tests__/getRelativeModelPath.test.js +3 -3
- package/dist/core/utils/__tests__/getServiceClassName.test.js +2 -2
- package/dist/core/utils/__tests__/getServiceNames.test.js +2 -2
- package/dist/core/utils/__tests__/getServiceVersion.test.js +2 -2
- package/dist/core/utils/__tests__/isString.test.js +2 -2
- package/dist/core/utils/__tests__/isSubdirectory.test.js +10 -10
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
- package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +2 -2
- package/dist/core/utils/__tests__/replaceString.test.js +2 -2
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +360 -51
- package/dist/core/utils/__tests__/sort.test.js +2 -2
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +11 -11
- package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +11 -11
- package/dist/core/utils/__tests__/sortModelsByName.test.js +2 -2
- package/dist/core/utils/__tests__/sortServicesByName.test.js +2 -2
- package/dist/core/utils/__tests__/stripNamespace.test.js +2 -2
- package/dist/core/utils/__tests__/unique.test.js +2 -2
- package/dist/core/utils/__tests__/writeClientCore.test.js +52 -50
- package/dist/core/utils/__tests__/writeClientFullIndex.test.js +39 -37
- package/dist/core/utils/__tests__/writeClientModels.test.js +65 -63
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +65 -63
- package/dist/core/utils/__tests__/writeClientServices.test.js +60 -58
- package/dist/core/utils/appendUniqueLinesToFile.js +4 -4
- package/dist/core/utils/createNormalizedRef.js +2 -2
- package/dist/core/utils/getAbsolutePath.js +3 -3
- package/dist/core/utils/getModelNameWithPrefix.d.ts +3 -0
- package/dist/core/utils/getModelNameWithPrefix.d.ts.map +1 -0
- package/dist/core/utils/getModelNameWithPrefix.js +15 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +4 -4
- package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
- package/dist/core/utils/getOutputPaths.js +6 -6
- package/dist/core/utils/getPattern.d.ts.map +1 -1
- package/dist/core/utils/getPattern.js +2 -1
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
- package/dist/core/utils/getRelativeModelPath.js +2 -6
- package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
- package/dist/core/utils/isSubdirectory.js +4 -3
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -1
- package/dist/core/utils/mapPathToTargetDirSafe.js +11 -12
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +18 -6
- package/dist/core/utils/normalizeString.d.ts +2 -0
- package/dist/core/utils/normalizeString.d.ts.map +1 -0
- package/dist/core/utils/normalizeString.js +14 -0
- package/dist/core/utils/normalizedAbsolutePath.js +3 -3
- package/dist/core/utils/parseRef.d.ts.map +1 -1
- package/dist/core/utils/parseRef.js +7 -10
- package/dist/core/utils/precompileTemplates.js +14 -10
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +24 -0
- package/dist/core/utils/replaceString.d.ts.map +1 -1
- package/dist/core/utils/replaceString.js +2 -1
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefPath.js +3 -3
- package/dist/core/utils/resolveRefToImportPath.d.ts +8 -2
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefToImportPath.js +91 -31
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +2 -1
- package/dist/core/utils/stripNamespace.js +5 -5
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +12 -12
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +2 -2
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +4 -4
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +7 -7
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +2 -2
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +7 -7
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemasIndex.js +2 -2
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +5 -5
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientServicesIndex.js +2 -2
- package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSimpleIndex.js +4 -4
- package/dist/templatesCompiled/client/exportModel.js +4 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +12 -13
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +35 -29
- package/dist/templatesCompiled/client/partials/parameters.d.ts +3 -2
- package/dist/templatesCompiled/client/partials/parameters.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/parameters.js +25 -20
- package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts +4 -2
- package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/parametersDefinition.js +31 -10
- package/package.json +15 -13
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +0 -5
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +0 -1
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +0 -45
- package/dist/common/Utils.d.ts +0 -3
- package/dist/common/Utils.d.ts.map +0 -1
- package/dist/common/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
- package/dist/common/__tests__/convertArrayToObject.test.d.ts.map +0 -1
- package/dist/common/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
- package/dist/common/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +0 -1
- package/dist/common/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
- package/dist/common/__tests__/getUniqueObjectKeys.test.d.ts.map +0 -1
- package/dist/common/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
- package/dist/common/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
- package/dist/common/__tests__/migrationForOptions.test.d.ts.map +0 -1
- package/dist/common/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +0 -1
- package/dist/common/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts +0 -2
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.js +0 -82
- package/dist/core/utils/__tests__/pathHelpers.test.d.ts.map +0 -1
- package/dist/core/utils/fileSystem.d.ts.map +0 -1
- package/dist/core/utils/fileSystem.js +0 -26
- package/dist/core/utils/format.d.ts +0 -2
- package/dist/core/utils/format.d.ts.map +0 -1
- package/dist/core/utils/getRelativeModelImportPath.d.ts +0 -9
- package/dist/core/utils/getRelativeModelImportPath.d.ts.map +0 -1
- package/dist/core/utils/getRelativeModelImportPath.js +0 -45
- package/dist/core/utils/isDirectory.d.ts +0 -2
- package/dist/core/utils/isDirectory.d.ts.map +0 -1
- package/dist/core/utils/isDirectory.js +0 -13
- package/dist/core/utils/pathHelpers.d.ts +0 -7
- package/dist/core/utils/pathHelpers.d.ts.map +0 -1
- /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.js +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.d.ts +0 -0
- /package/dist/{core → common}/utils/__tests__/pathHelpers.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.d.ts +0 -0
- /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(
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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.
|
|
21
|
-
|
|
22
|
-
|
|
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.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)(
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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',
|