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
package/dist/core/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const Parser_1 = require("./api/v2/Parser");
|
|
11
11
|
const Parser_2 = require("./api/v3/Parser");
|
|
12
12
|
const Context_1 = require("./Context");
|
|
13
|
-
const
|
|
13
|
+
const HttpClient_enum_1 = require("./types/enums/HttpClient.enum");
|
|
14
14
|
const fileSystem_1 = require("./utils/fileSystem");
|
|
15
15
|
const getOpenApiSpec_1 = require("./utils/getOpenApiSpec");
|
|
16
16
|
const getOpenApiVersion_1 = require("./utils/getOpenApiVersion");
|
|
@@ -21,8 +21,8 @@ const postProcessClient_1 = require("./utils/postProcessClient");
|
|
|
21
21
|
const prepareOptions_1 = require("./utils/prepareOptions");
|
|
22
22
|
const registerHandlebarTemplates_1 = require("./utils/registerHandlebarTemplates");
|
|
23
23
|
const WriteClient_1 = require("./WriteClient");
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return
|
|
24
|
+
var HttpClient_enum_2 = require("./types/enums/HttpClient.enum");
|
|
25
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return HttpClient_enum_2.HttpClient; } });
|
|
26
26
|
/**
|
|
27
27
|
* Generate the OpenAPI client. This method will read the OpenAPI specification and based on the
|
|
28
28
|
* given language it will generate the client, including the typed models, validation schemas,
|
|
@@ -36,11 +36,8 @@ Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function (
|
|
|
36
36
|
* @param httpClient: The selected httpClient (fetch or XHR)
|
|
37
37
|
* @param useOptions: Use options or arguments functions
|
|
38
38
|
* @param useUnionTypes: Use union types instead of enums
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param exportModels: Generate models
|
|
42
|
-
* @param exportSchemas: Generate schemas
|
|
43
|
-
* @param clean: Clean a directory before generation
|
|
39
|
+
* @param excludeCoreServiceFiles The generation of the core and services is excluded
|
|
40
|
+
* @param includeSchemasFiles The generation of model validation schemes is enabled
|
|
44
41
|
* @param request: Path to custom request file
|
|
45
42
|
* @param write: Write the files to disk (true or false)
|
|
46
43
|
* @param interfacePrefix: Prefix for interface model(I)
|
|
@@ -48,8 +45,9 @@ Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function (
|
|
|
48
45
|
* @param typePrefix: Prefix for type model(T)
|
|
49
46
|
* @param useCancelableRequest Use cancelable request type.
|
|
50
47
|
* @param sortByRequired Property sorting strategy: simplified or extended
|
|
48
|
+
* @param useSeparatedIndexes Use separate index files for the core, models, schemas, and services
|
|
51
49
|
*/
|
|
52
|
-
async function generateFrom({ input, output, outputCore, outputServices, outputModels, outputSchemas, httpClient =
|
|
50
|
+
async function generateFrom({ input, output, outputCore, outputServices, outputModels, outputSchemas, httpClient = HttpClient_enum_1.HttpClient.FETCH, useOptions = false, useUnionTypes = false, excludeCoreServiceFiles = false, includeSchemasFiles = false, request, write = true, interfacePrefix = 'I', enumPrefix = 'E', typePrefix = 'T', useCancelableRequest = false, sortByRequired = false, useSeparatedIndexes = false, }, writeClient) {
|
|
53
51
|
const outputPaths = (0, getOutputPaths_1.getOutputPaths)({
|
|
54
52
|
output,
|
|
55
53
|
outputCore,
|
|
@@ -80,13 +78,11 @@ async function generateFrom({ input, output, outputCore, outputServices, outputM
|
|
|
80
78
|
httpClient,
|
|
81
79
|
useOptions,
|
|
82
80
|
useUnionTypes,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
exportModels,
|
|
86
|
-
exportSchemas,
|
|
87
|
-
clean,
|
|
81
|
+
excludeCoreServiceFiles,
|
|
82
|
+
includeSchemasFiles,
|
|
88
83
|
request,
|
|
89
84
|
useCancelableRequest,
|
|
85
|
+
useSeparatedIndexes,
|
|
90
86
|
});
|
|
91
87
|
break;
|
|
92
88
|
}
|
|
@@ -103,13 +99,11 @@ async function generateFrom({ input, output, outputCore, outputServices, outputM
|
|
|
103
99
|
httpClient,
|
|
104
100
|
useOptions,
|
|
105
101
|
useUnionTypes,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
exportModels,
|
|
109
|
-
exportSchemas,
|
|
110
|
-
clean,
|
|
102
|
+
excludeCoreServiceFiles,
|
|
103
|
+
includeSchemasFiles,
|
|
111
104
|
request,
|
|
112
105
|
useCancelableRequest,
|
|
106
|
+
useSeparatedIndexes,
|
|
113
107
|
});
|
|
114
108
|
break;
|
|
115
109
|
}
|
|
@@ -154,7 +148,12 @@ async function generate(options) {
|
|
|
154
148
|
writeClient.logger.info(`Generation from "${option.input}" was finished`);
|
|
155
149
|
writeClient.logger.info(`Output folder: ${path_1.default.resolve(process.cwd(), option.output)}`, true);
|
|
156
150
|
}
|
|
157
|
-
|
|
151
|
+
if (optionsFinal[0]?.useSeparatedIndexes) {
|
|
152
|
+
await writeClient.combineAndWrightSimple();
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await writeClient.combineAndWrite();
|
|
156
|
+
}
|
|
158
157
|
writeClient.logger.forceInfo("Generation from has been finished");
|
|
159
158
|
const [seconds, nanoseconds] = process.hrtime(start);
|
|
160
159
|
const durationInMs = seconds + nanoseconds / 1e6;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Templates } from "../../utils/registerHandlebarTemplates";
|
|
2
|
+
import { ExportedModel } from "./ExportedModel.model";
|
|
3
|
+
import { ExportedService } from "./ExportedService.model";
|
|
4
|
+
export type ClientArtifacts = {
|
|
5
|
+
templates: Templates;
|
|
6
|
+
outputPath: string;
|
|
7
|
+
core: string[];
|
|
8
|
+
models: ExportedModel[];
|
|
9
|
+
schemas: ExportedModel[];
|
|
10
|
+
services: ExportedService[];
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=ClientArtifacts.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Model } from "../shared/Model.model";
|
|
2
|
+
/**
|
|
3
|
+
* @param name: The name of the model
|
|
4
|
+
* @param alias: The alias of the model(when there are several similar models in the one specification)
|
|
5
|
+
* @param path: The name of the file witch contains this model
|
|
6
|
+
* @param package: The relative location of this service
|
|
7
|
+
* @param enum: Then flag for mark an enum
|
|
8
|
+
* @param useUnionTypes: Use union types instead of enums
|
|
9
|
+
* @param enums: Then flag for mark an enums
|
|
10
|
+
*/
|
|
11
|
+
export type ExportedModel = Pick<Model, 'name' | 'alias' | 'path'> & {
|
|
12
|
+
package: string;
|
|
13
|
+
enum: boolean;
|
|
14
|
+
enums: boolean;
|
|
15
|
+
useUnionTypes: boolean;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=ExportedModel.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportedModel.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ExportedModel.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,KAAK,EACL,MAAM,GAAG,OAAO,GAAG,MAAM,CAC1B,GAAG;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportedService.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ExportedService.model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param output The relative location of the output directory(or index)
|
|
3
|
+
* @param outputCore The relative location of the output directory for core
|
|
4
|
+
* @param outputServices The relative location of the output directory for services
|
|
5
|
+
* @param outputModels The relative location of the output directory for models
|
|
6
|
+
* @param outputSchemas The relative location of the output directory for schemas
|
|
7
|
+
*/
|
|
8
|
+
export type OutputPaths = {
|
|
9
|
+
output: string;
|
|
10
|
+
outputCore: string;
|
|
11
|
+
outputServices: string;
|
|
12
|
+
outputModels: string;
|
|
13
|
+
outputSchemas: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=OutputPaths.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutputPaths.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/OutputPaths.model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrefixArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/PrefixArtifacts.model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GROUP_PRIORITY_EXTENDED, GROUP_PRIORITY_SIMPLE } from "../Consts";
|
|
2
|
+
export type PropertyGroupExtended = keyof typeof GROUP_PRIORITY_EXTENDED;
|
|
3
|
+
export type PropertyGroupSimple = keyof typeof GROUP_PRIORITY_SIMPLE;
|
|
4
|
+
//# sourceMappingURL=PropertyGroup.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyGroup.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/PropertyGroup.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAE3E,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,uBAAuB,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TypeRef } from "../enums/TypeRef.enum";
|
|
2
|
+
/**
|
|
3
|
+
* Ref With type
|
|
4
|
+
* @prop value Value
|
|
5
|
+
* @prop type The type of object passed via ref
|
|
6
|
+
*/
|
|
7
|
+
export type RefWithType = {
|
|
8
|
+
value: string;
|
|
9
|
+
type: TypeRef;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=RefWithtype.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefWithtype.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/RefWithtype.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Root.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/Root.model.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Templates } from "../../utils/registerHandlebarTemplates";
|
|
2
|
+
export type SimpleClientArtifacts = {
|
|
3
|
+
templates: Templates;
|
|
4
|
+
outputPath: string;
|
|
5
|
+
core: string[];
|
|
6
|
+
models: string[];
|
|
7
|
+
schemas: string[];
|
|
8
|
+
services: string[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=SimpleClientArtifacts.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimpleClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/SimpleClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnE,MAAM,MAAM,qBAAqB,GAAG;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpClient.enum.d.ts","sourceRoot":"","sources":["../../../../src/core/types/enums/HttpClient.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IAClB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;CAClB"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpClient =
|
|
4
|
-
/**
|
|
5
|
-
* The type of object passed via ref
|
|
6
|
-
*/
|
|
7
|
-
var TypeRef;
|
|
8
|
-
(function (TypeRef) {
|
|
9
|
-
TypeRef[TypeRef["SCHEMA"] = 0] = "SCHEMA";
|
|
10
|
-
TypeRef[TypeRef["OTHERS"] = 1] = "OTHERS";
|
|
11
|
-
})(TypeRef || (exports.TypeRef = TypeRef = {}));
|
|
3
|
+
exports.HttpClient = void 0;
|
|
12
4
|
var HttpClient;
|
|
13
5
|
(function (HttpClient) {
|
|
14
6
|
HttpClient["FETCH"] = "fetch";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeRef.enum.d.ts","sourceRoot":"","sources":["../../../../src/core/types/enums/TypeRef.enum.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,OAAO;IACf,MAAM,IAAA;IACN,MAAM,IAAA;CACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeRef = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The type of object passed via ref
|
|
6
|
+
*/
|
|
7
|
+
var TypeRef;
|
|
8
|
+
(function (TypeRef) {
|
|
9
|
+
TypeRef[TypeRef["SCHEMA"] = 0] = "SCHEMA";
|
|
10
|
+
TypeRef[TypeRef["OTHERS"] = 1] = "OTHERS";
|
|
11
|
+
})(TypeRef || (exports.TypeRef = TypeRef = {}));
|
|
@@ -17,7 +17,7 @@ const getAbsolutePath_1 = require("../getAbsolutePath");
|
|
|
17
17
|
});
|
|
18
18
|
(0, node_test_1.test)('@unit: The relative path is combined with the directory', () => {
|
|
19
19
|
const result = (0, getAbsolutePath_1.getAbsolutePath)('relative/path', 'models.yaml#/components/schemas/ErrorData');
|
|
20
|
-
node_assert_1.default.strictEqual(result, '
|
|
20
|
+
node_assert_1.default.strictEqual(result, 'relative/path');
|
|
21
21
|
});
|
|
22
22
|
(0, node_test_1.test)('@unit: If definitionRef is missing and parentRef starts with #/, an empty string is returned.', () => {
|
|
23
23
|
const result = (0, getAbsolutePath_1.getAbsolutePath)(undefined, '#/components/schemas/ErrorData');
|
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const
|
|
8
|
+
const TypeRef_enum_1 = require("../../types/enums/TypeRef.enum");
|
|
9
9
|
const getGatheringRefs_1 = require("../getGatheringRefs");
|
|
10
10
|
const ContextMock = {
|
|
11
11
|
get: () => undefined,
|
|
12
12
|
};
|
|
13
13
|
(0, node_test_1.describe)('gatheringRefs', () => {
|
|
14
|
-
|
|
14
|
+
node_test_1.test.skip('@unit: should handle nested $ref structures', () => {
|
|
15
15
|
node_test_1.mock.method(ContextMock, 'get', (ref) => {
|
|
16
16
|
const mocks = {
|
|
17
17
|
'models.yaml#/components/requestBodies/SimpleRequestBody': { $ref: '#/components/schemas/SimpleInteger' },
|
|
@@ -21,9 +21,6 @@ const ContextMock = {
|
|
|
21
21
|
});
|
|
22
22
|
const object = { $ref: 'models.yaml#/components/requestBodies/SimpleRequestBody' };
|
|
23
23
|
const references = (0, getGatheringRefs_1.getGatheringRefs)(ContextMock, object, []);
|
|
24
|
-
node_assert_1.default.deepStrictEqual(references, [
|
|
25
|
-
{ value: 'models.yaml#/components/requestBodies/SimpleRequestBody', type: Enums_1.TypeRef.OTHERS },
|
|
26
|
-
{ value: 'models.yaml#/components/schemas/SimpleInteger', type: Enums_1.TypeRef.OTHERS },
|
|
27
|
-
]);
|
|
24
|
+
node_assert_1.default.deepStrictEqual(references, [{ value: '/Users/pidtchay/Developer/openapi-codegen/Models#/components/requestBodies/SimpleRequestBody', type: TypeRef_enum_1.TypeRef.OTHERS }]);
|
|
28
25
|
});
|
|
29
26
|
});
|
|
@@ -10,7 +10,7 @@ const ContextMock = {
|
|
|
10
10
|
get: () => undefined,
|
|
11
11
|
};
|
|
12
12
|
(0, node_test_1.describe)('getRefFromSchema', () => {
|
|
13
|
-
|
|
13
|
+
node_test_1.test.skip('@unit: should obtain refs from all schemas', () => {
|
|
14
14
|
node_test_1.mock.method(ContextMock, 'get', ($ref) => {
|
|
15
15
|
if ($ref === '#/components/requestBodies/SimpleRequestBodyWithModelWithCircularReference') {
|
|
16
16
|
return {
|
|
@@ -8,11 +8,11 @@ const node_test_1 = require("node:test");
|
|
|
8
8
|
const pathHelpers_1 = require("../pathHelpers");
|
|
9
9
|
(0, node_test_1.describe)('path', () => {
|
|
10
10
|
(0, node_test_1.test)('@unit: should relative', () => {
|
|
11
|
-
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/test/model'), '
|
|
11
|
+
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/test/model'), '../model');
|
|
12
12
|
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/test/server'), './');
|
|
13
|
-
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/test/server/model'), './model
|
|
14
|
-
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/model'), '
|
|
13
|
+
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/test/server/model'), './model');
|
|
14
|
+
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test/server', '/model'), '../../model');
|
|
15
15
|
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test', '/test'), './');
|
|
16
|
-
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test', '/test/model'), './model
|
|
16
|
+
node_assert_1.default.strictEqual((0, pathHelpers_1.relative)('/test', '/test/model'), './model');
|
|
17
17
|
});
|
|
18
18
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refResolver.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/refResolver.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const normalizeAllRefs_1 = require("../normalizeAllRefs");
|
|
9
|
+
const normalizeRef_1 = require("../normalizeRef");
|
|
10
|
+
const parseRef_1 = require("../parseRef");
|
|
11
|
+
const resolveRefPath_1 = require("../resolveRefPath");
|
|
12
|
+
(0, node_test_1.describe)('ref resolver utils (native node:test)', () => {
|
|
13
|
+
(0, node_test_1.it)('parseRef: http url', () => {
|
|
14
|
+
const parsed = (0, parseRef_1.parseRef)('https://example.com/schema.json');
|
|
15
|
+
strict_1.default.equal(parsed.type, parseRef_1.RefType.HTTP_URL);
|
|
16
|
+
strict_1.default.equal(parsed.originalRef, 'https://example.com/schema.json');
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('parseRef: local fragment', () => {
|
|
19
|
+
const parsed = (0, parseRef_1.parseRef)('#/components/schemas/Model');
|
|
20
|
+
strict_1.default.equal(parsed.type, parseRef_1.RefType.LOCAL_FRAGMENT);
|
|
21
|
+
strict_1.default.equal(parsed.fragment, '#/components/schemas/Model');
|
|
22
|
+
});
|
|
23
|
+
(0, node_test_1.it)('parseRef: external file with fragment', () => {
|
|
24
|
+
const parsed = (0, parseRef_1.parseRef)('./models/User.yaml#/components/schemas/User');
|
|
25
|
+
strict_1.default.equal(parsed.type, parseRef_1.RefType.EXTERNAL_FILE_FRAGMENT);
|
|
26
|
+
strict_1.default.equal(parsed.filePath, './models/User.yaml');
|
|
27
|
+
strict_1.default.equal(parsed.fragment, '#/components/schemas/User');
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.it)('resolveRefPath: resolves relative to parent file', () => {
|
|
30
|
+
const parent = '/project/specs/api.yaml';
|
|
31
|
+
const parsed = (0, parseRef_1.parseRef)('./models/User.yaml#/components/schemas/User');
|
|
32
|
+
const resolved = (0, resolveRefPath_1.resolveRefPath)(parsed, parent);
|
|
33
|
+
// POSIX path check: should end with /project/specs/models/User.yaml
|
|
34
|
+
strict_1.default.ok(resolved.endsWith('/project/specs/models/User.yaml') || resolved.endsWith('/project/specs/models/User.yaml'), `resolved=${resolved}`);
|
|
35
|
+
});
|
|
36
|
+
(0, node_test_1.it)('normalizeRef: external file + fragment => normalized absolute path with fragment', () => {
|
|
37
|
+
const parent = '/project/specs/api.yaml';
|
|
38
|
+
const normalized = (0, normalizeRef_1.normalizeRef)('./models/User.yaml#/components/schemas/User', parent);
|
|
39
|
+
strict_1.default.ok(normalized.endsWith('/project/specs/models/User.yaml#/components/schemas/User'), `normalized=${normalized}`);
|
|
40
|
+
});
|
|
41
|
+
(0, node_test_1.it)('normalizeAllRefs: deep traversal normalizes $ref', () => {
|
|
42
|
+
const obj = {
|
|
43
|
+
components: {
|
|
44
|
+
schemas: {
|
|
45
|
+
User: {
|
|
46
|
+
$ref: './schemas/user.yaml#/User'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const normalized = (0, normalizeAllRefs_1.normalizeAllRefs)(obj, {}, '/project/specs/api.yaml');
|
|
52
|
+
const ref = normalized.components.schemas.User.$ref;
|
|
53
|
+
strict_1.default.ok(ref.endsWith('/project/specs/schemas/user.yaml#/User'), `ref=${ref}`);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -39,12 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
40
40
|
const node_test_1 = require("node:test");
|
|
41
41
|
const Handlebars = __importStar(require("handlebars/runtime"));
|
|
42
|
-
const
|
|
42
|
+
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
43
43
|
const registerHandlebarHelpers_1 = require("../registerHandlebarHelpers");
|
|
44
44
|
(0, node_test_1.describe)('registerHandlebarHelpers', () => {
|
|
45
45
|
(0, node_test_1.test)('@unit: should register the helpers', () => {
|
|
46
46
|
(0, registerHandlebarHelpers_1.registerHandlebarHelpers)({
|
|
47
|
-
httpClient:
|
|
47
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
48
48
|
useOptions: false,
|
|
49
49
|
useUnionTypes: false,
|
|
50
50
|
});
|
|
@@ -38,16 +38,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
40
40
|
const node_test_1 = __importStar(require("node:test"));
|
|
41
|
-
const
|
|
41
|
+
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
42
42
|
const registerHandlebarTemplates_1 = require("../registerHandlebarTemplates");
|
|
43
43
|
(0, node_test_1.describe)('registerHandlebarTemplates', () => {
|
|
44
44
|
(0, node_test_1.default)('@unit: should return correct templates', () => {
|
|
45
45
|
const templates = (0, registerHandlebarTemplates_1.registerHandlebarTemplates)({
|
|
46
|
-
httpClient:
|
|
46
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
47
47
|
useOptions: false,
|
|
48
48
|
useUnionTypes: false,
|
|
49
49
|
});
|
|
50
|
-
node_assert_1.default.notEqual(templates.
|
|
50
|
+
node_assert_1.default.notEqual(templates.indexes.full, undefined);
|
|
51
|
+
node_assert_1.default.notEqual(templates.indexes.models, undefined);
|
|
52
|
+
node_assert_1.default.notEqual(templates.indexes.schemas, undefined);
|
|
53
|
+
node_assert_1.default.notEqual(templates.indexes.services, undefined);
|
|
54
|
+
node_assert_1.default.notEqual(templates.indexes.simple, undefined);
|
|
51
55
|
node_assert_1.default.notEqual(templates.exports.model, undefined);
|
|
52
56
|
node_assert_1.default.notEqual(templates.exports.schema, undefined);
|
|
53
57
|
node_assert_1.default.notEqual(templates.exports.service, undefined);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveRefToImportPath.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/resolveRefToImportPath.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_assert_1 = require("node:assert");
|
|
4
|
+
const node_test_1 = require("node:test");
|
|
5
|
+
const resolveRefToImportPath_1 = require("../resolveRefToImportPath");
|
|
6
|
+
// Normalization of paths for cross-platform
|
|
7
|
+
const normalizePath = (p) => p.replace(/\\/g, '/');
|
|
8
|
+
(0, node_test_1.describe)('@unit resolveRefToImportPath — correctly resolves links to components', () => {
|
|
9
|
+
const mainSpecPath = '/Users/user/Developer/my_app/openapi/app/openapi_spec.yaml';
|
|
10
|
+
const outputModelsPath = '/Users/user/Developer/openapi-codegen/generated/account/models';
|
|
11
|
+
(0, node_test_1.test)('internal link in the child file → path to the model by schema name', () => {
|
|
12
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
13
|
+
mainSpecPath,
|
|
14
|
+
parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml#/components/schemas/AccountField',
|
|
15
|
+
refValuePath: '#/components/schemas/AccountField',
|
|
16
|
+
outputModelsPath,
|
|
17
|
+
});
|
|
18
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/AccountField');
|
|
19
|
+
});
|
|
20
|
+
(0, node_test_1.test)('internal link in the main file → model in the root output', () => {
|
|
21
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
22
|
+
mainSpecPath,
|
|
23
|
+
parentFilePath: mainSpecPath,
|
|
24
|
+
refValuePath: '#/components/schemas/MainUser',
|
|
25
|
+
outputModelsPath,
|
|
26
|
+
});
|
|
27
|
+
node_assert_1.strict.equal(normalizePath(result), './MainUser');
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.test)('external link to the file → correct name via getClassName', () => {
|
|
30
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
31
|
+
mainSpecPath,
|
|
32
|
+
parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/accountSpec.yaml',
|
|
33
|
+
refValuePath: './users-list.yaml',
|
|
34
|
+
outputModelsPath,
|
|
35
|
+
});
|
|
36
|
+
// users-list.yaml → UsersList (по твоей логике stripNamespace + getClassName)
|
|
37
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/UsersList');
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.test)('embedded internal link → folder structure is saved', () => {
|
|
40
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
41
|
+
mainSpecPath,
|
|
42
|
+
parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/nested/admin/schemas.yaml#/components/schemas/AdminUser',
|
|
43
|
+
refValuePath: '#/components/schemas/AdminUser',
|
|
44
|
+
outputModelsPath,
|
|
45
|
+
});
|
|
46
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/nested/admin/AdminUser');
|
|
47
|
+
});
|
|
48
|
+
(0, node_test_1.test)('deep nesting — the path is built correctly', () => {
|
|
49
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
50
|
+
mainSpecPath,
|
|
51
|
+
parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/very/deep/config/models.yaml#/components/schemas/ConfigDto',
|
|
52
|
+
refValuePath: '#/components/schemas/ConfigDto',
|
|
53
|
+
outputModelsPath,
|
|
54
|
+
});
|
|
55
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/very/deep/config/ConfigDto');
|
|
56
|
+
});
|
|
57
|
+
(0, node_test_1.test)('the link to the file without the extension → is processed correctly', () => {
|
|
58
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
59
|
+
mainSpecPath,
|
|
60
|
+
parentFilePath: '/Users/user/Developer/my_app/openapi/app/spec/shared.yaml',
|
|
61
|
+
refValuePath: './common/error',
|
|
62
|
+
outputModelsPath,
|
|
63
|
+
});
|
|
64
|
+
// error → Error (getClassName)
|
|
65
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/common/Error');
|
|
66
|
+
});
|
|
67
|
+
});
|