ts-openapi-codegen 2.0.0-beta.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -18
- package/README.rus.md +88 -21
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +2 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +14 -6
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +2 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +13 -5
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +5 -0
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +24 -13
- package/dist/cli/index.js +10 -8
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +5 -13
- package/dist/cli/initOpenApiConfig/initConfig.js +3 -3
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/previewChanges.js +119 -28
- package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.js +6 -0
- package/dist/cli/schemas/base.d.ts +6 -1
- package/dist/cli/schemas/base.d.ts.map +1 -1
- package/dist/cli/schemas/base.js +10 -6
- package/dist/cli/schemas/checkConfig.d.ts +1 -1
- package/dist/cli/schemas/generate.d.ts +1 -25
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +21 -32
- package/dist/cli/schemas/index.d.ts +2 -1
- package/dist/cli/schemas/index.d.ts.map +1 -1
- package/dist/cli/schemas/index.js +1 -0
- package/dist/cli/schemas/init.d.ts +5 -5
- package/dist/cli/schemas/init.d.ts.map +1 -1
- package/dist/cli/schemas/init.js +4 -5
- package/dist/cli/schemas/previewChanges.d.ts +9 -0
- package/dist/cli/schemas/previewChanges.d.ts.map +1 -0
- package/dist/cli/schemas/previewChanges.js +11 -0
- package/dist/cli/schemas/updateConfig.d.ts +1 -1
- package/dist/common/Consts.d.ts +2 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +8 -2
- package/dist/common/LoggerMessages.d.ts +1 -0
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +2 -1
- package/dist/common/TRawOptions.d.ts +1 -1
- package/dist/common/TRawOptions.d.ts.map +1 -1
- package/dist/common/Validation/formatZodError.d.ts +10 -0
- package/dist/common/Validation/formatZodError.d.ts.map +1 -0
- package/dist/{cli/validation/errorFormatter.js → common/Validation/formatZodError.js} +14 -13
- package/dist/common/Validation/index.d.ts +3 -0
- package/dist/common/Validation/index.d.ts.map +1 -0
- package/dist/{cli/validation → common/Validation}/index.js +2 -2
- package/dist/{cli/validation/validateCLIOptions.d.ts → common/Validation/validateZodOptions.d.ts} +4 -4
- package/dist/common/Validation/validateZodOptions.d.ts.map +1 -0
- package/dist/{cli/validation/validateCLIOptions.js → common/Validation/validateZodOptions.js} +7 -10
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +14 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +6 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +8 -14
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +28 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.js +25 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +36 -6
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +33 -37
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +37 -6
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +30 -37
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +40 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.js +36 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +42 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +38 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +192 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +27 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +61 -30
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +56 -73
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +25 -5
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.js +34 -17
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +25 -5
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.js +28 -19
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +25 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.js +29 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +25 -5
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.js +30 -14
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +23 -5
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.js +33 -18
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts +3 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.js +18 -11
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +22 -5
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.js +30 -12
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +22 -5
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.js +27 -13
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +22 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.js +28 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +22 -5
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.js +31 -12
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts +3 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.js +15 -9
- package/dist/common/VersionedSchema/Types.d.ts +5 -5
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts +16 -0
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +104 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +185 -0
- package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.js +40 -0
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +93 -0
- package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts +12 -0
- package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/buildVersionedSchema.js +13 -0
- package/dist/common/VersionedSchema/Utils/compareShapes.d.ts +16 -0
- package/dist/common/VersionedSchema/Utils/compareShapes.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/compareShapes.js +30 -0
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +6 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +70 -25
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +2 -2
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +15 -7
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts +3 -3
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.js +17 -4
- package/dist/common/VersionedSchema/Utils/getUniqueObjectKeys.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/getUniqueObjectKeys.js +19 -2
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +12 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +41 -22
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts +4 -0
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts.map +1 -0
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.js +43 -0
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts +4 -0
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts.map +1 -0
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.js +21 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.js +64 -169
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +51 -14
- package/dist/core/Context.d.ts +6 -5
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +69 -26
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +24 -9
- package/dist/core/WriteClient.d.ts +8 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +48 -7
- package/dist/core/__tests__/WriteClient.test.js +2 -0
- package/dist/core/api/v2/Parser.d.ts +1 -1
- package/dist/core/api/v2/Parser.d.ts.map +1 -1
- package/dist/core/api/v2/Parser.js +2 -2
- package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModel.js +2 -5
- package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModelProperties.js +1 -3
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +1 -2
- package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.js +2 -5
- package/dist/core/api/v2/parser/getOperationParameters.js +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.js +1 -3
- package/dist/core/api/v2/parser/getOperationResponses.js +1 -1
- package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getServices.js +4 -3
- package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getType.js +4 -3
- package/dist/core/api/v3/Parser.d.ts +1 -1
- package/dist/core/api/v3/Parser.d.ts.map +1 -1
- package/dist/core/api/v3/Parser.js +2 -2
- package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModel.js +2 -5
- package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModelProperties.js +1 -3
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +1 -2
- package/dist/core/api/v3/parser/getOperation.js +1 -1
- package/dist/core/api/v3/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameter.js +2 -5
- package/dist/core/api/v3/parser/getOperationParameters.js +1 -1
- package/dist/core/api/v3/parser/getOperationRequestBody.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationRequestBody.js +1 -3
- package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponse.js +1 -3
- package/dist/core/api/v3/parser/getOperationResponses.js +1 -1
- package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServices.js +4 -3
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +4 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/types/base/Templates.model.d.ts +1 -1
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts +6 -0
- package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts.map +1 -0
- package/dist/core/types/enums/EmptySchemaStrategy.enum.js +9 -0
- package/dist/core/utils/__tests__/getRelativeModelPath.test.js +9 -3
- package/dist/core/utils/__tests__/isSubdirectory.test.js +2 -2
- package/dist/core/utils/__tests__/modelHelpers.test.d.ts +2 -0
- package/dist/core/utils/__tests__/modelHelpers.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/modelHelpers.test.js +151 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts +2 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.js +67 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts +2 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.js +26 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.js +22 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.d.ts +2 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +121 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.js +20 -0
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +14 -1
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +37 -3
- package/dist/core/utils/postProcessModelImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessModelImports.js +14 -1
- package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessServiceImports.js +1 -2
- package/dist/core/utils/precompileTemplates.js +1 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +25 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +42 -41
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefPath.js +1 -4
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +32 -6
- package/dist/core/utils/validateRawOptions.d.ts +3 -0
- package/dist/core/utils/validateRawOptions.d.ts.map +1 -0
- package/dist/core/utils/validateRawOptions.js +15 -0
- package/dist/core/utils/writeClientExecutor.d.ts +4 -1
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +17 -2
- package/dist/core/utils/writeClientSchemas.d.ts +4 -1
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +11 -2
- package/dist/templatesCompiled/client/core/ApiError.js +1 -1
- package/dist/templatesCompiled/client/core/ApiResult.js +1 -1
- package/dist/templatesCompiled/client/core/axios/request.js +3 -3
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +2 -0
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +13 -8
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/request.js +3 -3
- package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
- package/dist/templatesCompiled/client/core/node/request.js +3 -3
- package/dist/templatesCompiled/client/core/xhr/request.js +3 -3
- package/dist/templatesCompiled/client/exportClient.d.ts +4 -0
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportClient.js +51 -13
- package/dist/templatesCompiled/client/exportSchema.d.ts +5 -1
- package/dist/templatesCompiled/client/exportSchema.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportSchema.js +37 -7
- package/dist/templatesCompiled/client/exportService.d.ts +2 -0
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +71 -31
- package/dist/templatesCompiled/client/indexFull.d.ts +1 -0
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +4 -1
- package/dist/templatesCompiled/client/indexSimple.d.ts +1 -0
- package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexSimple.js +4 -1
- package/dist/templatesCompiled/client/joi/exportSchema.js +5 -5
- package/dist/templatesCompiled/client/joi/partials/joiSchema.js +7 -7
- package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +4 -4
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +5 -3
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +39 -12
- package/dist/templatesCompiled/client/jsonschema/exportSchema.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +7 -7
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +2 -2
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +3 -1
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +45 -15
- package/dist/templatesCompiled/client/partials/exportComposition.d.ts +2 -0
- package/dist/templatesCompiled/client/partials/exportComposition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/exportComposition.js +17 -9
- package/dist/templatesCompiled/client/yup/exportSchema.js +3 -3
- package/dist/templatesCompiled/client/yup/partials/yupSchema.js +7 -7
- package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +4 -4
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +5 -3
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +39 -12
- package/dist/templatesCompiled/client/zod/exportSchema.js +3 -3
- package/dist/templatesCompiled/client/zod/partials/zodSchema.js +7 -7
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +5 -6
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +14 -28
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +3 -0
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +32 -8
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +3 -4
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +9 -23
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +4 -2
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +18 -7
- package/package.json +2 -2
- package/dist/cli/validation/errorFormatter.d.ts +0 -6
- package/dist/cli/validation/errorFormatter.d.ts.map +0 -1
- package/dist/cli/validation/index.d.ts +0 -3
- package/dist/cli/validation/index.d.ts.map +0 -1
- package/dist/cli/validation/validateCLIOptions.d.ts.map +0 -1
- package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.d.ts +0 -6
- package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.d.ts.map +0 -1
- package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.js +0 -7
- package/dist/common/VersionedSchema/Utils/joiHandlers.d.ts +0 -6
- package/dist/common/VersionedSchema/Utils/joiHandlers.d.ts.map +0 -1
- package/dist/common/VersionedSchema/Utils/joiHandlers.js +0 -59
- package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.d.ts +0 -3
- package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.d.ts.map +0 -1
- package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.js +0 -12
- package/dist/common/VersionedSchema/Utils/traverseObjectStructure.d.ts +0 -3
- package/dist/common/VersionedSchema/Utils/traverseObjectStructure.d.ts.map +0 -1
- package/dist/common/VersionedSchema/Utils/traverseObjectStructure.js +0 -31
- package/dist/common/defaultOptions.d.ts +0 -3
- package/dist/common/defaultOptions.d.ts.map +0 -1
- package/dist/common/defaultOptions.js +0 -28
- package/dist/common/schemas/configSchemas.d.ts +0 -91
- package/dist/common/schemas/configSchemas.d.ts.map +0 -1
- package/dist/common/schemas/configSchemas.js +0 -131
- package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts +0 -19
- package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
- package/dist/common/utils/__tests__/__mock__/mockJoiSchema.js +0 -14
- package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts +0 -2
- package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
- package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.js +0 -38
- package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts +0 -2
- package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
- package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.js +0 -20
- package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts +0 -2
- package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
- package/dist/common/utils/__tests__/mergeObjectSchemas.test.js +0 -35
- package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts +0 -2
- package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
- package/dist/common/utils/__tests__/migrationForMultiOptions.test.js +0 -112
- package/dist/common/utils/__tests__/migrationForOptions.test.d.ts +0 -2
- package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +0 -1
- package/dist/common/utils/__tests__/migrationForOptions.test.js +0 -56
- package/dist/core/utils/advancedDeduplicatePath.d.ts +0 -5
- package/dist/core/utils/advancedDeduplicatePath.d.ts.map +0 -1
- package/dist/core/utils/advancedDeduplicatePath.js +0 -29
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ npm install ts-openapi-codegen --save-dev
|
|
|
38
38
|
|
|
39
39
|
## Usage
|
|
40
40
|
|
|
41
|
-
The CLI tool supports
|
|
41
|
+
The CLI tool supports five commands: `generate`, `check-config`, `update-config`, `init`, and `preview-changes`.
|
|
42
42
|
|
|
43
43
|
### Command: `generate`
|
|
44
44
|
|
|
@@ -65,6 +65,7 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
65
65
|
| `--useUnionTypes` | - | boolean | `false` | Use union types instead of enums |
|
|
66
66
|
| `--excludeCoreServiceFiles` | - | boolean | `false` | Exclude generation of core and service files |
|
|
67
67
|
| `--request` | - | string | - | Path to custom request file |
|
|
68
|
+
| `--customExecutorPath` | - | string | - | Path to custom `createExecutorAdapter` module |
|
|
68
69
|
| `--interfacePrefix` | - | string | `I` | Prefix for interface models |
|
|
69
70
|
| `--enumPrefix` | - | string | `E` | Prefix for enum models |
|
|
70
71
|
| `--typePrefix` | - | string | `T` | Prefix for type models |
|
|
@@ -74,6 +75,7 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
74
75
|
| `--logLevel` | `-l` | string | `error` | Logging level: `info`, `warn`, or `error` |
|
|
75
76
|
| `--logTarget` | `-t` | string | `console` | Logging target: `console` or `file` |
|
|
76
77
|
| `--validationLibrary` | - | string | `none` | Validation library for schema generation: `none`, `zod`, `joi`, `yup`, or `jsonschema` |
|
|
78
|
+
| `--emptySchemaStrategy` | - | string | `keep` | Strategy for empty schemas: `keep`, `semantic`, or `skip` |
|
|
77
79
|
|
|
78
80
|
**Examples:**
|
|
79
81
|
```bash
|
|
@@ -96,38 +98,70 @@ openapi generate \
|
|
|
96
98
|
--logLevel info
|
|
97
99
|
```
|
|
98
100
|
|
|
99
|
-
### Command: `check-
|
|
101
|
+
### Command: `check-config`
|
|
100
102
|
|
|
101
103
|
Validates the configuration file structure and values.
|
|
102
104
|
|
|
103
105
|
**Usage:**
|
|
104
106
|
```bash
|
|
105
|
-
openapi check-
|
|
106
|
-
openapi check-
|
|
107
|
+
openapi check-config
|
|
108
|
+
openapi check-config --openapi-config ./custom-config.json
|
|
107
109
|
```
|
|
108
110
|
|
|
109
111
|
**Options:**
|
|
110
112
|
- `--openapi-config` / `-ocn` - Path to configuration file (default: `openapi.config.json`)
|
|
111
113
|
|
|
112
|
-
### Command: `
|
|
114
|
+
### Command: `update-config`
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
Updates the configuration file to the latest supported schema version.
|
|
115
117
|
|
|
116
118
|
**Usage:**
|
|
117
119
|
```bash
|
|
118
|
-
|
|
119
|
-
openapi
|
|
120
|
+
openapi update-config
|
|
121
|
+
openapi update-config --openapi-config ./custom-config.json
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Options:**
|
|
125
|
+
- `--openapi-config` / `-ocn` - Path to configuration file (default: `openapi.config.json`)
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
### Command: `init`
|
|
128
|
+
|
|
129
|
+
Generates a configuration file template.
|
|
130
|
+
|
|
131
|
+
**Usage:**
|
|
132
|
+
```bash
|
|
133
|
+
# Generate config using default settings
|
|
134
|
+
openapi init
|
|
123
135
|
|
|
124
136
|
# Custom config file name
|
|
125
|
-
openapi init
|
|
137
|
+
openapi init --openapi-config ./my-config.json
|
|
138
|
+
|
|
139
|
+
# Specify directory with OpenAPI specs
|
|
140
|
+
openapi init --specs-dir ./openapi
|
|
126
141
|
```
|
|
127
142
|
|
|
128
143
|
**Options:**
|
|
129
144
|
- `--openapi-config` / `-ocn` - Path to output configuration file (default: `openapi.config.json`)
|
|
130
|
-
- `--
|
|
145
|
+
- `--specs-dir` / `-sd` - Directory with OpenAPI specification files (default: `./openapi`)
|
|
146
|
+
- `--request` - Path to custom request file
|
|
147
|
+
- `--useCancelableRequest` - Generate cancelable request handling
|
|
148
|
+
- `--useInteractiveMode` - Enable interactive mode for guided setup
|
|
149
|
+
|
|
150
|
+
### Command: `preview-changes`
|
|
151
|
+
|
|
152
|
+
Previews differences between already generated code and newly generated output without overwriting your current generated directory.
|
|
153
|
+
|
|
154
|
+
**Usage:**
|
|
155
|
+
```bash
|
|
156
|
+
openapi preview-changes
|
|
157
|
+
openapi preview-changes --openapi-config ./custom-config.json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Options:**
|
|
161
|
+
- `--openapi-config` / `-ocn` - Path to configuration file (default: `openapi.config.json`)
|
|
162
|
+
- `--generated-dir` / `-gd` - Directory with current generated files (default: `./generated`)
|
|
163
|
+
- `--preview-dir` / `-pd` - Temporary preview generation directory (default: `./.ts-openapi-codegen-preview-changes`)
|
|
164
|
+
- `--diff-dir` / `-dd` - Directory for diff reports (default: `./.ts-openapi-codegen-diff-changes`)
|
|
131
165
|
|
|
132
166
|
### Configuration File
|
|
133
167
|
|
|
@@ -148,7 +182,8 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
148
182
|
"useCancelableRequest": false,
|
|
149
183
|
"sortByRequired": false,
|
|
150
184
|
"useSeparatedIndexes": false,
|
|
151
|
-
"request": "./custom-request.ts"
|
|
185
|
+
"request": "./custom-request.ts",
|
|
186
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
152
187
|
}
|
|
153
188
|
```
|
|
154
189
|
|
|
@@ -199,6 +234,7 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
199
234
|
| `useUnionTypes` | boolean | `false` | Use union types instead of enums |
|
|
200
235
|
| `excludeCoreServiceFiles` | boolean | `false` | Exclude core and service files generation |
|
|
201
236
|
| `request` | string | - | Path to custom request file |
|
|
237
|
+
| `customExecutorPath` | string | - | Path to custom `createExecutorAdapter` module |
|
|
202
238
|
| `interfacePrefix` | string | `I` | Prefix for interface models |
|
|
203
239
|
| `enumPrefix` | string | `E` | Prefix for enum models |
|
|
204
240
|
| `typePrefix` | string | `T` | Prefix for type models |
|
|
@@ -207,8 +243,9 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
207
243
|
| `useSeparatedIndexes` | boolean | `false` | Use separate index files |
|
|
208
244
|
| `items` | array | - | Array of configurations (for multi-options format) |
|
|
209
245
|
| `validationLibrary` | string | `none` | Validation library for schema generation: `none`, `zod`, `joi`, `yup`, or `jsonschema` |
|
|
246
|
+
| `emptySchemaStrategy` | string | `keep` | Strategy for empty schemas: `keep`, `semantic`, or `skip` |
|
|
210
247
|
|
|
211
|
-
**Note:** You can use the `init
|
|
248
|
+
**Note:** You can use the `init` command to generate a template configuration file.
|
|
212
249
|
|
|
213
250
|
## Examples
|
|
214
251
|
|
|
@@ -222,7 +259,7 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
222
259
|
**With configuration file:**
|
|
223
260
|
```bash
|
|
224
261
|
# First, create config file
|
|
225
|
-
openapi init
|
|
262
|
+
openapi init
|
|
226
263
|
|
|
227
264
|
# Then generate
|
|
228
265
|
openapi generate
|
|
@@ -230,7 +267,13 @@ openapi generate
|
|
|
230
267
|
|
|
231
268
|
**Check configuration:**
|
|
232
269
|
```bash
|
|
233
|
-
openapi check-
|
|
270
|
+
openapi check-config
|
|
271
|
+
openapi update-config
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Preview changes before applying:**
|
|
275
|
+
```bash
|
|
276
|
+
openapi preview-changes
|
|
234
277
|
```
|
|
235
278
|
|
|
236
279
|
### Using NPX
|
|
@@ -247,8 +290,10 @@ npx ts-openapi-codegen generate --input ./spec.json --output ./dist
|
|
|
247
290
|
"scripts": {
|
|
248
291
|
"generate": "openapi generate --input ./spec.json --output ./dist",
|
|
249
292
|
"generate:config": "openapi generate",
|
|
250
|
-
"check-config": "openapi check-
|
|
251
|
-
"
|
|
293
|
+
"check-config": "openapi check-config",
|
|
294
|
+
"update-config": "openapi update-config",
|
|
295
|
+
"init-config": "openapi init",
|
|
296
|
+
"preview-changes": "openapi preview-changes"
|
|
252
297
|
}
|
|
253
298
|
}
|
|
254
299
|
```
|
|
@@ -630,6 +675,31 @@ const service = new SimpleService(executor);
|
|
|
630
675
|
await service.getCallWithoutParametersAndResponse({ timeout: 5000 });
|
|
631
676
|
```
|
|
632
677
|
|
|
678
|
+
#### Using generated `createClient` with `customExecutorPath` and `executorFactory`
|
|
679
|
+
|
|
680
|
+
If you set `customExecutorPath` in generation config, `createClient.ts` imports your custom
|
|
681
|
+
`createExecutorAdapter` and uses it as the default executor.
|
|
682
|
+
|
|
683
|
+
You can additionally pass `executorFactory` at runtime to wrap/extend this default executor
|
|
684
|
+
(for retry, tracing, metrics, etc.) without changing generated services.
|
|
685
|
+
|
|
686
|
+
```ts
|
|
687
|
+
import { createClient } from './generated';
|
|
688
|
+
|
|
689
|
+
const client = createClient({
|
|
690
|
+
executorFactory: ({ openApiConfig, createDefaultExecutor }) => {
|
|
691
|
+
const baseExecutor = createDefaultExecutor();
|
|
692
|
+
|
|
693
|
+
return {
|
|
694
|
+
async request<TResponse>(config, options) {
|
|
695
|
+
console.debug('Request to', openApiConfig.BASE, config.path);
|
|
696
|
+
return baseExecutor.request<TResponse>(config, options);
|
|
697
|
+
},
|
|
698
|
+
};
|
|
699
|
+
},
|
|
700
|
+
});
|
|
701
|
+
```
|
|
702
|
+
|
|
633
703
|
### Sorting strategy for function arguments `--sortByRequired`
|
|
634
704
|
By default, the OpenAPI generator sorts the parameters of service functions according to a simplified scheme. If you need a more strict sorting option, then you need to use the `--sortByRequired` flag. The simplified sorting option is similar to the one used in version 0.2.3 of the OpenAPI generator. This flag allows you to upgrade to a new version of the generator if you are "stuck" on version 0.2.3.
|
|
635
705
|
|
package/README.rus.md
CHANGED
|
@@ -37,7 +37,7 @@ npm install ts-openapi-codegen --save-dev
|
|
|
37
37
|
|
|
38
38
|
## Использование
|
|
39
39
|
|
|
40
|
-
CLI инструмент поддерживает
|
|
40
|
+
CLI инструмент поддерживает пять команд: `generate`, `check-config`, `update-config`, `init` и `preview-changes`.
|
|
41
41
|
|
|
42
42
|
### Команда: `generate`
|
|
43
43
|
|
|
@@ -64,6 +64,7 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
64
64
|
| `--useUnionTypes` | - | boolean | `false` | Использовать union типы вместо enums |
|
|
65
65
|
| `--excludeCoreServiceFiles` | - | boolean | `false` | Исключить генерацию core и сервисных файлов |
|
|
66
66
|
| `--request` | - | string | - | Путь к пользовательскому файлу запросов |
|
|
67
|
+
| `--customExecutorPath` | - | string | - | Путь к пользовательскому модулю `createExecutorAdapter` |
|
|
67
68
|
| `--interfacePrefix` | - | string | `I` | Префикс для интерфейсов моделей |
|
|
68
69
|
| `--enumPrefix` | - | string | `E` | Префикс для enum моделей |
|
|
69
70
|
| `--typePrefix` | - | string | `T` | Префикс для type моделей |
|
|
@@ -73,6 +74,7 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
73
74
|
| `--logLevel` | `-l` | string | `error` | Уровень логирования: `info`, `warn`, или `error` |
|
|
74
75
|
| `--logTarget` | `-t` | string | `console` | Цель логирования: `console` или `file` |
|
|
75
76
|
| `--validationLibrary` | - | string | `none` | Библиотека валидации для генерации схем: `none`, `zod`, `joi`, `yup`, или `jsonschema` |
|
|
77
|
+
| `--emptySchemaStrategy` | - | string | `keep` | Стратегия для пустых схем: `keep`, `semantic`, или `skip` |
|
|
76
78
|
|
|
77
79
|
**Примеры:**
|
|
78
80
|
```bash
|
|
@@ -95,38 +97,70 @@ openapi generate \
|
|
|
95
97
|
--logLevel info
|
|
96
98
|
```
|
|
97
99
|
|
|
98
|
-
### Команда: `check-
|
|
100
|
+
### Команда: `check-config`
|
|
99
101
|
|
|
100
102
|
Проверяет структуру и значения файла конфигурации.
|
|
101
103
|
|
|
102
104
|
**Использование:**
|
|
103
105
|
```bash
|
|
104
|
-
openapi check-
|
|
105
|
-
openapi check-
|
|
106
|
+
openapi check-config
|
|
107
|
+
openapi check-config --openapi-config ./custom-config.json
|
|
106
108
|
```
|
|
107
109
|
|
|
108
110
|
**Опции:**
|
|
109
111
|
- `--openapi-config` / `-ocn` - Путь к файлу конфигурации (по умолчанию: `openapi.config.json`)
|
|
110
112
|
|
|
111
|
-
### Команда: `
|
|
113
|
+
### Команда: `update-config`
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
Обновляет файл конфигурации до последней поддерживаемой версии схемы.
|
|
114
116
|
|
|
115
117
|
**Использование:**
|
|
116
118
|
```bash
|
|
117
|
-
|
|
118
|
-
openapi
|
|
119
|
+
openapi update-config
|
|
120
|
+
openapi update-config --openapi-config ./custom-config.json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Опции:**
|
|
124
|
+
- `--openapi-config` / `-ocn` - Путь к файлу конфигурации (по умолчанию: `openapi.config.json`)
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
### Команда: `init`
|
|
127
|
+
|
|
128
|
+
Генерирует шаблон файла конфигурации.
|
|
129
|
+
|
|
130
|
+
**Использование:**
|
|
131
|
+
```bash
|
|
132
|
+
# Генерация шаблона с настройками по умолчанию
|
|
133
|
+
openapi init
|
|
122
134
|
|
|
123
135
|
# Пользовательское имя файла конфигурации
|
|
124
|
-
openapi init
|
|
136
|
+
openapi init --openapi-config ./my-config.json
|
|
137
|
+
|
|
138
|
+
# Явно указать директорию со спецификациями OpenAPI
|
|
139
|
+
openapi init --specs-dir ./openapi
|
|
125
140
|
```
|
|
126
141
|
|
|
127
142
|
**Опции:**
|
|
128
143
|
- `--openapi-config` / `-ocn` - Путь к выходному файлу конфигурации (по умолчанию: `openapi.config.json`)
|
|
129
|
-
- `--
|
|
144
|
+
- `--specs-dir` / `-sd` - Директория с файлами OpenAPI спецификаций (по умолчанию: `./openapi`)
|
|
145
|
+
- `--request` - Путь к пользовательскому request-файлу
|
|
146
|
+
- `--useCancelableRequest` - Включить генерацию cancelable request
|
|
147
|
+
- `--useInteractiveMode` - Включить интерактивный режим настройки
|
|
148
|
+
|
|
149
|
+
### Команда: `preview-changes`
|
|
150
|
+
|
|
151
|
+
Показывает различия между уже сгенерированным кодом и новым результатом генерации без перезаписи текущей директории generated-кода.
|
|
152
|
+
|
|
153
|
+
**Использование:**
|
|
154
|
+
```bash
|
|
155
|
+
openapi preview-changes
|
|
156
|
+
openapi preview-changes --openapi-config ./custom-config.json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Опции:**
|
|
160
|
+
- `--openapi-config` / `-ocn` - Путь к файлу конфигурации (по умолчанию: `openapi.config.json`)
|
|
161
|
+
- `--generated-dir` / `-gd` - Директория с текущим generated-кодом (по умолчанию: `./generated`)
|
|
162
|
+
- `--preview-dir` / `-pd` - Временная директория для preview-генерации (по умолчанию: `./.ts-openapi-codegen-preview-changes`)
|
|
163
|
+
- `--diff-dir` / `-dd` - Директория для diff-отчетов (по умолчанию: `./.ts-openapi-codegen-diff-changes`)
|
|
130
164
|
|
|
131
165
|
### Файл конфигурации
|
|
132
166
|
|
|
@@ -147,7 +181,8 @@ openapi init-openapi-config --openapi-config ./my-config.json
|
|
|
147
181
|
"useCancelableRequest": false,
|
|
148
182
|
"sortByRequired": false,
|
|
149
183
|
"useSeparatedIndexes": false,
|
|
150
|
-
"request": "./custom-request.ts"
|
|
184
|
+
"request": "./custom-request.ts",
|
|
185
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
151
186
|
}
|
|
152
187
|
```
|
|
153
188
|
|
|
@@ -198,6 +233,7 @@ openapi init-openapi-config --openapi-config ./my-config.json
|
|
|
198
233
|
| `useUnionTypes` | boolean | `false` | Использовать union типы вместо enums |
|
|
199
234
|
| `excludeCoreServiceFiles` | boolean | `false` | Исключить генерацию core и сервисных файлов |
|
|
200
235
|
| `request` | string | - | Путь к пользовательскому файлу запросов |
|
|
236
|
+
| `customExecutorPath` | string | - | Путь к пользовательскому модулю `createExecutorAdapter` |
|
|
201
237
|
| `interfacePrefix` | string | `I` | Префикс для интерфейсов моделей |
|
|
202
238
|
| `enumPrefix` | string | `E` | Префикс для enum моделей |
|
|
203
239
|
| `typePrefix` | string | `T` | Префикс для type моделей |
|
|
@@ -206,8 +242,9 @@ openapi init-openapi-config --openapi-config ./my-config.json
|
|
|
206
242
|
| `useSeparatedIndexes` | boolean | `false` | Использовать отдельные index файлы |
|
|
207
243
|
| `items` | array | - | Массив конфигураций (для формата multi-options) |
|
|
208
244
|
| `validationLibrary` | string | `none` | Библиотека валидации для генерации схем: `none`, `zod`, `joi`, `yup`, или `jsonschema` |
|
|
245
|
+
| `emptySchemaStrategy` | string | `keep` | Стратегия для пустых схем: `keep`, `semantic`, или `skip` |
|
|
209
246
|
|
|
210
|
-
**Примечание:** Вы можете использовать команду `init
|
|
247
|
+
**Примечание:** Вы можете использовать команду `init` для генерации шаблона файла конфигурации.
|
|
211
248
|
|
|
212
249
|
## Примеры
|
|
213
250
|
|
|
@@ -221,7 +258,7 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
221
258
|
**С файлом конфигурации:**
|
|
222
259
|
```bash
|
|
223
260
|
# Сначала создайте файл конфигурации
|
|
224
|
-
openapi init
|
|
261
|
+
openapi init
|
|
225
262
|
|
|
226
263
|
# Затем выполните генерацию
|
|
227
264
|
openapi generate
|
|
@@ -229,7 +266,13 @@ openapi generate
|
|
|
229
266
|
|
|
230
267
|
**Проверка конфигурации:**
|
|
231
268
|
```bash
|
|
232
|
-
openapi check-
|
|
269
|
+
openapi check-config
|
|
270
|
+
openapi update-config
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Предпросмотр изменений перед применением:**
|
|
274
|
+
```bash
|
|
275
|
+
openapi preview-changes
|
|
233
276
|
```
|
|
234
277
|
|
|
235
278
|
### Использование NPX
|
|
@@ -246,8 +289,10 @@ npx ts-openapi-codegen generate --input ./spec.json --output ./dist
|
|
|
246
289
|
"scripts": {
|
|
247
290
|
"generate": "openapi generate --input ./spec.json --output ./dist",
|
|
248
291
|
"generate:config": "openapi generate",
|
|
249
|
-
"check-config": "openapi check-
|
|
250
|
-
"
|
|
292
|
+
"check-config": "openapi check-config",
|
|
293
|
+
"update-config": "openapi update-config",
|
|
294
|
+
"init-config": "openapi init",
|
|
295
|
+
"preview-changes": "openapi preview-changes"
|
|
251
296
|
}
|
|
252
297
|
}
|
|
253
298
|
```
|
|
@@ -630,6 +675,31 @@ const service = new SimpleService(executor);
|
|
|
630
675
|
await service.getCallWithoutParametersAndResponse({ timeout: 5000 });
|
|
631
676
|
```
|
|
632
677
|
|
|
678
|
+
#### Использование сгенерированного `createClient` с `customExecutorPath` и `executorFactory`
|
|
679
|
+
|
|
680
|
+
Если в конфигурации генерации задан `customExecutorPath`, в `createClient.ts` будет импортирован ваш
|
|
681
|
+
пользовательский `createExecutorAdapter`, и он станет базовым executor по умолчанию.
|
|
682
|
+
|
|
683
|
+
Дополнительно в runtime можно передать `executorFactory`, чтобы обернуть/расширить этот базовый executor
|
|
684
|
+
(retry, tracing, metrics и т.д.) без изменения сгенерированных сервисов.
|
|
685
|
+
|
|
686
|
+
```ts
|
|
687
|
+
import { createClient } from './generated';
|
|
688
|
+
|
|
689
|
+
const client = createClient({
|
|
690
|
+
executorFactory: ({ openApiConfig, createDefaultExecutor }) => {
|
|
691
|
+
const baseExecutor = createDefaultExecutor();
|
|
692
|
+
|
|
693
|
+
return {
|
|
694
|
+
async request<TResponse>(config, options) {
|
|
695
|
+
console.debug('Request to', openApiConfig.BASE, config.path);
|
|
696
|
+
return baseExecutor.request<TResponse>(config, options);
|
|
697
|
+
},
|
|
698
|
+
};
|
|
699
|
+
},
|
|
700
|
+
});
|
|
701
|
+
```
|
|
702
|
+
|
|
633
703
|
### Стратегия сортировки аргументов функций `--sortByRequired`
|
|
634
704
|
По умолчанию генератор OpenAPI сортирует параметры сервисных функций согласно упрощенной схеме. Если вам нужна более строгая опция сортировки, используйте флаг `--sortByRequired`. Упрощенная опция сортировки похожа на ту, что использовалась в версии 0.2.3 генератора OpenAPI. Этот флаг позволяет обновиться до новой версии генератора, если вы "застряли" на версии 0.2.3.
|
|
635
705
|
|
|
@@ -841,6 +911,3 @@ npm install form-data --save-dev
|
|
|
841
911
|
[stars-image]: https://img.shields.io/github/stars/ozonophore/openapi-codegen.svg
|
|
842
912
|
[librariesio-image]: https://img.shields.io/librariesio/github/ozonophore/openapi-codegen
|
|
843
913
|
[lines-image]: https://img.shields.io/tokei/lines/github/ozonophore/openapi-codegen
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionValues } from 'commander';
|
|
1
2
|
/**
|
|
2
3
|
* Проверяет конфигурационный файл на корректность и актуальность.
|
|
3
4
|
* Если обнаружены проблемы, предлагает действия для их исправления.
|
|
@@ -8,5 +9,5 @@
|
|
|
8
9
|
* @example
|
|
9
10
|
* await checkConfig('./openapi-config.json');
|
|
10
11
|
*/
|
|
11
|
-
export declare function checkConfig(
|
|
12
|
+
export declare function checkConfig(options: OptionValues): Promise<void>;
|
|
12
13
|
//# sourceMappingURL=checkConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/checkAndUpdateConfig/checkConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/checkAndUpdateConfig/checkConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAUzC;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CtE"}
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.checkConfig = checkConfig;
|
|
4
4
|
const Consts_1 = require("../../common/Consts");
|
|
5
5
|
const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
|
|
6
|
+
const validateZodOptions_1 = require("../../common/Validation/validateZodOptions");
|
|
7
|
+
const schemas_1 = require("../schemas");
|
|
6
8
|
const constants_1 = require("./constants");
|
|
7
9
|
const selectConfigAction_1 = require("./utils/selectConfigAction");
|
|
8
10
|
const validateAndMigrateConfigData_1 = require("./utils/validateAndMigrateConfigData");
|
|
@@ -16,20 +18,26 @@ const validateAndMigrateConfigData_1 = require("./utils/validateAndMigrateConfig
|
|
|
16
18
|
* @example
|
|
17
19
|
* await checkConfig('./openapi-config.json');
|
|
18
20
|
*/
|
|
19
|
-
async function checkConfig(
|
|
20
|
-
const
|
|
21
|
+
async function checkConfig(options) {
|
|
22
|
+
const validationResult = (0, validateZodOptions_1.validateZodOptions)(schemas_1.checkConfigOptionsSchema, options);
|
|
23
|
+
if (!validationResult.success) {
|
|
24
|
+
Consts_1.APP_LOGGER.error(validationResult.errors.join('\n'));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const validatedOptions = validationResult.data;
|
|
28
|
+
const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(validatedOptions.openapiConfig);
|
|
21
29
|
if (!configData) {
|
|
22
|
-
Consts_1.APP_LOGGER.error(`${constants_1.ERROR_MESSAGES.FILE_NOT_FOUND} ${
|
|
30
|
+
Consts_1.APP_LOGGER.error(`${constants_1.ERROR_MESSAGES.FILE_NOT_FOUND} ${validatedOptions.openapiConfig || ''}`);
|
|
23
31
|
return;
|
|
24
32
|
}
|
|
25
33
|
try {
|
|
26
34
|
const { isActualConfigVersion, hasDefaultValues, migratedData } = (0, validateAndMigrateConfigData_1.validateAndMigrateConfigData)(configData);
|
|
27
|
-
Consts_1.APP_LOGGER.info(constants_1.SUCCESS_MESSAGES.CONFIG_VALID(
|
|
35
|
+
Consts_1.APP_LOGGER.info(constants_1.SUCCESS_MESSAGES.CONFIG_VALID(validatedOptions.openapiConfig || ''));
|
|
28
36
|
// Если версия не актуальна, предложить обновление
|
|
29
37
|
if (!isActualConfigVersion) {
|
|
30
38
|
await (0, selectConfigAction_1.selectConfigAction)({
|
|
31
39
|
migratedData,
|
|
32
|
-
configPath,
|
|
40
|
+
configPath: validatedOptions.openapiConfig || '',
|
|
33
41
|
warningMessage: 'Ваша версия конфигурации устарела и нуждается в обновлении.',
|
|
34
42
|
actionChoices: constants_1.ACTION_FOR_CONFIG_DATA_OPTIONS,
|
|
35
43
|
});
|
|
@@ -39,7 +47,7 @@ async function checkConfig(configPath) {
|
|
|
39
47
|
if (hasDefaultValues) {
|
|
40
48
|
await (0, selectConfigAction_1.selectConfigAction)({
|
|
41
49
|
migratedData,
|
|
42
|
-
configPath,
|
|
50
|
+
configPath: validatedOptions.openapiConfig || '',
|
|
43
51
|
warningMessage: 'В вашей конфигурации есть значения по умолчанию, которые можно удалить.',
|
|
44
52
|
actionChoices: constants_1.ACTION_FOR_CONFIG_DATA_OPTIONS,
|
|
45
53
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionValues } from 'commander';
|
|
1
2
|
/**
|
|
2
3
|
* Обновляет конфигурационный файл до актуальной версии.
|
|
3
4
|
* Выполняет миграцию данных при необходимости.
|
|
@@ -8,5 +9,5 @@
|
|
|
8
9
|
* @example
|
|
9
10
|
* await updateConfig('./openapi-config.json');
|
|
10
11
|
*/
|
|
11
|
-
export declare function updateConfig(
|
|
12
|
+
export declare function updateConfig(options: OptionValues): Promise<void>;
|
|
12
13
|
//# sourceMappingURL=updateConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/checkAndUpdateConfig/updateConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/checkAndUpdateConfig/updateConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAUzC;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCvE"}
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateConfig = updateConfig;
|
|
4
4
|
const Consts_1 = require("../../common/Consts");
|
|
5
5
|
const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
|
|
6
|
+
const validateZodOptions_1 = require("../../common/Validation/validateZodOptions");
|
|
7
|
+
const schemas_1 = require("../schemas");
|
|
6
8
|
const constants_1 = require("./constants");
|
|
7
9
|
const validateAndMigrateConfigData_1 = require("./utils/validateAndMigrateConfigData");
|
|
8
10
|
const writeConfigFile_1 = require("./utils/writeConfigFile");
|
|
@@ -16,21 +18,27 @@ const writeConfigFile_1 = require("./utils/writeConfigFile");
|
|
|
16
18
|
* @example
|
|
17
19
|
* await updateConfig('./openapi-config.json');
|
|
18
20
|
*/
|
|
19
|
-
async function updateConfig(
|
|
20
|
-
const
|
|
21
|
+
async function updateConfig(options) {
|
|
22
|
+
const validationResult = (0, validateZodOptions_1.validateZodOptions)(schemas_1.updateConfigOptionsSchema, options);
|
|
23
|
+
if (!validationResult.success) {
|
|
24
|
+
Consts_1.APP_LOGGER.error(validationResult.errors.join('\n'));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const validatedOptions = validationResult.data;
|
|
28
|
+
const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(validatedOptions.openapiConfig);
|
|
21
29
|
if (!configData) {
|
|
22
|
-
Consts_1.APP_LOGGER.error(`${constants_1.ERROR_MESSAGES.FILE_NOT_FOUND} ${
|
|
30
|
+
Consts_1.APP_LOGGER.error(`${constants_1.ERROR_MESSAGES.FILE_NOT_FOUND} ${validatedOptions.openapiConfig}`);
|
|
23
31
|
return;
|
|
24
32
|
}
|
|
25
33
|
try {
|
|
26
34
|
const { isActualConfigVersion, migratedData } = (0, validateAndMigrateConfigData_1.validateAndMigrateConfigData)(configData);
|
|
27
35
|
if (isActualConfigVersion) {
|
|
28
|
-
Consts_1.APP_LOGGER.info(constants_1.SUCCESS_MESSAGES.CONFIG_UP_TO_DATE(
|
|
36
|
+
Consts_1.APP_LOGGER.info(constants_1.SUCCESS_MESSAGES.CONFIG_UP_TO_DATE(validatedOptions.openapiConfig || ''));
|
|
29
37
|
}
|
|
30
38
|
else {
|
|
31
39
|
await (0, writeConfigFile_1.writeConfigFile)({
|
|
32
40
|
data: migratedData,
|
|
33
|
-
configPath,
|
|
41
|
+
configPath: validatedOptions.openapiConfig || '',
|
|
34
42
|
isUpdating: true,
|
|
35
43
|
});
|
|
36
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateAndMigrateConfigData.d.ts","sourceRoot":"","sources":["../../../../src/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateAndMigrateConfigData.d.ts","sourceRoot":"","sources":["../../../../src/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,uBAAuB,CAmC7H"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateAndMigrateConfigData = validateAndMigrateConfigData;
|
|
4
|
+
const Consts_1 = require("../../../common/Consts");
|
|
4
5
|
const Enums_1 = require("../../../common/Enums");
|
|
6
|
+
const LoggerMessages_1 = require("../../../common/LoggerMessages");
|
|
5
7
|
const convertArrayToObject_1 = require("../../../common/utils/convertArrayToObject");
|
|
6
8
|
const MultiOptionsMigrationPlan_1 = require("../../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan");
|
|
7
9
|
const MultiOptionsVersionedSchemas_1 = require("../../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
|
|
@@ -26,6 +28,9 @@ const removeDefaultConfigValues_1 = require("./removeDefaultConfigValues");
|
|
|
26
28
|
*/
|
|
27
29
|
function validateAndMigrateConfigData(configData) {
|
|
28
30
|
const isArrayFormat = Array.isArray(configData);
|
|
31
|
+
if (isArrayFormat) {
|
|
32
|
+
Consts_1.APP_LOGGER.warn(LoggerMessages_1.LOGGER_MESSAGES.CONFIG.ARRAY_DEPRECATED);
|
|
33
|
+
}
|
|
29
34
|
const normalizedData = (0, convertArrayToObject_1.convertArrayToObject)(configData);
|
|
30
35
|
const isMultiOptions = (0, isInstanceOfMultiOptions_1.isInstanceOfMultioptions)(normalizedData);
|
|
31
36
|
// Выбрать соответствующие схемы и планы миграции
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateOpenApiClient.d.ts","sourceRoot":"","sources":["../../../src/cli/generateOpenApiClient/generateOpenApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generateOpenApiClient.d.ts","sourceRoot":"","sources":["../../../src/cli/generateOpenApiClient/generateOpenApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AA0BzC;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEhF"}
|
|
@@ -35,17 +35,26 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.generateOpenApiClient = generateOpenApiClient;
|
|
37
37
|
const Consts_1 = require("../../common/Consts");
|
|
38
|
-
const defaultOptions_1 = require("../../common/defaultOptions");
|
|
39
38
|
const Enums_1 = require("../../common/Enums");
|
|
40
39
|
const LoggerMessages_1 = require("../../common/LoggerMessages");
|
|
41
40
|
const convertArrayToObject_1 = require("../../common/utils/convertArrayToObject");
|
|
42
41
|
const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
|
|
42
|
+
const validateZodOptions_1 = require("../../common/Validation/validateZodOptions");
|
|
43
43
|
const AllMigrationPlans_1 = require("../../common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans");
|
|
44
44
|
const AllVersionedSchemas_1 = require("../../common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas");
|
|
45
|
+
const UnifiedVersionedSchemas_1 = require("../../common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas");
|
|
45
46
|
const migrateDataToLatestSchemaVersion_1 = require("../../common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion");
|
|
46
47
|
const OpenAPI = __importStar(require("../../core"));
|
|
47
|
-
const
|
|
48
|
-
const
|
|
48
|
+
const schemas_1 = require("../schemas");
|
|
49
|
+
const generateCliFlatSchema = UnifiedVersionedSchemas_1.flatOptionsSchema.strict().superRefine((data, ctx) => {
|
|
50
|
+
if (data.excludeCoreServiceFiles === true && data.request) {
|
|
51
|
+
ctx.addIssue({
|
|
52
|
+
code: 'custom',
|
|
53
|
+
message: '"request" can only be used when "excludeCoreServiceFiles" is false',
|
|
54
|
+
path: ['request'],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
49
58
|
/**
|
|
50
59
|
* Запускает генерацию OpenAPI клиента
|
|
51
60
|
* Поддерживает как конфиг-файл, так и параметры из CLI
|
|
@@ -53,36 +62,38 @@ const validation_1 = require("../validation");
|
|
|
53
62
|
async function generateOpenApiClient(options) {
|
|
54
63
|
const { openapiConfig, ...clientOptions } = options;
|
|
55
64
|
try {
|
|
56
|
-
|
|
57
|
-
const validationResult = (0, validation_1.validateCLIOptions)(generate_1.generateOptionsSchema, {
|
|
65
|
+
const validationResult = (0, validateZodOptions_1.validateZodOptions)(schemas_1.generateOptionsSchema, {
|
|
58
66
|
openapiConfig,
|
|
59
67
|
...clientOptions,
|
|
60
68
|
});
|
|
61
69
|
if (!validationResult.success) {
|
|
62
|
-
Consts_1.APP_LOGGER.error(validationResult.
|
|
70
|
+
Consts_1.APP_LOGGER.error(validationResult.errors.join('\n'));
|
|
63
71
|
process.exit(1);
|
|
64
72
|
}
|
|
65
73
|
const validatedOptions = validationResult.data;
|
|
66
74
|
// Если есть минимальные опции (input и output), используем их
|
|
67
75
|
const hasMinimumRequiredOptions = !!validatedOptions.input && !!validatedOptions.output;
|
|
68
76
|
if (hasMinimumRequiredOptions) {
|
|
69
|
-
|
|
70
|
-
// В будущем можно заменить на Zod
|
|
71
|
-
const { error: defaultValuesError, value } = defaultOptions_1.defaultOptions.validate({
|
|
77
|
+
const directOptionsValidationResult = (0, validateZodOptions_1.validateZodOptions)(generateCliFlatSchema, {
|
|
72
78
|
input: validatedOptions.input,
|
|
73
79
|
output: validatedOptions.output,
|
|
74
80
|
...clientOptions,
|
|
75
81
|
});
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
process.exit(
|
|
82
|
+
if (!directOptionsValidationResult.success) {
|
|
83
|
+
Consts_1.APP_LOGGER.error(directOptionsValidationResult.errors.join('\n'));
|
|
84
|
+
process.exit(1);
|
|
79
85
|
}
|
|
86
|
+
await OpenAPI.generate(directOptionsValidationResult.data);
|
|
87
|
+
process.exit(0);
|
|
80
88
|
}
|
|
81
89
|
const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(validatedOptions.openapiConfig);
|
|
82
90
|
if (!configData) {
|
|
83
|
-
Consts_1.APP_LOGGER.error(LoggerMessages_1.LOGGER_MESSAGES.CONFIG.FILE_MISSING);
|
|
91
|
+
Consts_1.APP_LOGGER.error(`${LoggerMessages_1.LOGGER_MESSAGES.CONFIG.FILE_MISSING}\nProvide non-empty "--input" and "--output" options, or a valid "--openapi-config" file path.`);
|
|
84
92
|
process.exit(1);
|
|
85
93
|
}
|
|
94
|
+
if (Array.isArray(configData)) {
|
|
95
|
+
Consts_1.APP_LOGGER.warn(LoggerMessages_1.LOGGER_MESSAGES.CONFIG.ARRAY_DEPRECATED);
|
|
96
|
+
}
|
|
86
97
|
const preparedOptions = (0, convertArrayToObject_1.convertArrayToObject)(configData);
|
|
87
98
|
// Use unified migration system for all schema types
|
|
88
99
|
const migratedOptions = (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
|