ts-openapi-codegen 1.0.0-beta.6 → 1.0.0-beta.7
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 +43 -58
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +2 -2
- package/dist/cli/generate/runGenerateOpenApi.js +4 -4
- package/dist/cli/index.js +11 -13
- package/dist/cli/utils.d.ts +0 -17
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +0 -20
- package/dist/common/Options.d.ts +4 -6
- package/dist/common/Options.d.ts.map +1 -1
- package/dist/common/Utils.d.ts.map +1 -1
- package/dist/common/Utils.js +8 -9
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +12 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +27 -1
- package/dist/common/VersionedSchema/{MultiOptionsMigrationPlan.d.ts → MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts} +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsMigrationPlan.js → MultiOptionsVersioned/MultiOptionsMigrationPlan.js} +18 -7
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV1.js → MultiOptionsVersioned/MultiOptionsSchemaV1.js} +4 -4
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV2.js → MultiOptionsVersioned/MultiOptionsSchemaV2.js} +4 -4
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +5 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV3.js → MultiOptionsVersioned/MultiOptionsSchemaV3.js} +3 -3
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV4.js → MultiOptionsVersioned/MultiOptionsSchemaV4.js} +4 -4
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.js +22 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsVersionedSchemas.js → MultiOptionsVersioned/MultiOptionsVersionedSchemas.js} +10 -5
- package/dist/common/VersionedSchema/{OptionsMigrationPlans.d.ts → OptionsVersioned/OptionsMigrationPlans.d.ts} +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +23 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +6 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsSchemaV1.js → OptionsVersioned/OptionsSchemaV1.js} +4 -4
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +6 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsSchemaV2.js → OptionsVersioned/OptionsSchemaV2.js} +4 -4
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +5 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsSchemaV3.js → OptionsVersioned/OptionsSchemaV3.js} +3 -3
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +6 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.js +17 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsVersionedSchemas.js → OptionsVersioned/OptionsVersionedSchemas.js} +9 -4
- package/dist/common/VersionedSchema/Types.d.ts +0 -4
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/__tests__/convertArrayToObject.test.js +62 -59
- package/dist/common/__tests__/mergeObjectSchemas.test.js +1 -1
- package/dist/common/__tests__/migrationForMultiOptions.test.js +9 -5
- package/dist/common/__tests__/migrationForOptions.test.js +17 -8
- package/dist/common/defaultOptions.d.ts.map +1 -1
- package/dist/common/defaultOptions.js +5 -7
- package/dist/core/Context.d.ts +15 -7
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +3 -0
- package/dist/core/WriteClient.d.ts +43 -45
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +156 -81
- package/dist/core/__tests__/WriteClient.test.js +12 -8
- package/dist/core/api/v2/parser/__tests__/getType.test.js +7 -25
- package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModel.js +5 -2
- package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModelProperties.js +3 -1
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +3 -29
- package/dist/core/api/v2/parser/getOperation.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperation.js +3 -3
- package/dist/core/api/v2/parser/getOperationParameter.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.js +4 -2
- package/dist/core/api/v2/parser/getOperationParameters.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameters.js +2 -2
- package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.js +3 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +2 -2
- package/dist/core/api/v2/parser/getServiceName.d.ts +3 -0
- package/dist/core/api/v2/parser/getServiceName.d.ts.map +1 -0
- package/dist/core/api/v2/parser/getServiceName.js +8 -0
- package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getServices.js +21 -32
- package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getType.js +13 -9
- package/dist/core/api/v3/parser/__tests__/getType.test.js +6 -24
- package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModel.js +5 -2
- package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModelProperties.js +3 -1
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +3 -29
- package/dist/core/api/v3/parser/getOperation.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperation.js +4 -4
- package/dist/core/api/v3/parser/getOperationParameter.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameter.js +6 -3
- package/dist/core/api/v3/parser/getOperationParameters.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.js +2 -2
- package/dist/core/api/v3/parser/getOperationRequestBody.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationRequestBody.js +3 -1
- package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponse.js +3 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +2 -2
- package/dist/core/api/v3/parser/getServiceName.d.ts +3 -0
- package/dist/core/api/v3/parser/getServiceName.d.ts.map +1 -0
- package/dist/core/api/v3/parser/getServiceName.js +8 -0
- package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServices.js +18 -84
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +22 -10
- package/dist/core/api/v3/types/OpenApiPath.model.d.ts +2 -1
- package/dist/core/api/v3/types/OpenApiPath.model.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +19 -20
- package/dist/core/types/base/ClientArtifacts.model.d.ts +12 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -0
- package/dist/core/types/base/ExportedModel.model.d.ts +17 -0
- package/dist/core/types/base/ExportedModel.model.d.ts.map +1 -0
- package/dist/core/types/base/ExportedService.model.d.ts +9 -0
- package/dist/core/types/base/ExportedService.model.d.ts.map +1 -0
- package/dist/core/types/base/ExportedService.model.js +2 -0
- package/dist/core/types/base/OutputPaths.model.d.ts +15 -0
- package/dist/core/types/base/OutputPaths.model.d.ts.map +1 -0
- package/dist/core/types/base/OutputPaths.model.js +2 -0
- package/dist/core/types/base/PrefixArtifacts.model.d.ts +6 -0
- package/dist/core/types/base/PrefixArtifacts.model.d.ts.map +1 -0
- package/dist/core/types/base/PrefixArtifacts.model.js +2 -0
- package/dist/core/types/base/PropertyGroup.model.d.ts +4 -0
- package/dist/core/types/base/PropertyGroup.model.d.ts.map +1 -0
- package/dist/core/types/base/PropertyGroup.model.js +2 -0
- package/dist/core/types/base/RefWithtype.model.d.ts +11 -0
- package/dist/core/types/base/RefWithtype.model.d.ts.map +1 -0
- package/dist/core/types/base/RefWithtype.model.js +2 -0
- package/dist/core/types/base/Root.model.d.ts +5 -0
- package/dist/core/types/base/Root.model.d.ts.map +1 -0
- package/dist/core/types/base/Root.model.js +2 -0
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +10 -0
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -0
- package/dist/core/types/base/SimpleClientArtifacts.model.js +2 -0
- package/dist/core/types/enums/HttpClient.enum.d.ts +7 -0
- package/dist/core/types/enums/HttpClient.enum.d.ts.map +1 -0
- package/dist/core/types/{Enums.js → enums/HttpClient.enum.js} +1 -9
- package/dist/core/types/enums/TypeRef.enum.d.ts +8 -0
- package/dist/core/types/enums/TypeRef.enum.d.ts.map +1 -0
- package/dist/core/types/enums/TypeRef.enum.js +11 -0
- package/dist/core/utils/__tests__/getAbsolutePath.test.js +1 -1
- package/dist/core/utils/__tests__/getGatheringRefs.test.js +3 -6
- package/dist/core/utils/__tests__/getRefFromSchema.test.js +1 -1
- package/dist/core/utils/__tests__/pathHelpers.test.js +4 -4
- package/dist/core/utils/__tests__/refResolver.test.d.ts +2 -0
- package/dist/core/utils/__tests__/refResolver.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/refResolver.test.js +55 -0
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
- package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +7 -3
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +67 -0
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +24 -24
- package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +13 -13
- package/dist/core/utils/__tests__/writeClientCore.test.js +14 -6
- package/dist/core/utils/__tests__/writeClientFullIndex.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeClientFullIndex.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/{writeClientIndex.test.js → writeClientFullIndex.test.js} +15 -7
- package/dist/core/utils/__tests__/writeClientModels.test.js +15 -7
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +15 -7
- package/dist/core/utils/__tests__/writeClientServices.test.js +15 -7
- package/dist/core/utils/advancedDeduplicatePath.d.ts +5 -0
- package/dist/core/utils/advancedDeduplicatePath.d.ts.map +1 -0
- package/dist/core/utils/advancedDeduplicatePath.js +29 -0
- package/dist/core/utils/appendUniqueLinesToFile.d.ts +2 -0
- package/dist/core/utils/appendUniqueLinesToFile.d.ts.map +1 -0
- package/dist/core/utils/appendUniqueLinesToFile.js +24 -0
- package/dist/core/utils/createNormalizedRef.d.ts +7 -0
- package/dist/core/utils/createNormalizedRef.d.ts.map +1 -0
- package/dist/core/utils/createNormalizedRef.js +24 -0
- package/dist/core/utils/findCommonParent.d.ts +7 -0
- package/dist/core/utils/findCommonParent.d.ts.map +1 -0
- package/dist/core/utils/findCommonParent.js +20 -0
- package/dist/core/utils/getAbsolutePath.d.ts.map +1 -1
- package/dist/core/utils/getAbsolutePath.js +16 -5
- package/dist/core/utils/getGatheringRefs.d.ts +2 -2
- package/dist/core/utils/getGatheringRefs.d.ts.map +1 -1
- package/dist/core/utils/getGatheringRefs.js +26 -17
- package/dist/core/utils/getMappedType.d.ts +0 -1
- package/dist/core/utils/getMappedType.d.ts.map +1 -1
- package/dist/core/utils/getMappedType.js +3 -4
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +9 -32
- package/dist/core/utils/getOutputPaths.d.ts +2 -2
- package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupExtended.d.ts +2 -2
- package/dist/core/utils/getPropertyGroupExtended.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupSimple.d.ts +2 -2
- package/dist/core/utils/getPropertyGroupSimple.d.ts.map +1 -1
- package/dist/core/utils/getRefFromSchema.js +2 -2
- package/dist/core/utils/getRelativeModelImportPath.js +1 -1
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
- package/dist/core/utils/getRelativeModelPath.js +5 -0
- package/dist/core/utils/isDirectory.d.ts +2 -0
- package/dist/core/utils/isDirectory.d.ts.map +1 -0
- package/dist/core/utils/isDirectory.js +13 -0
- package/dist/core/utils/isFileName.d.ts +7 -0
- package/dist/core/utils/isFileName.d.ts.map +1 -0
- package/dist/core/utils/isFileName.js +30 -0
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts +10 -0
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -0
- package/dist/core/utils/mapPathToTargetDirSafe.js +49 -0
- package/dist/core/utils/modelHelpers.d.ts +28 -0
- package/dist/core/utils/modelHelpers.d.ts.map +1 -0
- package/dist/core/utils/modelHelpers.js +73 -0
- package/dist/core/utils/normalizeAllRefs.d.ts +6 -0
- package/dist/core/utils/normalizeAllRefs.d.ts.map +1 -0
- package/dist/core/utils/normalizeAllRefs.js +35 -0
- package/dist/core/utils/normalizePath.d.ts +5 -0
- package/dist/core/utils/normalizePath.d.ts.map +1 -0
- package/dist/core/utils/normalizePath.js +19 -0
- package/dist/core/utils/normalizeRef.d.ts +5 -0
- package/dist/core/utils/normalizeRef.d.ts.map +1 -0
- package/dist/core/utils/normalizeRef.js +17 -0
- package/dist/core/utils/parseRef.d.ts +18 -0
- package/dist/core/utils/parseRef.d.ts.map +1 -0
- package/dist/core/utils/parseRef.js +64 -0
- package/dist/core/utils/pathHelpers.d.ts +1 -0
- package/dist/core/utils/pathHelpers.d.ts.map +1 -1
- package/dist/core/utils/pathHelpers.js +23 -3
- package/dist/core/utils/prepareAlias.d.ts +2 -6
- package/dist/core/utils/prepareAlias.d.ts.map +1 -1
- package/dist/core/utils/prepareAlias.js +0 -4
- package/dist/core/utils/prepareOptions.d.ts.map +1 -1
- package/dist/core/utils/prepareOptions.js +5 -7
- package/dist/core/utils/registerHandlebarHelpers.d.ts +1 -1
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.d.ts +9 -2
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +14 -2
- package/dist/core/utils/resolveRefPath.d.ts +7 -0
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -0
- package/dist/core/utils/resolveRefPath.js +34 -0
- package/dist/core/utils/resolveRefToImportPath.d.ts +7 -0
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -0
- package/dist/core/utils/resolveRefToImportPath.js +45 -0
- package/dist/core/utils/serviceHelpers.d.ts +41 -0
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -0
- package/dist/core/utils/serviceHelpers.js +115 -0
- package/dist/core/utils/sortModelByName.d.ts +2 -2
- package/dist/core/utils/sortModelByName.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.d.ts +4 -2
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +4 -1
- package/dist/core/utils/writeClientCoreIndex.d.ts +11 -0
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientCoreIndex.js +16 -0
- package/dist/core/utils/writeClientFullIndex.d.ts +9 -0
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientFullIndex.js +22 -0
- package/dist/core/utils/writeClientModels.d.ts +3 -2
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +5 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts +12 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientModelsIndex.js +16 -0
- package/dist/core/utils/writeClientSchemas.d.ts +3 -2
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +5 -0
- package/dist/core/utils/writeClientSchemasIndex.d.ts +12 -0
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientSchemasIndex.js +16 -0
- package/dist/core/utils/writeClientServices.d.ts +5 -4
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +4 -0
- package/dist/core/utils/writeClientServicesIndex.d.ts +12 -0
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientServicesIndex.js +16 -0
- package/dist/core/utils/writeClientSimpleIndex.d.ts +9 -0
- package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientSimpleIndex.js +22 -0
- package/dist/templatesCompiled/exportModel.js +2 -2
- package/dist/templatesCompiled/indexCore.d.ts +9 -0
- package/dist/templatesCompiled/indexCore.d.ts.map +1 -0
- package/dist/templatesCompiled/indexCore.js +22 -0
- package/dist/templatesCompiled/{index.d.ts → indexFull.d.ts} +1 -1
- package/dist/templatesCompiled/indexFull.d.ts.map +1 -0
- package/dist/templatesCompiled/indexModels.d.ts +15 -0
- package/dist/templatesCompiled/indexModels.d.ts.map +1 -0
- package/dist/templatesCompiled/indexModels.js +82 -0
- package/dist/templatesCompiled/indexServices.d.ts +10 -0
- package/dist/templatesCompiled/indexServices.d.ts.map +1 -0
- package/dist/templatesCompiled/indexServices.js +35 -0
- package/dist/templatesCompiled/indexShemas.d.ts +11 -0
- package/dist/templatesCompiled/indexShemas.d.ts.map +1 -0
- package/dist/templatesCompiled/indexShemas.js +47 -0
- package/dist/templatesCompiled/indexSimple.d.ts +21 -0
- package/dist/templatesCompiled/indexSimple.d.ts.map +1 -0
- package/dist/templatesCompiled/indexSimple.js +121 -0
- package/package.json +7 -4
- package/dist/common/VersionedSchema/MultiOptionsMigrationPlan.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV1.d.ts +0 -6
- package/dist/common/VersionedSchema/MultiOptionsSchemaV1.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV2.d.ts +0 -6
- package/dist/common/VersionedSchema/MultiOptionsSchemaV2.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV3.d.ts +0 -5
- package/dist/common/VersionedSchema/MultiOptionsSchemaV3.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV4.d.ts +0 -6
- package/dist/common/VersionedSchema/MultiOptionsSchemaV4.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsVersionedSchemas.d.ts +0 -3
- package/dist/common/VersionedSchema/MultiOptionsVersionedSchemas.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsMigrationPlans.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsMigrationPlans.js +0 -15
- package/dist/common/VersionedSchema/OptionsSchemaV1.d.ts +0 -6
- package/dist/common/VersionedSchema/OptionsSchemaV1.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsSchemaV2.d.ts +0 -6
- package/dist/common/VersionedSchema/OptionsSchemaV2.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsSchemaV3.d.ts +0 -5
- package/dist/common/VersionedSchema/OptionsSchemaV3.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsVersionedSchemas.d.ts +0 -3
- package/dist/common/VersionedSchema/OptionsVersionedSchemas.d.ts.map +0 -1
- package/dist/core/types/Enums.d.ts +0 -14
- package/dist/core/types/Enums.d.ts.map +0 -1
- package/dist/core/types/Models.d.ts +0 -37
- package/dist/core/types/Models.d.ts.map +0 -1
- package/dist/core/types/shared/ConverterData.model.d.ts +0 -7
- package/dist/core/types/shared/ConverterData.model.d.ts.map +0 -1
- package/dist/core/utils/__tests__/writeClientIndex.test.d.ts +0 -2
- package/dist/core/utils/__tests__/writeClientIndex.test.d.ts.map +0 -1
- package/dist/core/utils/writeClientIndex.d.ts +0 -59
- package/dist/core/utils/writeClientIndex.d.ts.map +0 -1
- package/dist/core/utils/writeClientIndex.js +0 -27
- package/dist/templatesCompiled/index.d.ts.map +0 -1
- /package/dist/core/types/{Models.js → base/ClientArtifacts.model.js} +0 -0
- /package/dist/core/types/{shared/ConverterData.model.js → base/ExportedModel.model.js} +0 -0
- /package/dist/templatesCompiled/{index.js → indexFull.js} +0 -0
|
@@ -7,14 +7,25 @@ function getAbsolutePath(definitionRef, parentRef) {
|
|
|
7
7
|
if (!definitionRef) {
|
|
8
8
|
return parentRef.startsWith('#/') ? '' : parentRef;
|
|
9
9
|
}
|
|
10
|
+
const parentBase = parentRef.split('#')[0] || '';
|
|
11
|
+
// If definitionRef is an absolute fragment, attach to parent base
|
|
10
12
|
if (definitionRef.startsWith('#/')) {
|
|
11
|
-
|
|
12
|
-
const basePath = parentRef.split('#')[0]; // We take everything up to #
|
|
13
|
-
return `${basePath}${definitionRef}`;
|
|
13
|
+
return `${parentBase}${definitionRef}`;
|
|
14
14
|
}
|
|
15
|
+
// If parentRef is only a fragment, keep definitionRef as is
|
|
15
16
|
if (parentRef.startsWith('#/')) {
|
|
16
|
-
// If parentRef is an absolute reference, we return definitionRef as it is.
|
|
17
17
|
return definitionRef;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
// Full URL or absolute filesystem path → return as is
|
|
20
|
+
if (/^https?:\/\//i.test(definitionRef) || definitionRef.startsWith('/')) {
|
|
21
|
+
return definitionRef;
|
|
22
|
+
}
|
|
23
|
+
// If definitionRef already has its own fragment and/or relative path
|
|
24
|
+
if (definitionRef.includes('#')) {
|
|
25
|
+
const [defPath, defFrag] = definitionRef.split('#');
|
|
26
|
+
const absPath = defPath ? (0, pathHelpers_1.join)((0, pathHelpers_1.dirName)(parentBase), defPath) : parentBase;
|
|
27
|
+
return defFrag ? `${absPath}#${defFrag}` : absPath;
|
|
28
|
+
}
|
|
29
|
+
// Plain relative path → resolve against parent base directory
|
|
30
|
+
return (0, pathHelpers_1.join)((0, pathHelpers_1.dirName)(parentBase), definitionRef);
|
|
20
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Context } from '../Context';
|
|
2
|
-
import {
|
|
3
|
-
export declare function getGatheringRefs(context: Context, object: Record<string, any>, references?:
|
|
2
|
+
import { RefWithType } from '../types/base/RefWithtype.model';
|
|
3
|
+
export declare function getGatheringRefs(context: Context, object: Record<string, any>, references?: RefWithType[], root?: string, isSchema?: boolean): RefWithType[];
|
|
4
4
|
//# sourceMappingURL=getGatheringRefs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGatheringRefs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getGatheringRefs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"getGatheringRefs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getGatheringRefs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAe9D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,GAAE,WAAW,EAAO,EAAE,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,OAAe,GAAG,WAAW,EAAE,CAqD3K"}
|
|
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getGatheringRefs = getGatheringRefs;
|
|
7
7
|
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const TypeRef_enum_1 = require("../types/enums/TypeRef.enum");
|
|
9
|
+
const normalizeRef_1 = require("./normalizeRef");
|
|
10
|
+
const parseRef_1 = require("./parseRef");
|
|
11
|
+
const resolveRefPath_1 = require("./resolveRefPath");
|
|
10
12
|
function includes(references, value) {
|
|
11
13
|
return references.findIndex(item => (0, fast_deep_equal_1.default)(item.value, value)) !== -1;
|
|
12
14
|
}
|
|
@@ -20,24 +22,31 @@ function getGatheringRefs(context, object, references = [], root = '', isSchema
|
|
|
20
22
|
return references;
|
|
21
23
|
}
|
|
22
24
|
if (object.$ref) {
|
|
23
|
-
|
|
24
|
-
const isHttpRef = object.$ref.startsWith('http://') || object.$ref.startsWith('https://');
|
|
25
|
-
// Extracting the base path from root
|
|
25
|
+
// Parse the reference to understand its type
|
|
26
26
|
const baseRoot = extractBasePath(root);
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
if (includes(references, newRef)) {
|
|
27
|
+
const parsedRef = (0, parseRef_1.parseRef)(object.$ref);
|
|
28
|
+
// Create normalized reference for context.get
|
|
29
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(object.$ref, baseRoot);
|
|
30
|
+
if (includes(references, normalizedRef)) {
|
|
33
31
|
return references;
|
|
34
32
|
}
|
|
35
|
-
references.push({ value:
|
|
36
|
-
const newObject = context.get(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
33
|
+
references.push({ value: normalizedRef, type: isSchema ? TypeRef_enum_1.TypeRef.SCHEMA : TypeRef_enum_1.TypeRef.OTHERS });
|
|
34
|
+
const newObject = context.get(normalizedRef);
|
|
35
|
+
// For recursive processing, determine the correct root path
|
|
36
|
+
let newRoot;
|
|
37
|
+
if (parsedRef.type === 'local_fragment') {
|
|
38
|
+
// For local fragments, keep the same root
|
|
39
|
+
newRoot = baseRoot;
|
|
40
|
+
}
|
|
41
|
+
else if (parsedRef.type === 'external_file' || parsedRef.type === 'external_file_fragment') {
|
|
42
|
+
// For external files, use the resolved file path
|
|
43
|
+
const resolvedPath = (0, resolveRefPath_1.resolveRefPath)(parsedRef, baseRoot);
|
|
44
|
+
newRoot = resolvedPath;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// For other types, use the normalized path without fragment
|
|
48
|
+
const [filePath] = normalizedRef.split('#');
|
|
49
|
+
newRoot = filePath;
|
|
41
50
|
}
|
|
42
51
|
return getGatheringRefs(context, newObject, references, newRoot, isSchema);
|
|
43
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMappedType.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getMappedType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMappedType.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getMappedType.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TYPE_MAPPINGS = void 0;
|
|
4
3
|
exports.getMappedType = getMappedType;
|
|
5
4
|
exports.hasMappedType = hasMappedType;
|
|
6
|
-
|
|
5
|
+
const TYPE_MAPPINGS = new Map([
|
|
7
6
|
['File', 'File'],
|
|
8
7
|
['file', 'File'],
|
|
9
8
|
['any', 'any'],
|
|
@@ -30,8 +29,8 @@ exports.TYPE_MAPPINGS = new Map([
|
|
|
30
29
|
* Get mapped type for given type to any basic Typescript/Javascript type.
|
|
31
30
|
*/
|
|
32
31
|
function getMappedType(type) {
|
|
33
|
-
return
|
|
32
|
+
return TYPE_MAPPINGS.get(type);
|
|
34
33
|
}
|
|
35
34
|
function hasMappedType(type) {
|
|
36
|
-
return
|
|
35
|
+
return TYPE_MAPPINGS.has(type);
|
|
37
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAMpE;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA6B5F"}
|
|
@@ -4,27 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getOpenApiSpec = getOpenApiSpec;
|
|
7
|
-
const
|
|
8
|
-
const path_1 = require("path");
|
|
7
|
+
const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
9
8
|
const pathHelpers_1 = require("../utils/pathHelpers");
|
|
10
9
|
const fileSystem_1 = require("./fileSystem");
|
|
11
|
-
|
|
12
|
-
if (object.$ref && !(0, path_1.isAbsolute)(object.$ref) && !object.$ref.match(/^(http:\/\/|https:\/\/|#\/)/g)) {
|
|
13
|
-
object.$ref = (0, pathHelpers_1.join)(parentRef, object.$ref);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
for (const key of Object.keys(object)) {
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
if (object[key] instanceof Object) {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
replaceRef(object[key], context, parentRef);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return object;
|
|
27
|
-
}
|
|
10
|
+
const normalizeAllRefs_1 = require("./normalizeAllRefs");
|
|
28
11
|
/**
|
|
29
12
|
* Load and parse te open api spec. If the file extension is ".yml" or ".yaml"
|
|
30
13
|
* we will try to parse the file as a YAML spec, otherwise we will fallback
|
|
@@ -40,23 +23,17 @@ async function getOpenApiSpec(context, input) {
|
|
|
40
23
|
if (!fileExists) {
|
|
41
24
|
throw new Error(`Could not read OpenApi spec: "${absoluteInput}"`);
|
|
42
25
|
}
|
|
43
|
-
const
|
|
26
|
+
// const isValidated = await SwaggerParser.validate(absoluteInput)
|
|
27
|
+
const resolvedRefs = await swagger_parser_1.default.resolve(absoluteInput, { validate: false });
|
|
28
|
+
// Coerce to the loose interface expected by Context
|
|
44
29
|
context.addRefs(resolvedRefs);
|
|
45
30
|
const raw = resolvedRefs.get(absoluteInput);
|
|
46
31
|
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || !('paths' in raw)) {
|
|
47
32
|
throw new Error(`Schema at "${absoluteInput}" is not a valid OpenAPI object`);
|
|
48
33
|
}
|
|
49
34
|
const mainSchema = raw;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
newPaths[pathKey] = replaceRef(context.get(maybeRef.$ref), context, (0, pathHelpers_1.dirName)(maybeRef.$ref));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
newPaths[pathKey] = value;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
mainSchema.paths = newPaths;
|
|
61
|
-
return mainSchema;
|
|
35
|
+
// Normalize all $ref in the entire schema using the new comprehensive resolver
|
|
36
|
+
const normalizedSchema = (0, normalizeAllRefs_1.normalizeAllRefs)(mainSchema, context, absoluteInput);
|
|
37
|
+
// The schema is already fully normalized, so we can return it directly
|
|
38
|
+
return normalizedSchema;
|
|
62
39
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OutputPaths } from '../types/base/OutputPaths.model';
|
|
2
2
|
export declare const getOutputPaths: ({ output, outputCore, outputModels, outputSchemas, outputServices, }: {
|
|
3
3
|
output: string;
|
|
4
4
|
outputCore?: string | undefined;
|
|
5
5
|
outputServices?: string | undefined;
|
|
6
6
|
outputModels?: string | undefined;
|
|
7
7
|
outputSchemas?: string | undefined;
|
|
8
|
-
}) =>
|
|
8
|
+
}) => OutputPaths;
|
|
9
9
|
//# sourceMappingURL=getOutputPaths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOutputPaths.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOutputPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getOutputPaths.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOutputPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAI9D,eAAO,MAAM,cAAc,GAAI,sEAM5B;IACC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,KAAG,WA+BH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyGroupExtended } from '../types/base/PropertyGroup.model';
|
|
2
2
|
import { OperationParameter } from '../types/shared/OperationParameter.model';
|
|
3
|
-
export declare function getPropertyGroupExtended(prop: OperationParameter):
|
|
3
|
+
export declare function getPropertyGroupExtended(prop: OperationParameter): PropertyGroupExtended;
|
|
4
4
|
//# sourceMappingURL=getPropertyGroupExtended.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPropertyGroupExtended.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getPropertyGroupExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getPropertyGroupExtended.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getPropertyGroupExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,qBAAqB,CAKxF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getPropertyGroupSimple(prop: any):
|
|
1
|
+
import { PropertyGroupSimple } from '../types/base/PropertyGroup.model';
|
|
2
|
+
export declare function getPropertyGroupSimple(prop: any): PropertyGroupSimple;
|
|
3
3
|
//# sourceMappingURL=getPropertyGroupSimple.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPropertyGroupSimple.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getPropertyGroupSimple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getPropertyGroupSimple.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getPropertyGroupSimple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAGxE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,GAAG,mBAAmB,CAIrE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRefFromSchema = getRefFromSchema;
|
|
4
|
-
const
|
|
4
|
+
const TypeRef_enum_1 = require("../types/enums/TypeRef.enum");
|
|
5
5
|
const getGatheringRefs_1 = require("./getGatheringRefs");
|
|
6
6
|
function getRefFromSchema(context, object) {
|
|
7
7
|
const references = (0, getGatheringRefs_1.getGatheringRefs)(context, object);
|
|
8
|
-
return references.filter(item => item.type ===
|
|
8
|
+
return references.filter(item => item.type === TypeRef_enum_1.TypeRef.SCHEMA).map(value => value.value);
|
|
9
9
|
}
|
|
@@ -30,7 +30,7 @@ function getRelativeModelImportPath(rootPath, sourcePath, targetPath) {
|
|
|
30
30
|
absSourcePath = path_1.default.resolve(absoluteRoot, sourceRelativePath);
|
|
31
31
|
}
|
|
32
32
|
const absSourceDir = normalizedSourcePath ? path_1.default.dirname(absSourcePath) : absoluteRoot;
|
|
33
|
-
let absTargetPath = path_1.default.resolve(absSourceDir, targetPath);
|
|
33
|
+
let absTargetPath = path_1.default.isAbsolute(targetPath) ? targetPath : path_1.default.resolve(absSourceDir, targetPath);
|
|
34
34
|
if (!(0, isInsideDirectory_1.isInsideDirectory)(absTargetPath, rootPath)) {
|
|
35
35
|
const targetRelativePath = (0, getRelativeModelPath_1.getRelativeModelPath)(absoluteRoot, targetPath);
|
|
36
36
|
absTargetPath = path_1.default.resolve(absoluteRoot, targetRelativePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRelativeModelPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getRelativeModelPath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getRelativeModelPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getRelativeModelPath.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,iBAAiB,EAAE,MAAM,UA6B7F"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRelativeModelPath = getRelativeModelPath;
|
|
4
|
+
const getTypeName_1 = require("./getTypeName");
|
|
4
5
|
const isInsideDirectory_1 = require("./isInsideDirectory");
|
|
5
6
|
const pathHelpers_1 = require("./pathHelpers");
|
|
6
7
|
const replaceString_1 = require("./replaceString");
|
|
@@ -19,6 +20,10 @@ function getRelativeModelPath(folderPath, relativeModelPath) {
|
|
|
19
20
|
const pathSep = '/';
|
|
20
21
|
let mappedPaths = '';
|
|
21
22
|
let modelPath = relativeModelPath;
|
|
23
|
+
// If absolute path (filesystem or URL-like), collapse to type name only
|
|
24
|
+
if (modelPath.startsWith('/')) {
|
|
25
|
+
return (0, getTypeName_1.getTypeName)(modelPath);
|
|
26
|
+
}
|
|
22
27
|
if (modelPath.startsWith('../')) {
|
|
23
28
|
const pathArray = modelPath.split(pathSep).filter(Boolean);
|
|
24
29
|
while (pathArray[0] === '..') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDirectory.d.ts","sourceRoot":"","sources":["../../../src/core/utils/isDirectory.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMjD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDirectory = isDirectory;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const pathHelpers_1 = require("./pathHelpers");
|
|
6
|
+
function isDirectory(path) {
|
|
7
|
+
try {
|
|
8
|
+
return (0, fs_1.statSync)((0, pathHelpers_1.normalize)(path)).isDirectory();
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFileName.d.ts","sourceRoot":"","sources":["../../../src/core/utils/isFileName.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAmB/C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFileName = isFileName;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the string is just a file name (with an extension)
|
|
6
|
+
* @param str - the line to check
|
|
7
|
+
* @returns true, if this is the file name
|
|
8
|
+
*/
|
|
9
|
+
function isFileName(str) {
|
|
10
|
+
if (typeof str !== 'string' || !str)
|
|
11
|
+
return false;
|
|
12
|
+
// 1. Does not contain path separators
|
|
13
|
+
if (str.includes('/') || str.includes('\\'))
|
|
14
|
+
return false;
|
|
15
|
+
// 2. Does not start with ./, ../, \
|
|
16
|
+
if (/^\.\.?[\\/\\]/.test(str))
|
|
17
|
+
return false;
|
|
18
|
+
if (str.startsWith('/'))
|
|
19
|
+
return false;
|
|
20
|
+
// 3. Contains at least one dot and does not end with a dot.
|
|
21
|
+
const parts = str.split('.');
|
|
22
|
+
if (parts.length < 2)
|
|
23
|
+
return false;
|
|
24
|
+
if (parts[parts.length - 1] === '')
|
|
25
|
+
return false; // ends with .
|
|
26
|
+
// 4. The file name is not empty
|
|
27
|
+
if (parts[0] === '')
|
|
28
|
+
return false;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely muppit the path from SourceDir → targetDir
|
|
3
|
+
* Works even if the file is outside SourceDir, but in a common parent
|
|
4
|
+
* @param filePath
|
|
5
|
+
* @param sourceDir
|
|
6
|
+
* @param targetDir
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapPathToTargetDirSafe(filePath: string, sourceDir: string, targetDir: string): string;
|
|
10
|
+
//# sourceMappingURL=mapPathToTargetDirSafe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapPathToTargetDirSafe.d.ts","sourceRoot":"","sources":["../../../src/core/utils/mapPathToTargetDirSafe.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CA0CrG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapPathToTargetDirSafe = mapPathToTargetDirSafe;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const findCommonParent_1 = require("./findCommonParent");
|
|
6
|
+
const getRelativeModelPath_1 = require("./getRelativeModelPath");
|
|
7
|
+
const pathHelpers_1 = require("./pathHelpers");
|
|
8
|
+
/**
|
|
9
|
+
* Safely muppit the path from SourceDir → targetDir
|
|
10
|
+
* Works even if the file is outside SourceDir, but in a common parent
|
|
11
|
+
* @param filePath
|
|
12
|
+
* @param sourceDir
|
|
13
|
+
* @param targetDir
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function mapPathToTargetDirSafe(filePath, sourceDir, targetDir) {
|
|
17
|
+
const pathSep = '/';
|
|
18
|
+
const absFile = (0, pathHelpers_1.resolve)(filePath);
|
|
19
|
+
const absSource = (0, pathHelpers_1.resolve)(sourceDir);
|
|
20
|
+
const absTarget = (0, pathHelpers_1.resolve)(targetDir);
|
|
21
|
+
const sourceWithSep = absSource.endsWith(pathSep) ? absSource : absSource + pathSep;
|
|
22
|
+
// 1. The file inside SourceDir → mapim as usual
|
|
23
|
+
if (absFile.startsWith(sourceWithSep)) {
|
|
24
|
+
const rel = (0, path_1.relative)(absSource, absFile);
|
|
25
|
+
return (0, pathHelpers_1.resolve)(absTarget, rel);
|
|
26
|
+
}
|
|
27
|
+
// 2. The file is outside SourceDir, but in a common parent
|
|
28
|
+
const commonParent = (0, findCommonParent_1.findCommonParent)(absSource, absFile);
|
|
29
|
+
if (commonParent) {
|
|
30
|
+
// Path from commonParent → file
|
|
31
|
+
const fileRelToCommon = (0, path_1.relative)(commonParent, absFile);
|
|
32
|
+
// Path from targetDir → commonParent
|
|
33
|
+
const targetToCommon = (0, path_1.relative)(absTarget, commonParent);
|
|
34
|
+
if (targetToCommon.includes('..')) {
|
|
35
|
+
// targetDir is higher than commonParent → we can't map
|
|
36
|
+
if (filePath) {
|
|
37
|
+
const relativePath = (0, path_1.relative)(absSource, absFile);
|
|
38
|
+
return (0, getRelativeModelPath_1.getRelativeModelPath)(targetDir, relativePath);
|
|
39
|
+
}
|
|
40
|
+
return filePath;
|
|
41
|
+
}
|
|
42
|
+
// Collecting: targetDir → commonParent → file
|
|
43
|
+
const pathFromTargetToCommon = (0, path_1.relative)(absTarget, commonParent);
|
|
44
|
+
const pathFromCommonToFile = fileRelToCommon;
|
|
45
|
+
return (0, pathHelpers_1.resolve)(absTarget, pathFromTargetToCommon, pathFromCommonToFile);
|
|
46
|
+
}
|
|
47
|
+
// 3. There is no common parent → return as is
|
|
48
|
+
return filePath;
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Model } from '../types/shared/Model.model';
|
|
2
|
+
/**
|
|
3
|
+
* Assigns alias to models with the same name.
|
|
4
|
+
* Modifies objects of in-place models and returns an array.
|
|
5
|
+
*
|
|
6
|
+
* Example: if there are two models with name="Pet", the following will be assigned:
|
|
7
|
+
* - first: alias="Pet$1"
|
|
8
|
+
* - second: alias="Pet$2"
|
|
9
|
+
*
|
|
10
|
+
* @param models - an array of models sorted by name
|
|
11
|
+
* @returns the same array of models (modified)
|
|
12
|
+
*/
|
|
13
|
+
export declare function setDuplicateModelAliases(models: Model[]): Model[];
|
|
14
|
+
/**
|
|
15
|
+
* Adjusts the imports fields of the models to relative paths and correct aliases,
|
|
16
|
+
* based on the outputModelsDir directory.
|
|
17
|
+
*
|
|
18
|
+
* Logic:
|
|
19
|
+
* - searches for the target model by name + path;
|
|
20
|
+
* - if found, calculates the relative path between files and substitutes;
|
|
21
|
+
* - updates alias (if it is set for the target model) and path in the import object.
|
|
22
|
+
*
|
|
23
|
+
* @param models - array of models
|
|
24
|
+
* @param outputModelsDir - the directory where the models are generated (this.context.output.outputModels)
|
|
25
|
+
* @returns the same array of models (modified)
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveModelImports(models: Model[], outputModelsDir: string): Model[];
|
|
28
|
+
//# sourceMappingURL=modelHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/modelHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAkBjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,KAAK,EAAE,CAyBrF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setDuplicateModelAliases = setDuplicateModelAliases;
|
|
4
|
+
exports.resolveModelImports = resolveModelImports;
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Assigns alias to models with the same name.
|
|
8
|
+
* Modifies objects of in-place models and returns an array.
|
|
9
|
+
*
|
|
10
|
+
* Example: if there are two models with name="Pet", the following will be assigned:
|
|
11
|
+
* - first: alias="Pet$1"
|
|
12
|
+
* - second: alias="Pet$2"
|
|
13
|
+
*
|
|
14
|
+
* @param models - an array of models sorted by name
|
|
15
|
+
* @returns the same array of models (modified)
|
|
16
|
+
*/
|
|
17
|
+
function setDuplicateModelAliases(models) {
|
|
18
|
+
let previous;
|
|
19
|
+
let index = 1;
|
|
20
|
+
models.forEach(model => {
|
|
21
|
+
if (previous && previous.name === model.name) {
|
|
22
|
+
if (index === 1) {
|
|
23
|
+
previous.alias = `${model.name}$${index}`;
|
|
24
|
+
index++;
|
|
25
|
+
}
|
|
26
|
+
model.alias = `${model.name}$${index}`;
|
|
27
|
+
index++;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
model.alias = '';
|
|
31
|
+
index = 1;
|
|
32
|
+
}
|
|
33
|
+
previous = model;
|
|
34
|
+
});
|
|
35
|
+
return models;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Adjusts the imports fields of the models to relative paths and correct aliases,
|
|
39
|
+
* based on the outputModelsDir directory.
|
|
40
|
+
*
|
|
41
|
+
* Logic:
|
|
42
|
+
* - searches for the target model by name + path;
|
|
43
|
+
* - if found, calculates the relative path between files and substitutes;
|
|
44
|
+
* - updates alias (if it is set for the target model) and path in the import object.
|
|
45
|
+
*
|
|
46
|
+
* @param models - array of models
|
|
47
|
+
* @param outputModelsDir - the directory where the models are generated (this.context.output.outputModels)
|
|
48
|
+
* @returns the same array of models (modified)
|
|
49
|
+
*/
|
|
50
|
+
function resolveModelImports(models, outputModelsDir) {
|
|
51
|
+
models.forEach(model => {
|
|
52
|
+
model.imports = model.imports.map(imprt => {
|
|
53
|
+
const importModel = models.find(value => {
|
|
54
|
+
const normalizedPath = !value.path.startsWith('./') ? `./${value.path}` : value.path;
|
|
55
|
+
return normalizedPath === imprt.path && value.name === imprt.name;
|
|
56
|
+
});
|
|
57
|
+
const importAlias = importModel?.alias ?? imprt.alias;
|
|
58
|
+
let importPath = imprt.path;
|
|
59
|
+
if (importModel) {
|
|
60
|
+
const fromDir = (0, path_1.dirname)((0, path_1.resolve)(outputModelsDir, model.path));
|
|
61
|
+
const toDir = (0, path_1.dirname)((0, path_1.resolve)(outputModelsDir, importModel.path));
|
|
62
|
+
const file = (0, path_1.basename)(importModel.name);
|
|
63
|
+
const relativePath = (0, path_1.relative)(fromDir, toDir);
|
|
64
|
+
importPath = relativePath === '' ? `./${file}` : `${relativePath.replace(/\\/g, '/')}/${file}`;
|
|
65
|
+
}
|
|
66
|
+
return Object.assign(imprt, {
|
|
67
|
+
alias: importAlias,
|
|
68
|
+
path: importPath,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return models;
|
|
73
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from '../Context';
|
|
2
|
+
/**
|
|
3
|
+
* Deep traversal and normalization of all $ref in an object
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeAllRefs<T extends Record<string, any>>(obj: T, context: Context, parentFilePath: string): T;
|
|
6
|
+
//# sourceMappingURL=normalizeAllRefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeAllRefs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/normalizeAllRefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,GAAG,EAAE,CAAC,EACN,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACvB,CAAC,CA6BH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAllRefs = normalizeAllRefs;
|
|
4
|
+
const normalizeRef_1 = require("./normalizeRef");
|
|
5
|
+
/**
|
|
6
|
+
* Deep traversal and normalization of all $ref in an object
|
|
7
|
+
*/
|
|
8
|
+
function normalizeAllRefs(obj, context, parentFilePath) {
|
|
9
|
+
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
// If this object is a $ref holder
|
|
13
|
+
if (obj.$ref && typeof obj.$ref === 'string') {
|
|
14
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(obj.$ref, parentFilePath);
|
|
15
|
+
return {
|
|
16
|
+
...obj,
|
|
17
|
+
$ref: normalizedRef
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const result = Array.isArray(obj) ? [] : { ...obj };
|
|
21
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
22
|
+
if (value && typeof value === 'object') {
|
|
23
|
+
// For nested objects, use the same parent file path
|
|
24
|
+
// The normalization will handle the $ref resolution correctly
|
|
25
|
+
result[key] = normalizeAllRefs(value, context, parentFilePath);
|
|
26
|
+
}
|
|
27
|
+
else if (Array.isArray(value)) {
|
|
28
|
+
result[key] = value.map((item) => (item && typeof item === 'object' ? normalizeAllRefs(item, context, parentFilePath) : item));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
result[key] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizePath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/normalizePath.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAelD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePath = normalizePath;
|
|
4
|
+
/**
|
|
5
|
+
* Normalize path to prevent duplication issues
|
|
6
|
+
*/
|
|
7
|
+
function normalizePath(path) {
|
|
8
|
+
// If path is empty (e.g. local fragment with no parent file), preserve emptiness
|
|
9
|
+
if (!path) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
// Remove any duplicate slashes
|
|
13
|
+
let normalized = path.replace(/\/+/g, '/');
|
|
14
|
+
// Ensure it starts with / for absolute paths
|
|
15
|
+
if (!normalized.startsWith('./') && !normalized.startsWith('/') && !normalized.startsWith('http')) {
|
|
16
|
+
normalized = `/${normalized}`;
|
|
17
|
+
}
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|