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
|
@@ -5,7 +5,7 @@ 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 swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
9
9
|
const Context_1 = require("../../../../Context");
|
|
10
10
|
const getOutputPaths_1 = require("../../../../utils/getOutputPaths");
|
|
11
11
|
const Parser_1 = require("../../Parser");
|
|
@@ -13,7 +13,7 @@ const Parser_1 = require("../../Parser");
|
|
|
13
13
|
(0, node_test_1.test)('@unit: should convert int', async () => {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
const parser = new
|
|
16
|
+
const parser = new swagger_parser_1.default();
|
|
17
17
|
const context = new Context_1.Context({ input: 'test/spec/v3.yml', output: (0, getOutputPaths_1.getOutputPaths)({ output: './generated' }) });
|
|
18
18
|
context.addRefs(await parser.resolve('test/spec/v3.yml'));
|
|
19
19
|
const type = new Parser_1.Parser(context).getType('int', '');
|
|
@@ -25,37 +25,19 @@ const Parser_1 = require("../../Parser");
|
|
|
25
25
|
(0, node_test_1.test)('@unit: should support file with ext', async () => {
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
27
|
// @ts-ignore
|
|
28
|
-
const parser = new
|
|
28
|
+
const parser = new swagger_parser_1.default();
|
|
29
29
|
const context = new Context_1.Context({ input: 'test/spec/v3.yml', output: (0, getOutputPaths_1.getOutputPaths)({ output: './generated' }) });
|
|
30
30
|
context.addRefs(await parser.resolve('test/spec/v3.yml'));
|
|
31
31
|
const type = new Parser_1.Parser(context).getType('schemas/ModelWithString.yml', '');
|
|
32
|
-
node_assert_1.default.strictEqual(type.type, '
|
|
33
|
-
node_assert_1.default.strictEqual(type.base, '
|
|
32
|
+
node_assert_1.default.strictEqual(type.type, 'ModelWithString');
|
|
33
|
+
node_assert_1.default.strictEqual(type.base, 'ModelWithString');
|
|
34
34
|
node_assert_1.default.strictEqual(type.template, null);
|
|
35
35
|
node_assert_1.default.deepStrictEqual(type.imports, [
|
|
36
36
|
{
|
|
37
|
-
name: '
|
|
37
|
+
name: 'ModelWithString',
|
|
38
38
|
alias: '',
|
|
39
|
-
path: '
|
|
39
|
+
path: '././schemas/ModelWithString',
|
|
40
40
|
},
|
|
41
41
|
]);
|
|
42
42
|
});
|
|
43
|
-
const object = {
|
|
44
|
-
components: {
|
|
45
|
-
schemas: {
|
|
46
|
-
someSpecialSchema: {
|
|
47
|
-
type: 'object',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
(0, node_test_1.test)('@unit: should support external generation type', async () => {
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
const parser = new json_schema_ref_parser_1.default();
|
|
56
|
-
const context = new Context_1.Context({ input: object, output: (0, getOutputPaths_1.getOutputPaths)({ output: './generated' }) });
|
|
57
|
-
context.addRefs(await parser.resolve(object));
|
|
58
|
-
const type = new Parser_1.Parser(context).getType('#/components/schemas/someSpecialSchema', '');
|
|
59
|
-
node_assert_1.default.strictEqual(type.type, 'ISomeSpecialSchema');
|
|
60
|
-
});
|
|
61
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModel.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModel.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAO/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,KAAK,CA2JjE"}
|
|
@@ -6,6 +6,7 @@ const getComment_1 = require("../../../utils/getComment");
|
|
|
6
6
|
const getEnum_1 = require("../../../utils/getEnum");
|
|
7
7
|
const getEnumFromDescription_1 = require("../../../utils/getEnumFromDescription");
|
|
8
8
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
9
|
+
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
9
10
|
function getModel(config) {
|
|
10
11
|
const { openApi, definition, isDefinition = false, name = '', path = '', parentRef } = config;
|
|
11
12
|
const model = {
|
|
@@ -44,7 +45,8 @@ function getModel(config) {
|
|
|
44
45
|
properties: [],
|
|
45
46
|
};
|
|
46
47
|
if (definition.$ref) {
|
|
47
|
-
const
|
|
48
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(definition.$ref, parentRef);
|
|
49
|
+
const definitionRef = this.getType(definition.$ref, normalizedRef);
|
|
48
50
|
model.export = 'reference';
|
|
49
51
|
model.type = definitionRef.type;
|
|
50
52
|
model.base = definitionRef.base;
|
|
@@ -75,7 +77,8 @@ function getModel(config) {
|
|
|
75
77
|
}
|
|
76
78
|
if (definition.type === 'array' && definition.items) {
|
|
77
79
|
if (definition.items.$ref) {
|
|
78
|
-
const
|
|
80
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(definition.items.$ref, parentRef);
|
|
81
|
+
const arrayItems = this.getType(definition.items.$ref, normalizedRef);
|
|
79
82
|
model.export = 'array';
|
|
80
83
|
model.type = arrayItems.type;
|
|
81
84
|
model.base = arrayItems.base;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModelProperties.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModelProperties.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModelProperties.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModelProperties.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAK/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,EAAE,CAiFxH"}
|
|
@@ -8,6 +8,7 @@ const get_1 = __importDefault(require("lodash-es/get"));
|
|
|
8
8
|
const escapeName_1 = require("../../../utils/escapeName");
|
|
9
9
|
const getComment_1 = require("../../../utils/getComment");
|
|
10
10
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
11
|
+
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
11
12
|
function getModelProperties(openApi, definition, parentRef) {
|
|
12
13
|
const models = [];
|
|
13
14
|
for (const propertyName in definition.properties) {
|
|
@@ -15,7 +16,8 @@ function getModelProperties(openApi, definition, parentRef) {
|
|
|
15
16
|
const property = definition.properties[propertyName];
|
|
16
17
|
const propertyRequired = definition.required?.includes(propertyName) || property.default !== undefined;
|
|
17
18
|
if (property.$ref) {
|
|
18
|
-
const
|
|
19
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(property.$ref, parentRef);
|
|
20
|
+
const model = this.getType(property.$ref, normalizedRef);
|
|
19
21
|
models.push({
|
|
20
22
|
name: (0, escapeName_1.escapeName)(propertyName),
|
|
21
23
|
alias: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAK/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAK/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getModels = getModels;
|
|
4
4
|
const getRefFromSchema_1 = require("../../../utils/getRefFromSchema");
|
|
5
|
-
const
|
|
5
|
+
const modelHelpers_1 = require("../../../utils/modelHelpers");
|
|
6
6
|
const sortModelsByName_1 = require("../../../utils/sortModelsByName");
|
|
7
7
|
const unique_1 = require("../../../utils/unique");
|
|
8
8
|
function getModels(openApi) {
|
|
@@ -23,34 +23,8 @@ function getModels(openApi) {
|
|
|
23
23
|
models.push(model);
|
|
24
24
|
}
|
|
25
25
|
models = (0, sortModelsByName_1.sortModelsByName)(models.filter(unique_1.unique));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
models.forEach(model => {
|
|
29
|
-
if (previous && previous.name === model.name) {
|
|
30
|
-
if (index === 1) {
|
|
31
|
-
previous.alias = `${model.name}$${index}`;
|
|
32
|
-
index++;
|
|
33
|
-
}
|
|
34
|
-
model.alias = `${model.name}$${index}`;
|
|
35
|
-
index++;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
model.alias = '';
|
|
39
|
-
index = 1;
|
|
40
|
-
}
|
|
41
|
-
previous = model;
|
|
42
|
-
});
|
|
43
|
-
models.forEach(model => {
|
|
44
|
-
model.imports = model.imports.map(imprt => {
|
|
45
|
-
const importModel = models.filter(value => `${value.path}${value.name}` === imprt.path && value.name === imprt.name);
|
|
46
|
-
const importAlias = importModel.length > 0 ? importModel[0].alias : imprt?.alias;
|
|
47
|
-
const importPath = importModel.length > 0 ? (0, pathHelpers_1.join)((0, pathHelpers_1.relative)(model.path, importModel[0].path), imprt.name) : imprt.path;
|
|
48
|
-
return Object.assign(imprt, {
|
|
49
|
-
alias: importAlias,
|
|
50
|
-
path: importPath,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
26
|
+
(0, modelHelpers_1.setDuplicateModelAliases)(models);
|
|
27
|
+
(0, modelHelpers_1.resolveModelImports)(models, this.context.output.outputModels);
|
|
54
28
|
}
|
|
55
29
|
return models.filter(unique_1.unique);
|
|
56
30
|
}
|
|
@@ -3,5 +3,5 @@ import type { OperationParameters } from '../../../types/shared/OperationParamet
|
|
|
3
3
|
import { Parser } from '../Parser';
|
|
4
4
|
import type { OpenApi } from '../types/OpenApi.model';
|
|
5
5
|
import type { OpenApiOperation } from '../types/OpenApiOperation.model';
|
|
6
|
-
export declare function getOperation(this: Parser, openApi: OpenApi, url: string, method: string, op: OpenApiOperation, pathParams: OperationParameters): Operation;
|
|
6
|
+
export declare function getOperation(this: Parser, openApi: OpenApi, url: string, method: string, op: OpenApiOperation, pathParams: OperationParameters, parentRef: string): Operation;
|
|
7
7
|
//# sourceMappingURL=getOperation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperation.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAQ3F,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,mBAAmB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"getOperation.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAQ3F,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAwD7K"}
|
|
@@ -8,7 +8,7 @@ const getOperationPath_1 = require("../../../utils/getOperationPath");
|
|
|
8
8
|
const getOperationResponseHeader_1 = require("../../../utils/getOperationResponseHeader");
|
|
9
9
|
const getOperationResults_1 = require("../../../utils/getOperationResults");
|
|
10
10
|
const getServiceClassName_1 = require("../../../utils/getServiceClassName");
|
|
11
|
-
function getOperation(openApi, url, method, op, pathParams) {
|
|
11
|
+
function getOperation(openApi, url, method, op, pathParams, parentRef) {
|
|
12
12
|
const serviceName = op.tags?.[0] || 'Service';
|
|
13
13
|
const serviceClassName = (0, getServiceClassName_1.getServiceClassName)(serviceName);
|
|
14
14
|
const operationNameFallback = `${method}${serviceClassName}`;
|
|
@@ -37,7 +37,7 @@ function getOperation(openApi, url, method, op, pathParams) {
|
|
|
37
37
|
};
|
|
38
38
|
// Parse the operation parameters (path, query, body, etc).
|
|
39
39
|
if (op.parameters) {
|
|
40
|
-
const parameters = this.getOperationParameters(openApi, op.parameters);
|
|
40
|
+
const parameters = this.getOperationParameters(openApi, op.parameters, parentRef);
|
|
41
41
|
operation.imports.push(...parameters.imports);
|
|
42
42
|
operation.parameters.push(...parameters.parameters);
|
|
43
43
|
operation.parametersPath.push(...parameters.parametersPath);
|
|
@@ -49,7 +49,7 @@ function getOperation(openApi, url, method, op, pathParams) {
|
|
|
49
49
|
}
|
|
50
50
|
// Parse the operation responses.
|
|
51
51
|
if (op.responses) {
|
|
52
|
-
const operationResponses = this.getOperationResponses(openApi, op.responses);
|
|
52
|
+
const operationResponses = this.getOperationResponses(openApi, op.responses, parentRef);
|
|
53
53
|
const operationResults = (0, getOperationResults_1.getOperationResults)(operationResponses);
|
|
54
54
|
operation.errors = (0, getOperationErrors_1.getOperationErrors)(operationResponses);
|
|
55
55
|
operation.responseHeader = (0, getOperationResponseHeader_1.getOperationResponseHeader)(operationResults);
|
|
@@ -2,5 +2,5 @@ import type { OperationParameter } from '../../../types/shared/OperationParamete
|
|
|
2
2
|
import { Parser } from '../Parser';
|
|
3
3
|
import type { OpenApi } from '../types/OpenApi.model';
|
|
4
4
|
import type { OpenApiParameter } from '../types/OpenApiParameter.model';
|
|
5
|
-
export declare function getOperationParameter(this: Parser, openApi: OpenApi, parameter: OpenApiParameter): OperationParameter;
|
|
5
|
+
export declare function getOperationParameter(this: Parser, openApi: OpenApi, parameter: OpenApiParameter, parentRef: string): OperationParameter;
|
|
6
6
|
//# sourceMappingURL=getOperationParameter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationParameter.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationParameter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"getOperationParameter.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationParameter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAQzF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAuIxI"}
|
|
@@ -7,8 +7,9 @@ const getEnum_1 = require("../../../utils/getEnum");
|
|
|
7
7
|
const getEnumFromDescription_1 = require("../../../utils/getEnumFromDescription");
|
|
8
8
|
const getOperationParameterName_1 = require("../../../utils/getOperationParameterName");
|
|
9
9
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
10
|
+
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
10
11
|
const getOperationParameterDefault_1 = require("./getOperationParameterDefault");
|
|
11
|
-
function getOperationParameter(openApi, parameter) {
|
|
12
|
+
function getOperationParameter(openApi, parameter, parentRef) {
|
|
12
13
|
const operationParameter = {
|
|
13
14
|
path: '',
|
|
14
15
|
in: parameter.in,
|
|
@@ -44,7 +45,8 @@ function getOperationParameter(openApi, parameter) {
|
|
|
44
45
|
mediaType: null,
|
|
45
46
|
};
|
|
46
47
|
if (parameter.$ref) {
|
|
47
|
-
const
|
|
48
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(parameter.$ref, parentRef);
|
|
49
|
+
const definitionRef = this.getType(parameter.$ref, normalizedRef);
|
|
48
50
|
operationParameter.export = 'reference';
|
|
49
51
|
operationParameter.type = definitionRef.type;
|
|
50
52
|
operationParameter.base = definitionRef.base;
|
|
@@ -2,5 +2,5 @@ import type { OperationParameters } from '../../../types/shared/OperationParamet
|
|
|
2
2
|
import { Parser } from '../Parser';
|
|
3
3
|
import type { OpenApi } from '../types/OpenApi.model';
|
|
4
4
|
import type { OpenApiParameter } from '../types/OpenApiParameter.model';
|
|
5
|
-
export declare function getOperationParameters(this: Parser, openApi: OpenApi, parameters: OpenApiParameter[]): OperationParameters;
|
|
5
|
+
export declare function getOperationParameters(this: Parser, openApi: OpenApi, parameters: OpenApiParameter[], parentRef: string): OperationParameters;
|
|
6
6
|
//# sourceMappingURL=getOperationParameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationParameters.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationParameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAG3F,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,mBAAmB,CA+
|
|
1
|
+
{"version":3,"file":"getOperationParameters.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationParameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAG3F,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CA+D7I"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOperationParameters = getOperationParameters;
|
|
4
4
|
const sortByRequiredExtended_1 = require("../../../utils/sortByRequiredExtended");
|
|
5
5
|
const sortByRequiredSimple_1 = require("../../../utils/sortByRequiredSimple");
|
|
6
|
-
function getOperationParameters(openApi, parameters) {
|
|
6
|
+
function getOperationParameters(openApi, parameters, parentRef) {
|
|
7
7
|
const operationParameters = {
|
|
8
8
|
imports: [],
|
|
9
9
|
parameters: [],
|
|
@@ -17,7 +17,7 @@ function getOperationParameters(openApi, parameters) {
|
|
|
17
17
|
// Iterate over the parameters
|
|
18
18
|
parameters.forEach(parameterOrReference => {
|
|
19
19
|
const parameterDef = (parameterOrReference.$ref ? this.context.get(parameterOrReference.$ref) : parameterOrReference);
|
|
20
|
-
const parameter = this.getOperationParameter(openApi, parameterDef);
|
|
20
|
+
const parameter = this.getOperationParameter(openApi, parameterDef, parentRef);
|
|
21
21
|
// We ignore the "api-version" param, since we do not want to add this
|
|
22
22
|
// as the first / default parameter for each of the service calls.
|
|
23
23
|
if (parameter.prop !== 'api-version') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponse.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"getOperationResponse.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAIvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAoF1J"}
|
|
@@ -7,6 +7,7 @@ exports.getOperationResponse = getOperationResponse;
|
|
|
7
7
|
const get_1 = __importDefault(require("lodash-es/get"));
|
|
8
8
|
const getComment_1 = require("../../../utils/getComment");
|
|
9
9
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
10
|
+
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
10
11
|
function getOperationResponse(openApi, response, responseCode, parentRef) {
|
|
11
12
|
const operationResponse = {
|
|
12
13
|
in: 'response',
|
|
@@ -35,7 +36,8 @@ function getOperationResponse(openApi, response, responseCode, parentRef) {
|
|
|
35
36
|
// then we need to parse the schema!
|
|
36
37
|
if (response.schema) {
|
|
37
38
|
if (response.schema.$ref) {
|
|
38
|
-
const
|
|
39
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(response.schema.$ref, parentRef);
|
|
40
|
+
const model = this.getType(response.schema.$ref, normalizedRef);
|
|
39
41
|
operationResponse.export = 'reference';
|
|
40
42
|
operationResponse.type = model.type;
|
|
41
43
|
operationResponse.base = model.base;
|
|
@@ -2,5 +2,5 @@ import type { OperationResponse } from '../../../types/shared/OperationResponse.
|
|
|
2
2
|
import { Parser } from '../Parser';
|
|
3
3
|
import type { OpenApi } from '../types/OpenApi.model';
|
|
4
4
|
import type { OpenApiResponses } from '../types/OpenApiResponses.model';
|
|
5
|
-
export declare function getOperationResponses(this: Parser, openApi: OpenApi, responses: OpenApiResponses): OperationResponse[];
|
|
5
|
+
export declare function getOperationResponses(this: Parser, openApi: OpenApi, responses: OpenApiResponses, parentRef: string): OperationResponse[];
|
|
6
6
|
//# sourceMappingURL=getOperationResponses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponses.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponses.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,GAAG,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"getOperationResponses.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getOperationResponses.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAsBzI"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getOperationResponses = getOperationResponses;
|
|
7
7
|
const get_1 = __importDefault(require("lodash-es/get"));
|
|
8
8
|
const getOperationResponseCode_1 = require("../../../utils/getOperationResponseCode");
|
|
9
|
-
function getOperationResponses(openApi, responses) {
|
|
9
|
+
function getOperationResponses(openApi, responses, parentRef) {
|
|
10
10
|
const operationResponses = [];
|
|
11
11
|
// Iterate over each response code and get the
|
|
12
12
|
// status code and response message (if any).
|
|
@@ -16,7 +16,7 @@ function getOperationResponses(openApi, responses) {
|
|
|
16
16
|
const response = (responseOrReference.$ref ? this.context.get(responseOrReference.$ref) : responseOrReference);
|
|
17
17
|
const responseCode = (0, getOperationResponseCode_1.getOperationResponseCode)(code);
|
|
18
18
|
if (responseCode) {
|
|
19
|
-
const operationResponse = this.getOperationResponse(openApi, response, responseCode,
|
|
19
|
+
const operationResponse = this.getOperationResponse(openApi, response, responseCode, parentRef);
|
|
20
20
|
operationResponses.push(operationResponse);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getServiceName.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getServiceName.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,wBAAgB,cAAc,CAAC,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7E"}
|
|
@@ -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/v2/parser/getServices.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"getServices.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/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"}
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getServices = getServices;
|
|
7
7
|
const get_1 = __importDefault(require("lodash-es/get"));
|
|
8
|
+
const getClassName_1 = require("../../../utils/getClassName");
|
|
9
|
+
const serviceHelpers_1 = require("../../../utils/serviceHelpers");
|
|
10
|
+
const getServiceName_1 = require("./getServiceName");
|
|
8
11
|
/**
|
|
9
12
|
* Get the OpenAPI services
|
|
10
13
|
*/
|
|
@@ -13,40 +16,26 @@ function getServices(openApi) {
|
|
|
13
16
|
for (const url in openApi.paths) {
|
|
14
17
|
if ((0, get_1.default)(openApi.paths, url, null)) {
|
|
15
18
|
// Grab path and parse any global path parameters
|
|
16
|
-
const
|
|
17
|
-
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 || '';
|
|
18
23
|
// Parse all the methods for this path
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const op = path[method];
|
|
31
|
-
const operation = this.getOperation(openApi, url, method, op, pathParams);
|
|
32
|
-
// If we have already declared a service, then we should fetch that and
|
|
33
|
-
// append the new method to it. Otherwise we should create a new service object.
|
|
34
|
-
const service = services.get(operation.service) || {
|
|
35
|
-
name: operation.service,
|
|
36
|
-
originName: operation.service,
|
|
37
|
-
operations: [],
|
|
38
|
-
imports: [],
|
|
39
|
-
};
|
|
40
|
-
// Push the operation in the service
|
|
41
|
-
service.operations.push(operation);
|
|
42
|
-
service.imports.push(...operation.imports);
|
|
43
|
-
services.set(operation.service, service);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
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, 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
|
+
});
|
|
49
35
|
}
|
|
50
36
|
}
|
|
37
|
+
services.forEach(service => {
|
|
38
|
+
(0, serviceHelpers_1.finalizeServiceImports)(service);
|
|
39
|
+
});
|
|
51
40
|
return Array.from(services.values());
|
|
52
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/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/v2/parser/getType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAoC5E"}
|
|
@@ -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,19 +20,25 @@ function getType(value, parentRef) {
|
|
|
22
20
|
imports: [],
|
|
23
21
|
path: '',
|
|
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;
|
|
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
|
+
const valueImportPath = !valuePath.startsWith('/') ? `./${valuePath}` : valuePath;
|
|
38
42
|
result.path = valuePath;
|
|
39
43
|
result.type = type;
|
|
40
44
|
result.base = type;
|
|
@@ -5,7 +5,7 @@ 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 swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
9
9
|
const Context_1 = require("../../../../Context");
|
|
10
10
|
const getOutputPaths_1 = require("../../../../utils/getOutputPaths");
|
|
11
11
|
const Parser_1 = require("../../Parser");
|
|
@@ -13,7 +13,7 @@ const Parser_1 = require("../../Parser");
|
|
|
13
13
|
(0, node_test_1.test)('@unit: should convert int', async () => {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
const parser = new
|
|
16
|
+
const parser = new swagger_parser_1.default();
|
|
17
17
|
const context = new Context_1.Context({ input: 'test/spec/v3.yml', output: (0, getOutputPaths_1.getOutputPaths)({ output: './generated' }) });
|
|
18
18
|
context.addRefs(await parser.resolve('test/spec/v3.yml'));
|
|
19
19
|
const type = new Parser_1.Parser(context).getType('int', '');
|
|
@@ -25,37 +25,19 @@ const Parser_1 = require("../../Parser");
|
|
|
25
25
|
(0, node_test_1.test)('@unit: should support file with ext', async () => {
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
27
|
// @ts-ignore
|
|
28
|
-
const parser = new
|
|
28
|
+
const parser = new swagger_parser_1.default();
|
|
29
29
|
const context = new Context_1.Context({ input: 'test/spec/v3.yml', output: (0, getOutputPaths_1.getOutputPaths)({ output: './generated' }) });
|
|
30
30
|
context.addRefs(await parser.resolve('test/spec/v3.yml'));
|
|
31
31
|
const type = new Parser_1.Parser(context).getType('schemas/ModelWithString.yml', '');
|
|
32
|
-
node_assert_1.default.strictEqual(type.type, '
|
|
33
|
-
node_assert_1.default.strictEqual(type.base, '
|
|
32
|
+
node_assert_1.default.strictEqual(type.type, 'ModelWithString');
|
|
33
|
+
node_assert_1.default.strictEqual(type.base, 'ModelWithString');
|
|
34
34
|
node_assert_1.default.strictEqual(type.template, null);
|
|
35
35
|
node_assert_1.default.deepStrictEqual(type.imports, [
|
|
36
36
|
{
|
|
37
|
-
name: '
|
|
37
|
+
name: 'ModelWithString',
|
|
38
38
|
alias: '',
|
|
39
39
|
path: './schemas/ModelWithString',
|
|
40
40
|
},
|
|
41
41
|
]);
|
|
42
42
|
});
|
|
43
|
-
const object = {
|
|
44
|
-
components: {
|
|
45
|
-
schemas: {
|
|
46
|
-
someSpecialSchema: {
|
|
47
|
-
type: 'object',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
(0, node_test_1.test)('@unit: should support external generation type', async () => {
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
const parser = new json_schema_ref_parser_1.default();
|
|
56
|
-
const context = new Context_1.Context({ input: object, output: (0, getOutputPaths_1.getOutputPaths)({ output: './generated' }) });
|
|
57
|
-
context.addRefs(await parser.resolve(object));
|
|
58
|
-
const type = new Parser_1.Parser(context).getType('#/components/schemas/someSpecialSchema', '');
|
|
59
|
-
node_assert_1.default.strictEqual(type.type, 'ISomeSpecialSchema');
|
|
60
|
-
});
|
|
61
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModel.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModel.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAO/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGzD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,KAAK,CAkLjE"}
|
|
@@ -6,6 +6,7 @@ const getComment_1 = require("../../../utils/getComment");
|
|
|
6
6
|
const getEnum_1 = require("../../../utils/getEnum");
|
|
7
7
|
const getEnumFromDescription_1 = require("../../../utils/getEnumFromDescription");
|
|
8
8
|
const getPattern_1 = require("../../../utils/getPattern");
|
|
9
|
+
const normalizeRef_1 = require("../../../utils/normalizeRef");
|
|
9
10
|
const getModelDefault_1 = require("./getModelDefault");
|
|
10
11
|
function getModel(config) {
|
|
11
12
|
const { openApi, definition, isDefinition = false, name = '', path = '', parentRef } = config;
|
|
@@ -43,7 +44,8 @@ function getModel(config) {
|
|
|
43
44
|
properties: [],
|
|
44
45
|
};
|
|
45
46
|
if (definition.$ref) {
|
|
46
|
-
const
|
|
47
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(definition.$ref, parentRef);
|
|
48
|
+
const definitionRef = this.getType(definition.$ref, normalizedRef);
|
|
47
49
|
model.export = 'reference';
|
|
48
50
|
model.type = definitionRef.type;
|
|
49
51
|
model.base = definitionRef.base;
|
|
@@ -76,7 +78,8 @@ function getModel(config) {
|
|
|
76
78
|
}
|
|
77
79
|
if (definition.type === 'array' && definition.items) {
|
|
78
80
|
if (definition.items.$ref) {
|
|
79
|
-
const
|
|
81
|
+
const normalizedRef = (0, normalizeRef_1.normalizeRef)(definition.items.$ref, parentRef);
|
|
82
|
+
const arrayItems = this.getType(definition.items.$ref, normalizedRef);
|
|
80
83
|
model.export = 'array';
|
|
81
84
|
model.type = arrayItems.type;
|
|
82
85
|
model.base = arrayItems.base;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModelProperties.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModelProperties.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModelProperties.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/parser/getModelProperties.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,EAAE,CAkFxH"}
|