ts-openapi-codegen 2.0.0 → 2.1.0-beta.2
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 +95 -2
- package/README.rus.md +95 -2
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.js +365 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.js +142 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.js +137 -0
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts +17 -0
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/analyzeDiff.js +105 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts +17 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.js +54 -0
- package/dist/cli/analyzeDiff/ciSummary.d.ts +6 -0
- package/dist/cli/analyzeDiff/ciSummary.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ciSummary.js +20 -0
- package/dist/cli/analyzeDiff/diffEngine.d.ts +54 -0
- package/dist/cli/analyzeDiff/diffEngine.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/diffEngine.js +209 -0
- package/dist/cli/analyzeDiff/ignoreRules.d.ts +33 -0
- package/dist/cli/analyzeDiff/ignoreRules.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ignoreRules.js +93 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.d.ts +10 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.js +84 -0
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts +6 -0
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/logLegacyReport.js +29 -0
- package/dist/cli/analyzeDiff/miracles.d.ts +89 -0
- package/dist/cli/analyzeDiff/miracles.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/miracles.js +325 -0
- package/dist/cli/analyzeDiff/pluginPaths.d.ts +5 -0
- package/dist/cli/analyzeDiff/pluginPaths.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/pluginPaths.js +13 -0
- package/dist/cli/analyzeDiff/report.d.ts +3 -0
- package/dist/cli/analyzeDiff/report.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/report.js +7 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.d.ts +6 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.js +16 -0
- package/dist/cli/analyzeDiff/specParser.d.ts +22 -0
- package/dist/cli/analyzeDiff/specParser.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/specParser.js +80 -0
- package/dist/cli/analyzeDiff/types.d.ts +61 -0
- package/dist/cli/analyzeDiff/types.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/types.js +2 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts +6 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.js +21 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +13 -8
- package/dist/cli/checkAndUpdateConfig/constants.d.ts +0 -9
- package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/constants.js +1 -10
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +11 -7
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +6 -3
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +3 -2
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +2 -2
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.d.ts +2 -0
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.d.ts.map +1 -0
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.js +152 -0
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts +6 -2
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +54 -18
- package/dist/cli/index.js +57 -2
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +19 -6
- package/dist/cli/initOpenApiConfig/initConfig.d.ts +1 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initConfig.js +47 -24
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +8 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +40 -8
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +60 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.js +2 -1
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.js +2 -1
- package/dist/cli/interactive/confirmDialog.d.ts.map +1 -1
- package/dist/cli/interactive/confirmDialog.js +3 -2
- package/dist/cli/interactive/constants.d.ts +2 -2
- package/dist/cli/interactive/constants.js +8 -8
- package/dist/cli/interactive/selectDialog.d.ts.map +1 -1
- package/dist/cli/interactive/selectDialog.js +11 -6
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/previewChanges.js +45 -17
- package/dist/cli/schemas/analyzeDiff.d.ts +14 -0
- package/dist/cli/schemas/analyzeDiff.d.ts.map +1 -0
- package/dist/cli/schemas/analyzeDiff.js +28 -0
- package/dist/cli/schemas/generate.d.ts +9 -0
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +9 -0
- package/dist/cli/schemas/index.d.ts +3 -1
- package/dist/cli/schemas/index.d.ts.map +1 -1
- package/dist/cli/schemas/index.js +2 -0
- package/dist/common/Consts.d.ts +1 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +15 -1
- package/dist/common/Logger.d.ts +20 -1
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +70 -9
- package/dist/common/LoggerMessages.d.ts +135 -33
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +118 -45
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +7 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +4 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +35 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +4 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +79 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.js +19 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +171 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +2 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +40 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +34 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +23 -3
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +2 -2
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +2 -1
- package/dist/common/__tests__/Logger.test.d.ts +2 -0
- package/dist/common/__tests__/Logger.test.d.ts.map +1 -0
- package/dist/common/__tests__/Logger.test.js +100 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.js +3 -0
- package/dist/common/utils/__tests__/eslintFix.test.d.ts +2 -0
- package/dist/common/utils/__tests__/eslintFix.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/eslintFix.test.js +134 -0
- package/dist/common/utils/__tests__/format.test.d.ts +2 -0
- package/dist/common/utils/__tests__/format.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/format.test.js +90 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +3 -0
- package/dist/common/utils/eslintFix.d.ts +7 -0
- package/dist/common/utils/eslintFix.d.ts.map +1 -0
- package/dist/common/utils/eslintFix.js +78 -0
- package/dist/common/utils/format.d.ts +1 -1
- package/dist/common/utils/format.d.ts.map +1 -1
- package/dist/common/utils/format.js +39 -15
- package/dist/common/utils/jsonPath.d.ts +5 -0
- package/dist/common/utils/jsonPath.d.ts.map +1 -0
- package/dist/common/utils/jsonPath.js +27 -0
- package/dist/common/utils/normalizeObject.d.ts +2 -0
- package/dist/common/utils/normalizeObject.d.ts.map +1 -0
- package/dist/common/utils/normalizeObject.js +63 -0
- package/dist/core/Context.d.ts +8 -1
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +23 -4
- package/dist/core/OpenApiClient.d.ts +2 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +116 -6
- package/dist/core/WriteClient.d.ts +4 -0
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +38 -4
- package/dist/core/__tests__/WriteClient.test.js +4 -1
- package/dist/core/api/v2/parser/__tests__/getModel.test.d.ts +2 -0
- package/dist/core/api/v2/parser/__tests__/getModel.test.d.ts.map +1 -0
- package/dist/core/api/v2/parser/__tests__/getModel.test.js +34 -0
- package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModel.js +6 -1
- package/dist/core/api/v2/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperation.js +2 -0
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +9 -1
- package/dist/core/api/v2/types/OpenApiSchema.model.d.ts +2 -0
- package/dist/core/api/v2/types/OpenApiSchema.model.d.ts.map +1 -1
- package/dist/core/api/v3/parser/__tests__/getContent.test.d.ts +2 -0
- package/dist/core/api/v3/parser/__tests__/getContent.test.d.ts.map +1 -0
- package/dist/core/api/v3/parser/__tests__/getContent.test.js +65 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.d.ts +2 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.d.ts.map +1 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.js +34 -0
- package/dist/core/api/v3/parser/getContent.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getContent.js +21 -11
- package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModel.js +6 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperation.js +2 -0
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +9 -1
- package/dist/core/api/v3/types/OpenApiSchema.model.d.ts +2 -0
- package/dist/core/api/v3/types/OpenApiSchema.model.d.ts.map +1 -1
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.d.ts +2 -0
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.d.ts.map +1 -0
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.js +100 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.d.ts +2 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.d.ts.map +1 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.js +71 -0
- package/dist/core/governance/evaluateGovernanceRules.d.ts +42 -0
- package/dist/core/governance/evaluateGovernanceRules.d.ts.map +1 -0
- package/dist/core/governance/evaluateGovernanceRules.js +134 -0
- package/dist/core/governance/governanceConfigSchema.d.ts +4 -0
- package/dist/core/governance/governanceConfigSchema.d.ts.map +1 -0
- package/dist/core/governance/governanceConfigSchema.js +39 -0
- package/dist/core/governance/loadGovernanceConfig.d.ts +7 -0
- package/dist/core/governance/loadGovernanceConfig.d.ts.map +1 -0
- package/dist/core/governance/loadGovernanceConfig.js +60 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/plugins/GeneratorPlugin.model.d.ts +42 -0
- package/dist/core/plugins/GeneratorPlugin.model.d.ts.map +1 -0
- package/dist/core/plugins/GeneratorPlugin.model.js +2 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.d.ts +2 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.d.ts.map +1 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.js +115 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.d.ts +2 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.d.ts.map +1 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.js +62 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts +28 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts.map +1 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.js +160 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.d.ts +6 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.d.ts.map +1 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.js +13 -0
- package/dist/core/plugins/getBuiltinPlugins.d.ts +6 -0
- package/dist/core/plugins/getBuiltinPlugins.d.ts.map +1 -0
- package/dist/core/plugins/getBuiltinPlugins.js +10 -0
- package/dist/core/plugins/index.d.ts +4 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +5 -0
- package/dist/core/plugins/loadGeneratorPlugins.d.ts +6 -0
- package/dist/core/plugins/loadGeneratorPlugins.d.ts.map +1 -0
- package/dist/core/plugins/loadGeneratorPlugins.js +94 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.d.ts +2 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.d.ts.map +1 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.js +537 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.d.ts +2 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.d.ts.map +1 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.js +66 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts +45 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts.map +1 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.js +640 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts +11 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts.map +1 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.js +132 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.d.ts +2 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.d.ts.map +1 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.js +156 -0
- package/dist/core/strict/validateOpenApiStrict.d.ts +43 -0
- package/dist/core/strict/validateOpenApiStrict.d.ts.map +1 -0
- package/dist/core/strict/validateOpenApiStrict.js +253 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts +2 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/Templates.model.d.ts +3 -0
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/enums/ModelsMode.enum.d.ts +5 -0
- package/dist/core/types/enums/ModelsMode.enum.d.ts.map +1 -0
- package/dist/core/types/enums/ModelsMode.enum.js +8 -0
- package/dist/core/types/shared/Client.model.d.ts +2 -0
- package/dist/core/types/shared/Client.model.d.ts.map +1 -1
- package/dist/core/types/shared/DiffInfo.model.d.ts +13 -0
- package/dist/core/types/shared/DiffInfo.model.d.ts.map +1 -0
- package/dist/core/types/shared/DiffInfo.model.js +2 -0
- package/dist/core/types/shared/Miracle.model.d.ts +13 -0
- package/dist/core/types/shared/Miracle.model.d.ts.map +1 -0
- package/dist/core/types/shared/Miracle.model.js +2 -0
- package/dist/core/types/shared/Model.model.d.ts +23 -0
- package/dist/core/types/shared/Model.model.d.ts.map +1 -1
- package/dist/core/types/shared/Operation.model.d.ts +5 -0
- package/dist/core/types/shared/Operation.model.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +9 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.d.ts +2 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.js +108 -0
- package/dist/core/utils/__tests__/getMappedType.test.js +2 -0
- package/dist/core/utils/__tests__/getOperationResponseCode.test.js +7 -2
- package/dist/core/utils/__tests__/getOperationResults.test.d.ts +2 -0
- package/dist/core/utils/__tests__/getOperationResults.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/getOperationResults.test.js +43 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.d.ts +2 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.js +116 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +1 -0
- package/dist/core/utils/__tests__/writeClientModels.test.js +50 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts +14 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts.map +1 -0
- package/dist/core/utils/applyDiffReportToClient.js +367 -0
- package/dist/core/utils/getMappedType.d.ts.map +1 -1
- package/dist/core/utils/getMappedType.js +2 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +1 -14
- package/dist/core/utils/getOperationResponseCode.d.ts.map +1 -1
- package/dist/core/utils/getOperationResponseCode.js +10 -8
- package/dist/core/utils/loadDiffReport.d.ts +39 -0
- package/dist/core/utils/loadDiffReport.d.ts.map +1 -0
- package/dist/core/utils/loadDiffReport.js +51 -0
- package/dist/core/utils/prepareDtoModels.d.ts +3 -0
- package/dist/core/utils/prepareDtoModels.d.ts.map +1 -0
- package/dist/core/utils/prepareDtoModels.js +189 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +4 -1
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +6 -0
- package/dist/core/utils/validateRawOptions.d.ts +1 -1
- package/dist/core/utils/validateRawOptions.d.ts.map +1 -1
- package/dist/core/utils/validateRawOptions.js +4 -2
- package/dist/core/utils/writeClientCore.d.ts +2 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +6 -1
- package/dist/core/utils/writeClientCoreIndex.d.ts +1 -0
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +2 -2
- package/dist/core/utils/writeClientExecutor.d.ts +2 -0
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +6 -2
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +3 -1
- package/dist/core/utils/writeClientModels.d.ts +6 -0
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +24 -3
- package/dist/core/utils/writeClientModelsIndex.d.ts +2 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +2 -2
- package/dist/core/utils/writeClientSchemas.d.ts +2 -0
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +6 -2
- package/dist/core/utils/writeClientServices.d.ts +2 -0
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +6 -2
- package/dist/templatesCompiled/cli/openApiConfig.d.ts +4 -1
- package/dist/templatesCompiled/cli/openApiConfig.d.ts.map +1 -1
- package/dist/templatesCompiled/cli/openApiConfig.js +88 -37
- package/dist/templatesCompiled/client/core/ApiRequestOptions.js +1 -1
- package/dist/templatesCompiled/client/core/BaseDto.d.ts +8 -0
- package/dist/templatesCompiled/client/core/BaseDto.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/BaseDto.js +18 -0
- package/dist/templatesCompiled/client/core/axios/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/axios/request.js +2 -2
- package/dist/templatesCompiled/client/core/axios/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/core/dtoUtils.d.ts +8 -0
- package/dist/templatesCompiled/client/core/dtoUtils.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/dtoUtils.js +18 -0
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +2 -2
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/request.js +2 -2
- package/dist/templatesCompiled/client/core/functions/isBinary.js +1 -1
- package/dist/templatesCompiled/client/core/node/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/node/request.js +2 -2
- package/dist/templatesCompiled/client/core/xhr/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/xhr/request.js +2 -2
- package/dist/templatesCompiled/client/core/xhr/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/exportModels.d.ts +34 -0
- package/dist/templatesCompiled/client/exportModels.d.ts.map +1 -0
- package/dist/templatesCompiled/client/exportModels.js +280 -0
- package/dist/templatesCompiled/client/exportService.d.ts +7 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +52 -33
- package/dist/templatesCompiled/client/indexCore.d.ts +3 -1
- package/dist/templatesCompiled/client/indexCore.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexCore.js +13 -2
- package/dist/templatesCompiled/client/indexFull.d.ts +9 -7
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +52 -34
- package/dist/templatesCompiled/client/indexModels.d.ts +7 -5
- package/dist/templatesCompiled/client/indexModels.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexModels.js +27 -18
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts +27 -19
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.js +144 -63
- package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts +1 -0
- package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts.map +1 -1
- package/dist/templatesCompiled/client/jsonschema/exportSchema.js +17 -13
- package/dist/templatesCompiled/client/partials/exportInterface.d.ts +13 -5
- package/dist/templatesCompiled/client/partials/exportInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/exportInterface.js +91 -21
- package/dist/templatesCompiled/client/partials/result.d.ts +6 -4
- package/dist/templatesCompiled/client/partials/result.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/result.js +16 -6
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts +1 -0
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/serviceOption.js +11 -4
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts +22 -16
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.js +72 -60
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts +27 -19
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.js +77 -61
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
- Supports tsc and @babel/plugin-transform-typescript
|
|
29
29
|
- Supports customization names of models
|
|
30
30
|
- Supports external references using [`swagger-parser`](https://github.com/APIDevTools/swagger-parser/)
|
|
31
|
+
- Supports binary request/response generation (`format: binary` -> `Blob`)
|
|
31
32
|
|
|
32
33
|
## Install
|
|
33
34
|
|
|
@@ -38,7 +39,7 @@ npm install ts-openapi-codegen --save-dev
|
|
|
38
39
|
|
|
39
40
|
## Usage
|
|
40
41
|
|
|
41
|
-
The CLI tool supports
|
|
42
|
+
The CLI tool supports six commands: `generate`, `check-config`, `update-config`, `init`, `preview-changes`, and `analyze-diff`.
|
|
42
43
|
|
|
43
44
|
### Command: `generate`
|
|
44
45
|
|
|
@@ -72,10 +73,15 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
72
73
|
| `--useCancelableRequest` | - | boolean | `false` | Use cancelable promise as return type |
|
|
73
74
|
| `--sortByRequired` | `-s` | boolean | `false` | Use extended sorting strategy for function arguments |
|
|
74
75
|
| `--useSeparatedIndexes` | - | boolean | `false` | Use separate index files for core, models, schemas, and services |
|
|
76
|
+
| `--strict-openapi` | - | boolean | `false` | Enable strict OpenAPI diagnostics and fail generation when strict errors are found |
|
|
77
|
+
| `--report-file` | - | string | `./openapi-report.json` | Path to strict OpenAPI diagnostics report JSON file |
|
|
75
78
|
| `--logLevel` | `-l` | string | `error` | Logging level: `info`, `warn`, or `error` |
|
|
76
79
|
| `--logTarget` | `-t` | string | `console` | Logging target: `console` or `file` |
|
|
77
80
|
| `--validationLibrary` | - | string | `none` | Validation library for schema generation: `none`, `zod`, `joi`, `yup`, or `jsonschema` |
|
|
78
81
|
| `--emptySchemaStrategy` | - | string | `keep` | Strategy for empty schemas: `keep`, `semantic`, or `skip` |
|
|
82
|
+
| `--modelsMode` | - | string | `interfaces` | Models generation mode: `interfaces` or `classes` |
|
|
83
|
+
| `--useHistory` | - | boolean | `false` | Apply diff report annotations during generation |
|
|
84
|
+
| `--diffReport` | - | string | `./openapi-diff-report.json` | Path to diff report JSON |
|
|
79
85
|
|
|
80
86
|
**Examples:**
|
|
81
87
|
```bash
|
|
@@ -163,6 +169,46 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
163
169
|
- `--preview-dir` / `-pd` - Temporary preview generation directory (default: `./.ts-openapi-codegen-preview-changes`)
|
|
164
170
|
- `--diff-dir` / `-dd` - Directory for diff reports (default: `./.ts-openapi-codegen-diff-changes`)
|
|
165
171
|
|
|
172
|
+
### Command: `analyze-diff`
|
|
173
|
+
|
|
174
|
+
Analyzes differences between two OpenAPI specifications and produces a JSON report.
|
|
175
|
+
|
|
176
|
+
**Usage:**
|
|
177
|
+
```bash
|
|
178
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
179
|
+
openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Options:**
|
|
183
|
+
- `--input` / `-i` - Path to current OpenAPI specification file (required)
|
|
184
|
+
- `--compare-with` - Path to previous OpenAPI specification file
|
|
185
|
+
- `--git` - Git ref to read previous specification version from (e.g. `HEAD~1`)
|
|
186
|
+
- `--output-report` - Path to save JSON diff report (default: `./openapi-diff-report.json`)
|
|
187
|
+
|
|
188
|
+
#### Miracles and confirmation
|
|
189
|
+
|
|
190
|
+
The diff report can contain a `miracles` section with detected renames/type-coercions. Only confirmed miracles are applied in generation.
|
|
191
|
+
|
|
192
|
+
**How to confirm miracles:**
|
|
193
|
+
1. Run `analyze-diff` and open the generated report (default: `./openapi-diff-report.json`).
|
|
194
|
+
2. Find the entry in `miracles` you want to accept.
|
|
195
|
+
3. Change `"status": "auto-generated"` to `"status": "confirmed"` and commit the report.
|
|
196
|
+
|
|
197
|
+
Example (excerpt):
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"miracles": [
|
|
201
|
+
{
|
|
202
|
+
"oldPath": "$.components.schemas.User.properties.user_name",
|
|
203
|
+
"newPath": "$.components.schemas.User.properties.userName",
|
|
204
|
+
"type": "RENAME",
|
|
205
|
+
"confidence": 0.85,
|
|
206
|
+
"status": "confirmed"
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
166
212
|
### Configuration File
|
|
167
213
|
|
|
168
214
|
Instead of passing all options via CLI, you can use a configuration file. Create `openapi.config.json` in your project root:
|
|
@@ -183,7 +229,22 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
183
229
|
"sortByRequired": false,
|
|
184
230
|
"useSeparatedIndexes": false,
|
|
185
231
|
"request": "./custom-request.ts",
|
|
186
|
-
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
232
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts",
|
|
233
|
+
"modelsMode": "interfaces",
|
|
234
|
+
"useHistory": false,
|
|
235
|
+
"diffReport": "./openapi-diff-report.json",
|
|
236
|
+
"models": {
|
|
237
|
+
"mode": "interfaces"
|
|
238
|
+
},
|
|
239
|
+
"analyze": {
|
|
240
|
+
"useHistory": false,
|
|
241
|
+
"reportPath": "./openapi-diff-report.json"
|
|
242
|
+
},
|
|
243
|
+
"miracles": {
|
|
244
|
+
"enabled": true,
|
|
245
|
+
"confidence": 1,
|
|
246
|
+
"types": ["RENAME", "TYPE_COERCION"]
|
|
247
|
+
}
|
|
187
248
|
}
|
|
188
249
|
```
|
|
189
250
|
|
|
@@ -241,9 +302,17 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
241
302
|
| `useCancelableRequest` | boolean | `false` | Use cancelable promise as return type |
|
|
242
303
|
| `sortByRequired` | boolean | `false` | Extended sorting strategy for arguments |
|
|
243
304
|
| `useSeparatedIndexes` | boolean | `false` | Use separate index files |
|
|
305
|
+
| `strictOpenapi` | boolean | `false` | Enable strict OpenAPI diagnostics and fail generation on strict errors |
|
|
306
|
+
| `reportFile` | string | `./openapi-report.json` | Path to strict OpenAPI diagnostics report JSON file |
|
|
244
307
|
| `items` | array | - | Array of configurations (for multi-options format) |
|
|
245
308
|
| `validationLibrary` | string | `none` | Validation library for schema generation: `none`, `zod`, `joi`, `yup`, or `jsonschema` |
|
|
246
309
|
| `emptySchemaStrategy` | string | `keep` | Strategy for empty schemas: `keep`, `semantic`, or `skip` |
|
|
310
|
+
| `modelsMode` | string | `interfaces` | Models generation mode: `interfaces` or `classes` |
|
|
311
|
+
| `useHistory` | boolean | `false` | Apply diff report annotations during generation |
|
|
312
|
+
| `diffReport` | string | `./openapi-diff-report.json` | Path to diff report JSON |
|
|
313
|
+
| `models` | object | - | Models config section (e.g. `mode`) |
|
|
314
|
+
| `analyze` | object | - | Analyze config section (e.g. reportPath, useHistory, ignore) |
|
|
315
|
+
| `miracles` | object | - | Miracles config section (enabled, confidence, types) |
|
|
247
316
|
|
|
248
317
|
**Note:** You can use the `init` command to generate a template configuration file.
|
|
249
318
|
|
|
@@ -265,6 +334,16 @@ openapi init
|
|
|
265
334
|
openapi generate
|
|
266
335
|
```
|
|
267
336
|
|
|
337
|
+
**With DTO models (classes mode):**
|
|
338
|
+
```bash
|
|
339
|
+
openapi generate --input ./spec.json --output ./dist --modelsMode classes
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Generate diff report:**
|
|
343
|
+
```bash
|
|
344
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
345
|
+
```
|
|
346
|
+
|
|
268
347
|
**Check configuration:**
|
|
269
348
|
```bash
|
|
270
349
|
openapi check-config
|
|
@@ -423,6 +502,20 @@ The `--validationLibrary` parameter allows you to generate runtime validation sc
|
|
|
423
502
|
- **yup** - Generate Yup validation schemas
|
|
424
503
|
- **jsonschema** - Generate JSON Schema validation schemas
|
|
425
504
|
|
|
505
|
+
When `--useHistory` is enabled and a diff report marks a type change, validators will attempt to coerce values:
|
|
506
|
+
- **Zod** uses `z.coerce.*`
|
|
507
|
+
- **Joi** uses `Joi.alternatives().try(...)`
|
|
508
|
+
- **Yup** uses `.transform(...)`
|
|
509
|
+
- **JSON Schema (AJV)** enables `coerceTypes`
|
|
510
|
+
|
|
511
|
+
### Models mode `--modelsMode`
|
|
512
|
+
|
|
513
|
+
By default, models are generated as TypeScript interfaces/types. When `--modelsMode classes` is used, the generator produces:
|
|
514
|
+
- `*Raw` interfaces matching the API JSON
|
|
515
|
+
- `*Dto` classes with getters, defaults, recursive constructors, and `toJSON()`
|
|
516
|
+
|
|
517
|
+
The output is consolidated into a single `models.ts` file, and `BaseDto`/`dtoUtils` are emitted in `core`.
|
|
518
|
+
|
|
426
519
|
Let's say we have the following model:
|
|
427
520
|
|
|
428
521
|
```json
|
package/README.rus.md
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
- Поддерживает tsc и @babel/plugin-transform-typescript
|
|
29
29
|
- Поддерживает кастомизацию имен моделей
|
|
30
30
|
- Поддерживает внешние ссылки с помощью [`swagger-parser`](https://github.com/APIDevTools/swagger-parser/)
|
|
31
|
+
- Поддерживает генерацию бинарных request/response (`format: binary` -> `Blob`)
|
|
31
32
|
|
|
32
33
|
## Установка
|
|
33
34
|
|
|
@@ -37,7 +38,7 @@ npm install ts-openapi-codegen --save-dev
|
|
|
37
38
|
|
|
38
39
|
## Использование
|
|
39
40
|
|
|
40
|
-
CLI инструмент поддерживает
|
|
41
|
+
CLI инструмент поддерживает шесть команд: `generate`, `check-config`, `update-config`, `init`, `preview-changes` и `analyze-diff`.
|
|
41
42
|
|
|
42
43
|
### Команда: `generate`
|
|
43
44
|
|
|
@@ -71,10 +72,15 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
71
72
|
| `--useCancelableRequest` | - | boolean | `false` | Использовать отменяемый promise как тип возврата |
|
|
72
73
|
| `--sortByRequired` | `-s` | boolean | `false` | Использовать расширенную стратегию сортировки для аргументов функций |
|
|
73
74
|
| `--useSeparatedIndexes` | - | boolean | `false` | Использовать отдельные index файлы для core, models, schemas и services |
|
|
75
|
+
| `--strict-openapi` | - | boolean | `false` | Включить строгую диагностику OpenAPI и завершать генерацию при strict-ошибках |
|
|
76
|
+
| `--report-file` | - | string | `./openapi-report.json` | Путь к JSON-файлу strict-отчета по диагностике OpenAPI |
|
|
74
77
|
| `--logLevel` | `-l` | string | `error` | Уровень логирования: `info`, `warn`, или `error` |
|
|
75
78
|
| `--logTarget` | `-t` | string | `console` | Цель логирования: `console` или `file` |
|
|
76
79
|
| `--validationLibrary` | - | string | `none` | Библиотека валидации для генерации схем: `none`, `zod`, `joi`, `yup`, или `jsonschema` |
|
|
77
80
|
| `--emptySchemaStrategy` | - | string | `keep` | Стратегия для пустых схем: `keep`, `semantic`, или `skip` |
|
|
81
|
+
| `--modelsMode` | - | string | `interfaces` | Режим генерации моделей: `interfaces` или `classes` |
|
|
82
|
+
| `--useHistory` | - | boolean | `false` | Применять diff-отчёт при генерации |
|
|
83
|
+
| `--diffReport` | - | string | `./openapi-diff-report.json` | Путь к diff-отчёту |
|
|
78
84
|
|
|
79
85
|
**Примеры:**
|
|
80
86
|
```bash
|
|
@@ -162,6 +168,46 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
162
168
|
- `--preview-dir` / `-pd` - Временная директория для preview-генерации (по умолчанию: `./.ts-openapi-codegen-preview-changes`)
|
|
163
169
|
- `--diff-dir` / `-dd` - Директория для diff-отчетов (по умолчанию: `./.ts-openapi-codegen-diff-changes`)
|
|
164
170
|
|
|
171
|
+
### Команда: `analyze-diff`
|
|
172
|
+
|
|
173
|
+
Анализирует изменения между двумя версиями OpenAPI и формирует JSON‑отчет.
|
|
174
|
+
|
|
175
|
+
**Использование:**
|
|
176
|
+
```bash
|
|
177
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
178
|
+
openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Опции:**
|
|
182
|
+
- `--input` / `-i` - Путь к текущей спецификации OpenAPI (обязательно)
|
|
183
|
+
- `--compare-with` - Путь к предыдущей спецификации
|
|
184
|
+
- `--git` - Git ref для чтения предыдущей версии спецификации (например, `HEAD~1`)
|
|
185
|
+
- `--output-report` - Путь для сохранения diff‑отчёта (по умолчанию: `./openapi-diff-report.json`)
|
|
186
|
+
|
|
187
|
+
#### Miracles и подтверждение
|
|
188
|
+
|
|
189
|
+
В diff‑отчёте может быть раздел `miracles` с обнаруженными переименованиями/коэрсингом типов. В генерации применяются только подтверждённые записи.
|
|
190
|
+
|
|
191
|
+
**Как подтверждать чудеса:**
|
|
192
|
+
1. Запустите `analyze-diff` и откройте отчёт (по умолчанию: `./openapi-diff-report.json`).
|
|
193
|
+
2. Найдите нужную запись в `miracles`.
|
|
194
|
+
3. Измените `"status": "auto-generated"` на `"status": "confirmed"` и закоммитьте отчёт.
|
|
195
|
+
|
|
196
|
+
Пример (фрагмент):
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"miracles": [
|
|
200
|
+
{
|
|
201
|
+
"oldPath": "$.components.schemas.User.properties.user_name",
|
|
202
|
+
"newPath": "$.components.schemas.User.properties.userName",
|
|
203
|
+
"type": "RENAME",
|
|
204
|
+
"confidence": 0.85,
|
|
205
|
+
"status": "confirmed"
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
165
211
|
### Файл конфигурации
|
|
166
212
|
|
|
167
213
|
Вместо передачи всех опций через CLI, вы можете использовать файл конфигурации. Создайте `openapi.config.json` в корне вашего проекта:
|
|
@@ -182,7 +228,22 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
182
228
|
"sortByRequired": false,
|
|
183
229
|
"useSeparatedIndexes": false,
|
|
184
230
|
"request": "./custom-request.ts",
|
|
185
|
-
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
231
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts",
|
|
232
|
+
"modelsMode": "interfaces",
|
|
233
|
+
"useHistory": false,
|
|
234
|
+
"diffReport": "./openapi-diff-report.json",
|
|
235
|
+
"models": {
|
|
236
|
+
"mode": "interfaces"
|
|
237
|
+
},
|
|
238
|
+
"analyze": {
|
|
239
|
+
"useHistory": false,
|
|
240
|
+
"reportPath": "./openapi-diff-report.json"
|
|
241
|
+
},
|
|
242
|
+
"miracles": {
|
|
243
|
+
"enabled": true,
|
|
244
|
+
"confidence": 1,
|
|
245
|
+
"types": ["RENAME", "TYPE_COERCION"]
|
|
246
|
+
}
|
|
186
247
|
}
|
|
187
248
|
```
|
|
188
249
|
|
|
@@ -240,9 +301,17 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
240
301
|
| `useCancelableRequest` | boolean | `false` | Использовать отменяемый promise как тип возврата |
|
|
241
302
|
| `sortByRequired` | boolean | `false` | Расширенная стратегия сортировки для аргументов |
|
|
242
303
|
| `useSeparatedIndexes` | boolean | `false` | Использовать отдельные index файлы |
|
|
304
|
+
| `strictOpenapi` | boolean | `false` | Включить строгую диагностику OpenAPI и падать на strict-ошибках |
|
|
305
|
+
| `reportFile` | string | `./openapi-report.json` | Путь к JSON-файлу strict-отчета по диагностике OpenAPI |
|
|
243
306
|
| `items` | array | - | Массив конфигураций (для формата multi-options) |
|
|
244
307
|
| `validationLibrary` | string | `none` | Библиотека валидации для генерации схем: `none`, `zod`, `joi`, `yup`, или `jsonschema` |
|
|
245
308
|
| `emptySchemaStrategy` | string | `keep` | Стратегия для пустых схем: `keep`, `semantic`, или `skip` |
|
|
309
|
+
| `modelsMode` | string | `interfaces` | Режим генерации моделей: `interfaces` или `classes` |
|
|
310
|
+
| `useHistory` | boolean | `false` | Применять diff‑отчёт при генерации |
|
|
311
|
+
| `diffReport` | string | `./openapi-diff-report.json` | Путь к diff‑отчёту |
|
|
312
|
+
| `models` | object | - | Секция конфигурации моделей (например, `mode`) |
|
|
313
|
+
| `analyze` | object | - | Секция анализа (например, reportPath, useHistory, ignore) |
|
|
314
|
+
| `miracles` | object | - | Секция чудес (enabled, confidence, types) |
|
|
246
315
|
|
|
247
316
|
**Примечание:** Вы можете использовать команду `init` для генерации шаблона файла конфигурации.
|
|
248
317
|
|
|
@@ -264,6 +333,16 @@ openapi init
|
|
|
264
333
|
openapi generate
|
|
265
334
|
```
|
|
266
335
|
|
|
336
|
+
**С DTO моделями (режим classes):**
|
|
337
|
+
```bash
|
|
338
|
+
openapi generate --input ./spec.json --output ./dist --modelsMode classes
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Сгенерировать diff‑отчёт:**
|
|
342
|
+
```bash
|
|
343
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
344
|
+
```
|
|
345
|
+
|
|
267
346
|
**Проверка конфигурации:**
|
|
268
347
|
```bash
|
|
269
348
|
openapi check-config
|
|
@@ -422,6 +501,20 @@ const order: Order = {
|
|
|
422
501
|
- **yup** - Генерация схем валидации Yup
|
|
423
502
|
- **jsonschema** - Генерация схем валидации JSON Schema
|
|
424
503
|
|
|
504
|
+
Если включен `--useHistory` и в diff‑отчёте есть смена типа, валидаторы будут пытаться выполнять коэрсинг:
|
|
505
|
+
- **Zod** использует `z.coerce.*`
|
|
506
|
+
- **Joi** использует `Joi.alternatives().try(...)`
|
|
507
|
+
- **Yup** использует `.transform(...)`
|
|
508
|
+
- **JSON Schema (AJV)** включает `coerceTypes`
|
|
509
|
+
|
|
510
|
+
### Режим моделей `--modelsMode`
|
|
511
|
+
|
|
512
|
+
По умолчанию модели генерируются как интерфейсы/типы. При `--modelsMode classes` генератор создаёт:
|
|
513
|
+
- `*Raw` интерфейсы (JSON‑формат API)
|
|
514
|
+
- `*Dto` классы с геттерами, дефолтами, рекурсивными конструкторами и `toJSON()`
|
|
515
|
+
|
|
516
|
+
Вывод консолидируется в один файл `models.ts`, а `BaseDto`/`dtoUtils` добавляются в `core`.
|
|
517
|
+
|
|
425
518
|
Допустим, у нас есть следующая модель:
|
|
426
519
|
|
|
427
520
|
```json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeDiff.cli.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.ts"],"names":[],"mappings":""}
|