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.
- 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 +20 -37
- 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 +4 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +31 -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 +7 -39
- package/dist/common/LoggerMessages.d.ts +64 -0
- package/dist/common/LoggerMessages.d.ts.map +1 -0
- package/dist/common/LoggerMessages.js +82 -0
- package/dist/common/TRawOptions.d.ts +40 -0
- package/dist/common/TRawOptions.d.ts.map +1 -0
- 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/AllVersionedSchemas/AllMigrationPlans.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +31 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +33 -0
- package/dist/common/VersionedSchema/Enums.d.ts +2 -1
- package/dist/common/VersionedSchema/Enums.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Enums.js +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.js +10 -19
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +10 -10
- package/dist/common/VersionedSchema/Types.d.ts +10 -0
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +3 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +28 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts +7 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.js +42 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +10 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +11 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +19 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts +7 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +15 -0
- 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 +31 -17
- 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/OpenApiClient.d.ts +13 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -0
- package/dist/core/OpenApiClient.js +175 -0
- package/dist/core/WriteClient.d.ts +1 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +20 -20
- 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 +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -161
- 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/Options.d.ts +0 -26
- package/dist/common/Options.d.ts.map +0 -1
- 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/core/utils/prepareOptions.d.ts +0 -8
- package/dist/core/utils/prepareOptions.d.ts.map +0 -1
- package/dist/core/utils/prepareOptions.js +0 -31
- /package/dist/common/{Options.js → TRawOptions.js} +0 -0
- /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
|
@@ -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)('
|
|
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)('
|
|
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)('
|
|
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('
|
|
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)('
|
|
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
|
-
|
|
10
|
-
(0, node_test_1.test)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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
|
|
8
|
+
const pathHelpers_1 = require("../../../common/utils/pathHelpers");
|
|
9
9
|
const isSubdirectory_1 = require("../isSubdirectory");
|
|
10
|
-
(0, node_test_1.describe)('isSubDirectory', () => {
|
|
11
|
-
|
|
12
|
-
node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0,
|
|
13
|
-
node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0,
|
|
14
|
-
node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0,
|
|
15
|
-
node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0,
|
|
16
|
-
node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0,
|
|
17
|
-
node_assert_1.default.ok((0, isSubdirectory_1.isSubDirectory)((0,
|
|
18
|
-
node_assert_1.default.strictEqual((0, isSubdirectory_1.isSubDirectory)((0,
|
|
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)('
|
|
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)('
|
|
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)('
|
|
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(
|
|
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
|
});
|