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
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getModelProperties = getModelProperties;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const escapeName_1 = require("../../../utils/escapeName");
|
|
9
6
|
const getComment_1 = require("../../../utils/getComment");
|
|
10
7
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
@@ -12,7 +9,7 @@ const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
|
12
9
|
function getModelProperties(openApi, definition, parentRef) {
|
|
13
10
|
const models = [];
|
|
14
11
|
for (const propertyName in definition.properties) {
|
|
15
|
-
if ((0,
|
|
12
|
+
if ((0, safeHasOwn_1.safeHasOwn)(definition.properties, propertyName)) {
|
|
16
13
|
const property = definition.properties[propertyName];
|
|
17
14
|
const propertyRequired = definition.required?.includes(propertyName) || property.default !== undefined;
|
|
18
15
|
if (property.$ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getModels = getModels;
|
|
4
|
+
const getModelNameWithPrefix_1 = require("../../../utils/getModelNameWithPrefix");
|
|
4
5
|
const getRefFromSchema_1 = require("../../../utils/getRefFromSchema");
|
|
5
6
|
const modelHelpers_1 = require("../../../utils/modelHelpers");
|
|
6
7
|
const sortModelsByName_1 = require("../../../utils/sortModelsByName");
|
|
@@ -16,7 +17,7 @@ function getModels(openApi) {
|
|
|
16
17
|
openApi: openApi,
|
|
17
18
|
definition: definition,
|
|
18
19
|
isDefinition: true,
|
|
19
|
-
name: definitionType.base,
|
|
20
|
+
name: (0, getModelNameWithPrefix_1.getModelNameWithPrefix)(definitionType.base, definition, this.context.prefix),
|
|
20
21
|
path: definitionType.path,
|
|
21
22
|
parentRef: modelRef,
|
|
22
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationParameter.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationParameter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAQzF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"getOperationParameter.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationParameter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAQzF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAwIxI"}
|
|
@@ -101,7 +101,8 @@ function getOperationParameter(openApi, parameter, parentRef) {
|
|
|
101
101
|
}
|
|
102
102
|
if (parameter.schema) {
|
|
103
103
|
if (parameter.schema.$ref) {
|
|
104
|
-
const
|
|
104
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(parameter.schema.$ref, parentRef);
|
|
105
|
+
const model = this.getType(parameter.schema.$ref, normalizedRef);
|
|
105
106
|
operationParameter.export = 'reference';
|
|
106
107
|
operationParameter.type = model.type;
|
|
107
108
|
operationParameter.base = model.base;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponse.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOperationResponse.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAIvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAoF1J"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getOperationResponse = getOperationResponse;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const getComment_1 = require("../../../utils/getComment");
|
|
9
6
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
10
7
|
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
@@ -80,7 +77,7 @@ function getOperationResponse(openApi, response, responseCode, parentRef) {
|
|
|
80
77
|
// fetch and XHR client just support string types.
|
|
81
78
|
if (response.headers) {
|
|
82
79
|
for (const name in response.headers) {
|
|
83
|
-
if ((0,
|
|
80
|
+
if ((0, safeHasOwn_1.safeHasOwn)(response.headers, name)) {
|
|
84
81
|
operationResponse.in = 'header';
|
|
85
82
|
operationResponse.name = name;
|
|
86
83
|
operationResponse.type = 'string';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponses.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOperationResponses.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAsBzI"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getOperationResponses = getOperationResponses;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const getOperationResponseCode_1 = require("../../../utils/getOperationResponseCode");
|
|
9
6
|
function getOperationResponses(openApi, responses, parentRef) {
|
|
10
7
|
const operationResponses = [];
|
|
11
8
|
// Iterate over each response code and get the
|
|
12
9
|
// status code and response message (if any).
|
|
13
10
|
for (const code in responses) {
|
|
14
|
-
if ((0,
|
|
11
|
+
if ((0, safeHasOwn_1.safeHasOwn)(responses, code)) {
|
|
15
12
|
const responseOrReference = responses[code];
|
|
16
13
|
const response = (responseOrReference.$ref ? this.context.get(responseOrReference.$ref) : responseOrReference);
|
|
17
14
|
const responseCode = (0, getOperationResponseCode_1.getOperationResponseCode)(code);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getServices.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getServices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAKtD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAgCrE"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getServices = getServices;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const getClassName_1 = require("../../../utils/getClassName");
|
|
9
6
|
const serviceHelpers_1 = require("../../../utils/serviceHelpers");
|
|
10
7
|
const getServiceName_1 = require("./getServiceName");
|
|
@@ -14,7 +11,7 @@ const getServiceName_1 = require("./getServiceName");
|
|
|
14
11
|
function getServices(openApi) {
|
|
15
12
|
const services = new Map();
|
|
16
13
|
for (const url in openApi.paths) {
|
|
17
|
-
if ((0,
|
|
14
|
+
if ((0, safeHasOwn_1.safeHasOwn)(openApi.paths, url)) {
|
|
18
15
|
// Grab path and parse any global path parameters
|
|
19
16
|
const pathByUrl = openApi.paths[url];
|
|
20
17
|
const path = (pathByUrl.$ref ? this.context.get(pathByUrl.$ref) : pathByUrl);
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getType = getType;
|
|
4
4
|
const getMappedType_1 = require("../../../utils/getMappedType");
|
|
5
5
|
const getTypeName_1 = require("../../../utils/getTypeName");
|
|
6
|
-
const
|
|
6
|
+
const normalizeString_1 = require("../../../utils/normalizeString");
|
|
7
7
|
const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
|
|
8
8
|
const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
9
9
|
/**
|
|
@@ -12,7 +12,7 @@ const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
|
12
12
|
* @param parentRef Reference to a parent model
|
|
13
13
|
*/
|
|
14
14
|
function getType(value, parentRef) {
|
|
15
|
-
const normalizedValue = (0,
|
|
15
|
+
const normalizedValue = (0, normalizeString_1.normalizeString)(value) || '';
|
|
16
16
|
const result = {
|
|
17
17
|
type: 'any',
|
|
18
18
|
base: 'any',
|
|
@@ -37,8 +37,8 @@ function getType(value, parentRef) {
|
|
|
37
37
|
refValuePath: normalizedValue,
|
|
38
38
|
outputModelsPath: this.context.output?.outputModels,
|
|
39
39
|
});
|
|
40
|
-
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean));
|
|
41
|
-
const valueImportPath = !valuePath.startsWith('
|
|
40
|
+
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), parentRef);
|
|
41
|
+
const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
|
|
42
42
|
result.path = valuePath;
|
|
43
43
|
result.type = type;
|
|
44
44
|
result.base = type;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from '
|
|
1
|
+
import { Context } from '../../Context';
|
|
2
2
|
import { getModel } from '../v3/parser/getModel';
|
|
3
3
|
import { getModelComposition } from './parser/getModelComposition';
|
|
4
4
|
import { getModelProperties } from './parser/getModelProperties';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../../src/core/api/v3/Parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Parser.d.ts","sourceRoot":"","sources":["../../../../src/core/api/v3/Parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,OAAO;IAI5B,IAAI,OAAO,IAAI,OAAO,CAErB;IAEM,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;IASrD,KAAK,eAAS;IACd,SAAS,mBAAa;IACtB,OAAO,iBAAW;IAClB,QAAQ,kBAAY;IACpB,mBAAmB,6BAAuB;IAC1C,kBAAkB,4BAAsB;IACxC,WAAW,qBAAe;IAC1B,sBAAsB,gCAA0B;IAChD,qBAAqB,+BAAyB;IAC9C,YAAY,sBAAgB;IAC5B,qBAAqB,+BAAyB;IAC9C,oBAAoB,8BAAwB;IAC5C,uBAAuB,iCAA2B;CAC5D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Parser = void 0;
|
|
4
|
+
const getModelNameWithPrefix_1 = require("../../utils/getModelNameWithPrefix");
|
|
4
5
|
const getModel_1 = require("../v3/parser/getModel");
|
|
5
6
|
const getModelComposition_1 = require("./parser/getModelComposition");
|
|
6
7
|
const getModelProperties_1 = require("./parser/getModelProperties");
|
|
@@ -25,15 +26,7 @@ class Parser {
|
|
|
25
26
|
getTypeNameByRef(value, ref) {
|
|
26
27
|
if (ref) {
|
|
27
28
|
const definition = this.context.get(ref);
|
|
28
|
-
|
|
29
|
-
return `${this.context.prefix.enum}${value}`;
|
|
30
|
-
}
|
|
31
|
-
else if (definition.oneOf || definition.anyOf || definition.allOf || ['string', 'number', 'integer', 'boolean', 'array'].includes(definition.type)) {
|
|
32
|
-
return `${this.context.prefix.type}${value}`;
|
|
33
|
-
}
|
|
34
|
-
else if (definition.type === 'object') {
|
|
35
|
-
return `${this.context.prefix.interface}${value}`;
|
|
36
|
-
}
|
|
29
|
+
return (0, getModelNameWithPrefix_1.getModelNameWithPrefix)(value, definition, this._context.prefix);
|
|
37
30
|
}
|
|
38
31
|
return value;
|
|
39
32
|
}
|
|
@@ -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 getServer_1 = require("../getServer");
|
|
9
|
-
(0, node_test_1.describe)('getServer', () => {
|
|
10
|
-
(0, node_test_1.test)('
|
|
9
|
+
(0, node_test_1.describe)('@unit: getServer', () => {
|
|
10
|
+
(0, node_test_1.test)('should produce correct result', () => {
|
|
11
11
|
node_assert_1.default.strictEqual((0, getServer_1.getServer)({
|
|
12
12
|
openapi: '3.0',
|
|
13
13
|
info: {
|
|
@@ -22,7 +22,7 @@ const getServer_1 = require("../getServer");
|
|
|
22
22
|
],
|
|
23
23
|
}), 'https://localhost:8080/api');
|
|
24
24
|
});
|
|
25
|
-
(0, node_test_1.test)('
|
|
25
|
+
(0, node_test_1.test)('should produce correct result with variables', () => {
|
|
26
26
|
node_assert_1.default.strictEqual((0, getServer_1.getServer)({
|
|
27
27
|
openapi: '3.0',
|
|
28
28
|
info: {
|
|
@@ -9,8 +9,8 @@ const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"))
|
|
|
9
9
|
const Context_1 = require("../../../../Context");
|
|
10
10
|
const getOutputPaths_1 = require("../../../../utils/getOutputPaths");
|
|
11
11
|
const Parser_1 = require("../../Parser");
|
|
12
|
-
(0, node_test_1.describe)('getType', () => {
|
|
13
|
-
(0, node_test_1.test)('
|
|
12
|
+
(0, node_test_1.describe)('@unit: getType', () => {
|
|
13
|
+
(0, node_test_1.test)('should convert int', async () => {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
const parser = new swagger_parser_1.default();
|
|
@@ -22,7 +22,7 @@ const Parser_1 = require("../../Parser");
|
|
|
22
22
|
node_assert_1.default.strictEqual(type.template, null);
|
|
23
23
|
node_assert_1.default.deepStrictEqual(type.imports, []);
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
node_test_1.test.skip('should support file with ext', async () => {
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
const parser = new swagger_parser_1.default();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModelProperties.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModelProperties.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getModelProperties.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModelProperties.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,EAAE,CAkFxH"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getModelProperties = getModelProperties;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const escapeName_1 = require("../../../utils/escapeName");
|
|
9
6
|
const getClassName_1 = require("../../../utils/getClassName");
|
|
10
7
|
const getComment_1 = require("../../../utils/getComment");
|
|
@@ -13,7 +10,7 @@ const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
|
13
10
|
function getModelProperties(openApi, definition, parentRef) {
|
|
14
11
|
const models = [];
|
|
15
12
|
for (const propertyName in definition.properties) {
|
|
16
|
-
if ((0,
|
|
13
|
+
if ((0, safeHasOwn_1.safeHasOwn)(definition.properties, propertyName)) {
|
|
17
14
|
const property = definition.properties[propertyName];
|
|
18
15
|
const propertyRequired = definition.required?.includes(propertyName) || property.default !== undefined;
|
|
19
16
|
if (property.$ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getModels = getModels;
|
|
4
|
+
const getModelNameWithPrefix_1 = require("../../../utils/getModelNameWithPrefix");
|
|
4
5
|
const getRefFromSchema_1 = require("../../../utils/getRefFromSchema");
|
|
5
6
|
const modelHelpers_1 = require("../../../utils/modelHelpers");
|
|
6
7
|
const sortModelsByName_1 = require("../../../utils/sortModelsByName");
|
|
@@ -16,7 +17,7 @@ function getModels(openApi) {
|
|
|
16
17
|
openApi: openApi,
|
|
17
18
|
definition: definition,
|
|
18
19
|
isDefinition: true,
|
|
19
|
-
name: definitionType.base,
|
|
20
|
+
name: (0, getModelNameWithPrefix_1.getModelNameWithPrefix)(definitionType.base, definition, this.context.prefix),
|
|
20
21
|
path: definitionType.path,
|
|
21
22
|
parentRef: modelRef,
|
|
22
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponse.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getOperationResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOperationResponse.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getOperationResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAIvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAqF1J"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getOperationResponse = getOperationResponse;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const getComment_1 = require("../../../utils/getComment");
|
|
9
6
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
10
7
|
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
@@ -82,7 +79,7 @@ function getOperationResponse(openApi, response, responseCode, parentRef) {
|
|
|
82
79
|
// fetch and XHR client just support string types.
|
|
83
80
|
if (response.headers) {
|
|
84
81
|
for (const name in response.headers) {
|
|
85
|
-
if ((0,
|
|
82
|
+
if ((0, safeHasOwn_1.safeHasOwn)(response.headers, name)) {
|
|
86
83
|
operationResponse.in = 'header';
|
|
87
84
|
operationResponse.name = name;
|
|
88
85
|
operationResponse.type = 'string';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponses.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getOperationResponses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOperationResponses.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getOperationResponses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAsBzI"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getOperationResponses = getOperationResponses;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const getOperationResponseCode_1 = require("../../../utils/getOperationResponseCode");
|
|
9
6
|
function getOperationResponses(openApi, responses, parentRef) {
|
|
10
7
|
const operationResponses = [];
|
|
11
8
|
// Iterate over each response code and get the
|
|
12
9
|
// status code and response message (if any).
|
|
13
10
|
for (const code in responses) {
|
|
14
|
-
if ((0,
|
|
11
|
+
if ((0, safeHasOwn_1.safeHasOwn)(responses, code)) {
|
|
15
12
|
const responseOrReference = responses[code];
|
|
16
13
|
const response = (responseOrReference.$ref ? this.context.get(responseOrReference.$ref) : responseOrReference);
|
|
17
14
|
const responseCode = (0, getOperationResponseCode_1.getOperationResponseCode)(code);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServer.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getServer.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAUlD"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getServer = getServer;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
function getServer(openApi) {
|
|
9
6
|
const server = openApi.servers?.[0];
|
|
10
7
|
const variables = server?.variables || {};
|
|
11
8
|
let url = server?.url || '';
|
|
12
9
|
for (const variable in variables) {
|
|
13
|
-
if ((0,
|
|
10
|
+
if ((0, safeHasOwn_1.safeHasOwn)(variables, variable)) {
|
|
14
11
|
url = url.replace(`{${variable}}`, variables[variable].default);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getServices.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getServices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAKtD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAgCrE"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getServices = getServices;
|
|
7
|
-
const
|
|
4
|
+
const safeHasOwn_1 = require("../../../../common/utils/safeHasOwn");
|
|
8
5
|
const getClassName_1 = require("../../../utils/getClassName");
|
|
9
6
|
const serviceHelpers_1 = require("../../../utils/serviceHelpers");
|
|
10
7
|
const getServiceName_1 = require("./getServiceName");
|
|
@@ -14,7 +11,7 @@ const getServiceName_1 = require("./getServiceName");
|
|
|
14
11
|
function getServices(openApi) {
|
|
15
12
|
const services = new Map();
|
|
16
13
|
for (const url in openApi.paths) {
|
|
17
|
-
if ((0,
|
|
14
|
+
if ((0, safeHasOwn_1.safeHasOwn)(openApi.paths, url)) {
|
|
18
15
|
// Grab path and parse any global path parameters
|
|
19
16
|
const pathByUrl = openApi.paths[url];
|
|
20
17
|
const path = (pathByUrl.$ref ? this.context.get(pathByUrl.$ref) : pathByUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAoC5E"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getType = getType;
|
|
4
4
|
const getMappedType_1 = require("../../../utils/getMappedType");
|
|
5
5
|
const getTypeName_1 = require("../../../utils/getTypeName");
|
|
6
|
-
const
|
|
6
|
+
const normalizeString_1 = require("../../../utils/normalizeString");
|
|
7
7
|
const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
|
|
8
8
|
const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
9
9
|
/**
|
|
@@ -12,7 +12,7 @@ const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
|
12
12
|
* @param parentRef Reference to a parent model
|
|
13
13
|
*/
|
|
14
14
|
function getType(value, parentRef) {
|
|
15
|
-
const normalizedValue = (0,
|
|
15
|
+
const normalizedValue = (0, normalizeString_1.normalizeString)(value) || '';
|
|
16
16
|
const result = {
|
|
17
17
|
type: 'any',
|
|
18
18
|
base: 'any',
|
|
@@ -37,20 +37,12 @@ function getType(value, parentRef) {
|
|
|
37
37
|
refValuePath: normalizedValue,
|
|
38
38
|
outputModelsPath: this.context.output?.outputModels,
|
|
39
39
|
});
|
|
40
|
-
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean));
|
|
41
|
-
|
|
42
|
-
// start with "/" (absolute) or "." (relative like "./" or "../").
|
|
43
|
-
let valueImportPath = valuePath;
|
|
44
|
-
if (valuePath && !valuePath.startsWith('/') && !valuePath.startsWith('.')) {
|
|
45
|
-
valueImportPath = `./${valuePath}`;
|
|
46
|
-
}
|
|
40
|
+
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), parentRef);
|
|
41
|
+
const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
|
|
47
42
|
result.path = valuePath;
|
|
48
43
|
result.type = type;
|
|
49
44
|
result.base = type;
|
|
50
|
-
|
|
51
|
-
if (valuePath) {
|
|
52
|
-
result.imports.push({ name: type, alias: '', path: valueImportPath });
|
|
53
|
-
}
|
|
45
|
+
result.imports.push({ name: type, alias: '', path: valueImportPath });
|
|
54
46
|
}
|
|
55
47
|
return result;
|
|
56
48
|
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { TMultiOptions, TOptions } from '../common/Options';
|
|
2
2
|
export { HttpClient } from './types/enums/HttpClient.enum';
|
|
3
|
+
/**
|
|
4
|
+
* @throws {Error} If options validation fails or generation encounters an error
|
|
5
|
+
* @returns {Promise<void>}
|
|
6
|
+
*/
|
|
3
7
|
export declare function generate(options: TOptions | TOptions[] | TMultiOptions): Promise<void>;
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAoB5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAkH3D;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAgD5F"}
|
package/dist/core/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.HttpClient = void 0;
|
|
7
4
|
exports.generate = generate;
|
|
8
|
-
|
|
9
|
-
const
|
|
5
|
+
const fileSystemHelpers_1 = require("../common/utils/fileSystemHelpers");
|
|
6
|
+
const pathHelpers_1 = require("../common/utils/pathHelpers");
|
|
10
7
|
const Parser_1 = require("./api/v2/Parser");
|
|
11
8
|
const Parser_2 = require("./api/v3/Parser");
|
|
12
9
|
const Context_1 = require("./Context");
|
|
13
10
|
const HttpClient_enum_1 = require("./types/enums/HttpClient.enum");
|
|
14
|
-
const fileSystem_1 = require("./utils/fileSystem");
|
|
15
11
|
const getOpenApiSpec_1 = require("./utils/getOpenApiSpec");
|
|
16
12
|
const getOpenApiVersion_1 = require("./utils/getOpenApiVersion");
|
|
17
13
|
const getOutputPaths_1 = require("./utils/getOutputPaths");
|
|
@@ -55,7 +51,8 @@ async function generateFrom({ input, output, outputCore, outputServices, outputM
|
|
|
55
51
|
outputModels,
|
|
56
52
|
outputSchemas,
|
|
57
53
|
});
|
|
58
|
-
const
|
|
54
|
+
const absoluteInput = (0, isString_1.isString)(input) ? (0, pathHelpers_1.resolveHelper)(process.cwd(), input) : input;
|
|
55
|
+
const context = new Context_1.Context({ input: absoluteInput, output: outputPaths, prefix: { interface: interfacePrefix, enum: enumPrefix, type: typePrefix }, sortByRequired });
|
|
59
56
|
const openApi = (0, isString_1.isString)(input) ? await (0, getOpenApiSpec_1.getOpenApiSpec)(context, input) : input;
|
|
60
57
|
const openApiVersion = (0, getOpenApiVersion_1.getOpenApiVersion)(openApi);
|
|
61
58
|
const templates = (0, registerHandlebarTemplates_1.registerHandlebarTemplates)({
|
|
@@ -109,6 +106,10 @@ async function generateFrom({ input, output, outputCore, outputServices, outputM
|
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* @throws {Error} If options validation fails or generation encounters an error
|
|
111
|
+
* @returns {Promise<void>}
|
|
112
|
+
*/
|
|
112
113
|
async function generate(options) {
|
|
113
114
|
let preparedOptions = [];
|
|
114
115
|
if (Array.isArray(options)) {
|
|
@@ -123,30 +124,21 @@ async function generate(options) {
|
|
|
123
124
|
}
|
|
124
125
|
const optionsFinal = preparedOptions.map(op => (0, prepareOptions_1.prepareOptions)(op));
|
|
125
126
|
const writeClient = new WriteClient_1.WriteClient();
|
|
126
|
-
writeClient.logger.forceInfo(
|
|
127
|
+
writeClient.logger.forceInfo(`${GENERATION_MESSAGES.STARTED}. Total number of specification files: ${optionsFinal.length}`);
|
|
128
|
+
if (optionsFinal.length === 0) {
|
|
129
|
+
throw new Error('No options provided for generation');
|
|
130
|
+
}
|
|
127
131
|
try {
|
|
128
132
|
const start = process.hrtime();
|
|
129
133
|
for (const option of optionsFinal) {
|
|
130
|
-
|
|
131
|
-
await fileSystem_1.fileSystem.rmdir(option.output);
|
|
132
|
-
}
|
|
133
|
-
if (option.outputCore) {
|
|
134
|
-
await fileSystem_1.fileSystem.rmdir(option.outputCore);
|
|
135
|
-
}
|
|
136
|
-
if (option.outputSchemas) {
|
|
137
|
-
await fileSystem_1.fileSystem.rmdir(option.outputSchemas);
|
|
138
|
-
}
|
|
139
|
-
if (option.outputModels) {
|
|
140
|
-
await fileSystem_1.fileSystem.rmdir(option.outputModels);
|
|
141
|
-
}
|
|
142
|
-
if (option.outputServices) {
|
|
143
|
-
await fileSystem_1.fileSystem.rmdir(option.outputServices);
|
|
144
|
-
}
|
|
134
|
+
await cleanOutputDirectories(option);
|
|
145
135
|
}
|
|
146
136
|
for (const option of optionsFinal) {
|
|
137
|
+
const fileStart = process.hrtime();
|
|
147
138
|
await generateFrom(option, writeClient);
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
const [fileSeconds, fileNanoseconds] = process.hrtime(fileStart);
|
|
140
|
+
const fileDuration = fileSeconds + fileNanoseconds / 1e6;
|
|
141
|
+
writeClient.logger.info(`Duration for "${option.input}": ${fileDuration.toFixed(2)} sec`);
|
|
150
142
|
}
|
|
151
143
|
if (optionsFinal[0]?.useSeparatedIndexes) {
|
|
152
144
|
await writeClient.combineAndWrightSimple();
|
|
@@ -154,13 +146,28 @@ async function generate(options) {
|
|
|
154
146
|
else {
|
|
155
147
|
await writeClient.combineAndWrite();
|
|
156
148
|
}
|
|
157
|
-
writeClient.logger.forceInfo(
|
|
149
|
+
writeClient.logger.forceInfo(GENERATION_MESSAGES.FINISHED);
|
|
158
150
|
const [seconds, nanoseconds] = process.hrtime(start);
|
|
159
151
|
const durationInMs = seconds + nanoseconds / 1e6;
|
|
160
|
-
writeClient.logger.forceInfo(
|
|
152
|
+
writeClient.logger.forceInfo(GENERATION_MESSAGES.DURATION(durationInMs));
|
|
153
|
+
writeClient.logger.forceInfo(GENERATION_MESSAGES.FINISHED);
|
|
161
154
|
}
|
|
162
155
|
catch (error) {
|
|
163
156
|
writeClient.logger.error(error.message);
|
|
164
157
|
}
|
|
165
158
|
writeClient.logger.shutdownLogger();
|
|
166
159
|
}
|
|
160
|
+
const cleanOutputDirectories = async (option) => {
|
|
161
|
+
const outputDirs = [option.output, option.outputCore, option.outputSchemas, option.outputModels, option.outputServices];
|
|
162
|
+
for (const dir of outputDirs) {
|
|
163
|
+
if (dir) {
|
|
164
|
+
await fileSystemHelpers_1.fileSystemHelpers.rmdir(dir);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const GENERATION_MESSAGES = {
|
|
169
|
+
STARTED: 'Generation has begun',
|
|
170
|
+
FINISHED: 'Generation from has been finished',
|
|
171
|
+
FILE_FINISHED: (input) => `Generation from "${input}" was finished`,
|
|
172
|
+
DURATION: (ms) => `Lead time: ${ms.toFixed(2)} sec`,
|
|
173
|
+
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const REGEX_BACKSLASH: RegExp;
|
|
2
|
+
export declare const REGEX_MULTIPLE_SLASHES: RegExp;
|
|
3
|
+
export declare const REGEX_DOT_SLASH: RegExp;
|
|
4
|
+
export declare const REGEX_LEADING_DOT_SLASH: RegExp;
|
|
5
|
+
export declare const REGEX_TRAILING_SLASH: RegExp;
|
|
2
6
|
export declare const GROUP_PRIORITY_EXTENDED: {
|
|
3
7
|
readonly required: 0;
|
|
4
8
|
readonly 'required-with-default': 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../../src/core/types/Consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../../src/core/types/Consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,eAAO,MAAM,eAAe,QAAe,CAAC;AAE5C,eAAO,MAAM,uBAAuB,QAAc,CAAC;AAEnD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAC;AAEX,eAAO,MAAM,qBAAqB;;;CAGxB,CAAC"}
|