ts-openapi-codegen 1.0.0-beta.5 → 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.d.ts +5 -0
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +1 -0
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +40 -0
- package/dist/cli/generate/runGenerateOpenApi.js +4 -4
- package/dist/cli/index.js +57 -18
- package/dist/cli/utils.d.ts +4 -16
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +22 -20
- package/dist/common/Options.d.ts +4 -6
- package/dist/common/Options.d.ts.map +1 -1
- package/dist/common/UpdateNotifier.d.ts +24 -0
- package/dist/common/UpdateNotifier.d.ts.map +1 -0
- package/dist/common/UpdateNotifier.js +120 -0
- 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 +94 -0
- package/dist/core/WriteClient.d.ts.map +1 -0
- package/dist/core/WriteClient.js +293 -0
- package/dist/core/__tests__/WriteClient.test.d.ts +2 -0
- package/dist/core/__tests__/WriteClient.test.d.ts.map +1 -0
- package/dist/core/{utils/__tests__/writeClient.test.js → __tests__/WriteClient.test.js} +16 -12
- 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 +21 -22
- 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 +3 -0
- package/dist/core/utils/prepareAlias.d.ts.map +1 -0
- package/dist/core/utils/prepareAlias.js +20 -0
- 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 +16 -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 +3 -0
- package/dist/core/utils/sortModelByName.d.ts.map +1 -0
- package/dist/core/utils/sortModelByName.js +12 -0
- 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/dist/templatesCompiled/partials/isReadOnly.d.ts +1 -1
- package/dist/templatesCompiled/partials/isReadOnly.d.ts.map +1 -1
- package/dist/templatesCompiled/partials/isReadOnly.js +1 -2
- package/dist/templatesCompiled/partials/isRequiredDefinition.d.ts +9 -0
- package/dist/templatesCompiled/partials/isRequiredDefinition.d.ts.map +1 -0
- package/dist/templatesCompiled/partials/isRequiredDefinition.js +27 -0
- package/dist/templatesCompiled/partials/parametersDefinition.js +1 -1
- package/package.json +15 -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__/writeClient.test.d.ts +0 -2
- package/dist/core/utils/__tests__/writeClient.test.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/writeClient.d.ts +0 -89
- package/dist/core/utils/writeClient.d.ts.map +0 -1
- package/dist/core/utils/writeClient.js +0 -227
- 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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServiceName = getServiceName;
|
|
4
|
+
const getClassName_1 = require("../../../utils/getClassName");
|
|
5
|
+
const getServiceClassName_1 = require("../../../utils/getServiceClassName");
|
|
6
|
+
function getServiceName(op, fileName) {
|
|
7
|
+
return (0, getServiceClassName_1.getServiceClassName)(op.tags?.[0] || `${(0, getClassName_1.getClassName)(fileName)}Service`);
|
|
8
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getServices.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getServices.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAKtD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAgCrE"}
|
|
@@ -6,19 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getServices = getServices;
|
|
7
7
|
const get_1 = __importDefault(require("lodash-es/get"));
|
|
8
8
|
const getClassName_1 = require("../../../utils/getClassName");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
function getServiceName(op, fileName) {
|
|
12
|
-
return (0, getServiceClassName_1.getServiceClassName)(op.tags?.[0] || `${(0, getClassName_1.getClassName)(fileName)}Service`);
|
|
13
|
-
}
|
|
14
|
-
function fillModelsByAlias(items, value) {
|
|
15
|
-
items
|
|
16
|
-
.filter(result => result.path === value.path && result.type === value.name && value.alias)
|
|
17
|
-
.forEach(result => {
|
|
18
|
-
result.alias = value.alias;
|
|
19
|
-
result.base = value.alias;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
9
|
+
const serviceHelpers_1 = require("../../../utils/serviceHelpers");
|
|
10
|
+
const getServiceName_1 = require("./getServiceName");
|
|
22
11
|
/**
|
|
23
12
|
* Get the OpenAPI services
|
|
24
13
|
*/
|
|
@@ -27,81 +16,26 @@ function getServices(openApi) {
|
|
|
27
16
|
for (const url in openApi.paths) {
|
|
28
17
|
if ((0, get_1.default)(openApi.paths, url, null)) {
|
|
29
18
|
// Grab path and parse any global path parameters
|
|
30
|
-
const
|
|
31
|
-
const
|
|
19
|
+
const pathByUrl = openApi.paths[url];
|
|
20
|
+
const path = (pathByUrl.$ref ? this.context.get(pathByUrl.$ref) : pathByUrl);
|
|
21
|
+
const pathParams = this.getOperationParameters(openApi, path.parameters || [], '');
|
|
22
|
+
const parentFileRef = pathByUrl.$ref || this.context.root?.path || '';
|
|
32
23
|
// Parse all the methods for this path
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const op = path[method];
|
|
45
|
-
const fileName = this.context.fileName();
|
|
46
|
-
const serviceName = getServiceName(op, fileName);
|
|
47
|
-
// If we have already declared a service, then we should fetch that and
|
|
48
|
-
// append the new method to it. Otherwise we should create a new service object.
|
|
49
|
-
const service = services.get(serviceName) ||
|
|
50
|
-
{
|
|
51
|
-
name: serviceName,
|
|
52
|
-
originName: (0, getClassName_1.getClassName)(op.tags?.[0] || fileName),
|
|
53
|
-
operations: [],
|
|
54
|
-
imports: [],
|
|
55
|
-
};
|
|
56
|
-
const operation = this.getOperation(openApi, url, method, op, pathParams, serviceName);
|
|
57
|
-
// Push the operation in the service
|
|
58
|
-
service.operations.push(operation);
|
|
59
|
-
operation.imports = operation.imports.map(item => {
|
|
60
|
-
const operationImport = service.imports.find(serviceImport => serviceImport.path === item.path);
|
|
61
|
-
if (!operationImport) {
|
|
62
|
-
return item;
|
|
63
|
-
}
|
|
64
|
-
return operationImport;
|
|
65
|
-
});
|
|
66
|
-
service.imports.push(...operation.imports);
|
|
67
|
-
services.set(operation.service, service);
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
24
|
+
(0, serviceHelpers_1.forEachOperationInPath)(path, (method, op) => {
|
|
25
|
+
// Each method contains an OpenAPI operation, we parse the operation
|
|
26
|
+
const fileName = this.context.fileName();
|
|
27
|
+
const serviceName = (0, getServiceName_1.getServiceName)(op, fileName);
|
|
28
|
+
const service = (0, serviceHelpers_1.ensureService)(services, serviceName, (0, getClassName_1.getClassName)(op.tags?.[0] || fileName));
|
|
29
|
+
const operation = this.getOperation(openApi, url, method, op, pathParams, serviceName, parentFileRef);
|
|
30
|
+
// Merge operation imports into service (reuse import objects when possible)
|
|
31
|
+
(0, serviceHelpers_1.mergeOperationImportsIntoService)(service, operation);
|
|
32
|
+
service.operations.push(operation);
|
|
33
|
+
services.set(operation.service, service);
|
|
34
|
+
});
|
|
73
35
|
}
|
|
74
36
|
}
|
|
75
37
|
services.forEach(service => {
|
|
76
|
-
|
|
77
|
-
const nameA = a.name.toLowerCase();
|
|
78
|
-
const nameB = b.name.toLowerCase();
|
|
79
|
-
return nameA.localeCompare(nameB, 'en');
|
|
80
|
-
});
|
|
81
|
-
let previous;
|
|
82
|
-
let index = 1;
|
|
83
|
-
service.imports = service.imports.map(value => {
|
|
84
|
-
if (previous && previous.name === value.name) {
|
|
85
|
-
if (index === 1) {
|
|
86
|
-
previous.alias = `${value.name}$${index}`;
|
|
87
|
-
index++;
|
|
88
|
-
}
|
|
89
|
-
value.alias = `${value.name}$${index}`;
|
|
90
|
-
index++;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
value.alias = '';
|
|
94
|
-
index = 1;
|
|
95
|
-
}
|
|
96
|
-
previous = value;
|
|
97
|
-
return value;
|
|
98
|
-
});
|
|
99
|
-
service.imports.forEach(item => {
|
|
100
|
-
for (const operation of service.operations) {
|
|
101
|
-
fillModelsByAlias(operation.results, item);
|
|
102
|
-
fillModelsByAlias(operation.parameters, item);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
38
|
+
(0, serviceHelpers_1.finalizeServiceImports)(service);
|
|
105
39
|
});
|
|
106
40
|
return Array.from(services.values());
|
|
107
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA4C5E"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getType = getType;
|
|
4
|
-
const getAbsolutePath_1 = require("../../../utils/getAbsolutePath");
|
|
5
4
|
const getMappedType_1 = require("../../../utils/getMappedType");
|
|
6
|
-
const getRelativeModelImportPath_1 = require("../../../utils/getRelativeModelImportPath");
|
|
7
|
-
const getRelativeModelPath_1 = require("../../../utils/getRelativeModelPath");
|
|
8
5
|
const getTypeName_1 = require("../../../utils/getTypeName");
|
|
9
6
|
const replaceString_1 = require("../../../utils/replaceString");
|
|
7
|
+
const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
|
|
10
8
|
const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
11
9
|
/**
|
|
12
10
|
* Parse any string value into a type object.
|
|
@@ -14,7 +12,7 @@ const stripNamespace_1 = require("../../../utils/stripNamespace");
|
|
|
14
12
|
* @param parentRef Reference to a parent model
|
|
15
13
|
*/
|
|
16
14
|
function getType(value, parentRef) {
|
|
17
|
-
const normalizedValue = (0, replaceString_1.replaceString)(value);
|
|
15
|
+
const normalizedValue = (0, replaceString_1.replaceString)(value) || '';
|
|
18
16
|
const result = {
|
|
19
17
|
type: 'any',
|
|
20
18
|
base: 'any',
|
|
@@ -22,23 +20,37 @@ function getType(value, parentRef) {
|
|
|
22
20
|
path: '',
|
|
23
21
|
template: null,
|
|
24
22
|
};
|
|
25
|
-
const valueClean = (0, stripNamespace_1.stripNamespace)(normalizedValue
|
|
26
|
-
const valuePath = (0, getRelativeModelPath_1.getRelativeModelPath)(this.context.output?.outputModels, valueClean);
|
|
23
|
+
const valueClean = (0, stripNamespace_1.stripNamespace)(normalizedValue);
|
|
27
24
|
if ((0, getMappedType_1.hasMappedType)(valueClean)) {
|
|
28
25
|
const mapped = (0, getMappedType_1.getMappedType)(valueClean);
|
|
29
|
-
result.path =
|
|
26
|
+
result.path = valueClean.toLowerCase();
|
|
30
27
|
if (mapped) {
|
|
31
28
|
result.type = mapped;
|
|
32
29
|
result.base = mapped;
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
else if (valueClean) {
|
|
36
|
-
|
|
37
|
-
const
|
|
33
|
+
// Safely calculate the path that the specification file will have in outputModels folder
|
|
34
|
+
const valuePath = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
35
|
+
mainSpecPath: this.context.root?.path || '',
|
|
36
|
+
parentFilePath: parentRef,
|
|
37
|
+
refValuePath: normalizedValue,
|
|
38
|
+
outputModelsPath: this.context.output?.outputModels,
|
|
39
|
+
});
|
|
40
|
+
const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean));
|
|
41
|
+
// Only prefix with "./" when the path is non-empty and does not already
|
|
42
|
+
// start with "/" (absolute) or "." (relative like "./" or "../").
|
|
43
|
+
let valueImportPath = valuePath;
|
|
44
|
+
if (valuePath && !valuePath.startsWith('/') && !valuePath.startsWith('.')) {
|
|
45
|
+
valueImportPath = `./${valuePath}`;
|
|
46
|
+
}
|
|
38
47
|
result.path = valuePath;
|
|
39
48
|
result.type = type;
|
|
40
49
|
result.base = type;
|
|
41
|
-
|
|
50
|
+
// Push import only when we actually have a path (avoid './' for empty)
|
|
51
|
+
if (valuePath) {
|
|
52
|
+
result.imports.push({ name: type, alias: '', path: valueImportPath });
|
|
53
|
+
}
|
|
42
54
|
}
|
|
43
55
|
return result;
|
|
44
56
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { OpenApiReference } from '../../../types/shared/OpenApiReference.model';
|
|
1
2
|
import type { OpenApiOperation } from './OpenApiOperation.model';
|
|
2
3
|
import type { OpenApiParameter } from './OpenApiParameter.model';
|
|
3
4
|
import type { OpenApiServer } from './OpenApiServer.model';
|
|
4
5
|
/**
|
|
5
6
|
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathItemObject
|
|
6
7
|
*/
|
|
7
|
-
export interface OpenApiPath {
|
|
8
|
+
export interface OpenApiPath extends OpenApiReference {
|
|
8
9
|
summary?: string;
|
|
9
10
|
description?: string;
|
|
10
11
|
get?: OpenApiOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiPath.model.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/types/OpenApiPath.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"OpenApiPath.model.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/types/OpenApiPath.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TMultiOptions, TOptions } from '../common/Options';
|
|
2
|
-
export { HttpClient } from './types/
|
|
2
|
+
export { HttpClient } from './types/enums/HttpClient.enum';
|
|
3
3
|
export declare function generate(options: TOptions | TOptions[] | TMultiOptions): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAmB5D,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAmB5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAiH3D,wBAAsB,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,EAAE,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5F"}
|
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");
|
|
@@ -20,9 +20,9 @@ const isString_1 = require("./utils/isString");
|
|
|
20
20
|
const postProcessClient_1 = require("./utils/postProcessClient");
|
|
21
21
|
const prepareOptions_1 = require("./utils/prepareOptions");
|
|
22
22
|
const registerHandlebarTemplates_1 = require("./utils/registerHandlebarTemplates");
|
|
23
|
-
const
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return
|
|
23
|
+
const WriteClient_1 = require("./WriteClient");
|
|
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
|
}
|
|
@@ -128,7 +122,7 @@ async function generate(options) {
|
|
|
128
122
|
preparedOptions = Array.of(options);
|
|
129
123
|
}
|
|
130
124
|
const optionsFinal = preparedOptions.map(op => (0, prepareOptions_1.prepareOptions)(op));
|
|
131
|
-
const writeClient = new
|
|
125
|
+
const writeClient = new WriteClient_1.WriteClient();
|
|
132
126
|
writeClient.logger.forceInfo(`Generation has begun. Total number of specification files: ${optionsFinal.length}`);
|
|
133
127
|
try {
|
|
134
128
|
const start = process.hrtime();
|
|
@@ -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 {
|