ts-openapi-codegen 2.0.0 → 2.1.0-beta.1
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 +91 -2
- package/README.rus.md +91 -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
|
|
|
@@ -76,6 +77,9 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
76
77
|
| `--logTarget` | `-t` | string | `console` | Logging target: `console` or `file` |
|
|
77
78
|
| `--validationLibrary` | - | string | `none` | Validation library for schema generation: `none`, `zod`, `joi`, `yup`, or `jsonschema` |
|
|
78
79
|
| `--emptySchemaStrategy` | - | string | `keep` | Strategy for empty schemas: `keep`, `semantic`, or `skip` |
|
|
80
|
+
| `--modelsMode` | - | string | `interfaces` | Models generation mode: `interfaces` or `classes` |
|
|
81
|
+
| `--useHistory` | - | boolean | `false` | Apply diff report annotations during generation |
|
|
82
|
+
| `--diffReport` | - | string | `./openapi-diff-report.json` | Path to diff report JSON |
|
|
79
83
|
|
|
80
84
|
**Examples:**
|
|
81
85
|
```bash
|
|
@@ -163,6 +167,46 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
163
167
|
- `--preview-dir` / `-pd` - Temporary preview generation directory (default: `./.ts-openapi-codegen-preview-changes`)
|
|
164
168
|
- `--diff-dir` / `-dd` - Directory for diff reports (default: `./.ts-openapi-codegen-diff-changes`)
|
|
165
169
|
|
|
170
|
+
### Command: `analyze-diff`
|
|
171
|
+
|
|
172
|
+
Analyzes differences between two OpenAPI specifications and produces a JSON report.
|
|
173
|
+
|
|
174
|
+
**Usage:**
|
|
175
|
+
```bash
|
|
176
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
177
|
+
openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Options:**
|
|
181
|
+
- `--input` / `-i` - Path to current OpenAPI specification file (required)
|
|
182
|
+
- `--compare-with` - Path to previous OpenAPI specification file
|
|
183
|
+
- `--git` - Git ref to read previous specification version from (e.g. `HEAD~1`)
|
|
184
|
+
- `--output-report` - Path to save JSON diff report (default: `./openapi-diff-report.json`)
|
|
185
|
+
|
|
186
|
+
#### Miracles and confirmation
|
|
187
|
+
|
|
188
|
+
The diff report can contain a `miracles` section with detected renames/type-coercions. Only confirmed miracles are applied in generation.
|
|
189
|
+
|
|
190
|
+
**How to confirm miracles:**
|
|
191
|
+
1. Run `analyze-diff` and open the generated report (default: `./openapi-diff-report.json`).
|
|
192
|
+
2. Find the entry in `miracles` you want to accept.
|
|
193
|
+
3. Change `"status": "auto-generated"` to `"status": "confirmed"` and commit the report.
|
|
194
|
+
|
|
195
|
+
Example (excerpt):
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"miracles": [
|
|
199
|
+
{
|
|
200
|
+
"oldPath": "$.components.schemas.User.properties.user_name",
|
|
201
|
+
"newPath": "$.components.schemas.User.properties.userName",
|
|
202
|
+
"type": "RENAME",
|
|
203
|
+
"confidence": 0.85,
|
|
204
|
+
"status": "confirmed"
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
166
210
|
### Configuration File
|
|
167
211
|
|
|
168
212
|
Instead of passing all options via CLI, you can use a configuration file. Create `openapi.config.json` in your project root:
|
|
@@ -183,7 +227,22 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
183
227
|
"sortByRequired": false,
|
|
184
228
|
"useSeparatedIndexes": false,
|
|
185
229
|
"request": "./custom-request.ts",
|
|
186
|
-
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
230
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts",
|
|
231
|
+
"modelsMode": "interfaces",
|
|
232
|
+
"useHistory": false,
|
|
233
|
+
"diffReport": "./openapi-diff-report.json",
|
|
234
|
+
"models": {
|
|
235
|
+
"mode": "interfaces"
|
|
236
|
+
},
|
|
237
|
+
"analyze": {
|
|
238
|
+
"useHistory": false,
|
|
239
|
+
"reportPath": "./openapi-diff-report.json"
|
|
240
|
+
},
|
|
241
|
+
"miracles": {
|
|
242
|
+
"enabled": true,
|
|
243
|
+
"confidence": 1,
|
|
244
|
+
"types": ["RENAME", "TYPE_COERCION"]
|
|
245
|
+
}
|
|
187
246
|
}
|
|
188
247
|
```
|
|
189
248
|
|
|
@@ -244,6 +303,12 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
244
303
|
| `items` | array | - | Array of configurations (for multi-options format) |
|
|
245
304
|
| `validationLibrary` | string | `none` | Validation library for schema generation: `none`, `zod`, `joi`, `yup`, or `jsonschema` |
|
|
246
305
|
| `emptySchemaStrategy` | string | `keep` | Strategy for empty schemas: `keep`, `semantic`, or `skip` |
|
|
306
|
+
| `modelsMode` | string | `interfaces` | Models generation mode: `interfaces` or `classes` |
|
|
307
|
+
| `useHistory` | boolean | `false` | Apply diff report annotations during generation |
|
|
308
|
+
| `diffReport` | string | `./openapi-diff-report.json` | Path to diff report JSON |
|
|
309
|
+
| `models` | object | - | Models config section (e.g. `mode`) |
|
|
310
|
+
| `analyze` | object | - | Analyze config section (e.g. reportPath, useHistory, ignore) |
|
|
311
|
+
| `miracles` | object | - | Miracles config section (enabled, confidence, types) |
|
|
247
312
|
|
|
248
313
|
**Note:** You can use the `init` command to generate a template configuration file.
|
|
249
314
|
|
|
@@ -265,6 +330,16 @@ openapi init
|
|
|
265
330
|
openapi generate
|
|
266
331
|
```
|
|
267
332
|
|
|
333
|
+
**With DTO models (classes mode):**
|
|
334
|
+
```bash
|
|
335
|
+
openapi generate --input ./spec.json --output ./dist --modelsMode classes
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Generate diff report:**
|
|
339
|
+
```bash
|
|
340
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
341
|
+
```
|
|
342
|
+
|
|
268
343
|
**Check configuration:**
|
|
269
344
|
```bash
|
|
270
345
|
openapi check-config
|
|
@@ -423,6 +498,20 @@ The `--validationLibrary` parameter allows you to generate runtime validation sc
|
|
|
423
498
|
- **yup** - Generate Yup validation schemas
|
|
424
499
|
- **jsonschema** - Generate JSON Schema validation schemas
|
|
425
500
|
|
|
501
|
+
When `--useHistory` is enabled and a diff report marks a type change, validators will attempt to coerce values:
|
|
502
|
+
- **Zod** uses `z.coerce.*`
|
|
503
|
+
- **Joi** uses `Joi.alternatives().try(...)`
|
|
504
|
+
- **Yup** uses `.transform(...)`
|
|
505
|
+
- **JSON Schema (AJV)** enables `coerceTypes`
|
|
506
|
+
|
|
507
|
+
### Models mode `--modelsMode`
|
|
508
|
+
|
|
509
|
+
By default, models are generated as TypeScript interfaces/types. When `--modelsMode classes` is used, the generator produces:
|
|
510
|
+
- `*Raw` interfaces matching the API JSON
|
|
511
|
+
- `*Dto` classes with getters, defaults, recursive constructors, and `toJSON()`
|
|
512
|
+
|
|
513
|
+
The output is consolidated into a single `models.ts` file, and `BaseDto`/`dtoUtils` are emitted in `core`.
|
|
514
|
+
|
|
426
515
|
Let's say we have the following model:
|
|
427
516
|
|
|
428
517
|
```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
|
|
|
@@ -75,6 +76,9 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
75
76
|
| `--logTarget` | `-t` | string | `console` | Цель логирования: `console` или `file` |
|
|
76
77
|
| `--validationLibrary` | - | string | `none` | Библиотека валидации для генерации схем: `none`, `zod`, `joi`, `yup`, или `jsonschema` |
|
|
77
78
|
| `--emptySchemaStrategy` | - | string | `keep` | Стратегия для пустых схем: `keep`, `semantic`, или `skip` |
|
|
79
|
+
| `--modelsMode` | - | string | `interfaces` | Режим генерации моделей: `interfaces` или `classes` |
|
|
80
|
+
| `--useHistory` | - | boolean | `false` | Применять diff-отчёт при генерации |
|
|
81
|
+
| `--diffReport` | - | string | `./openapi-diff-report.json` | Путь к diff-отчёту |
|
|
78
82
|
|
|
79
83
|
**Примеры:**
|
|
80
84
|
```bash
|
|
@@ -162,6 +166,46 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
162
166
|
- `--preview-dir` / `-pd` - Временная директория для preview-генерации (по умолчанию: `./.ts-openapi-codegen-preview-changes`)
|
|
163
167
|
- `--diff-dir` / `-dd` - Директория для diff-отчетов (по умолчанию: `./.ts-openapi-codegen-diff-changes`)
|
|
164
168
|
|
|
169
|
+
### Команда: `analyze-diff`
|
|
170
|
+
|
|
171
|
+
Анализирует изменения между двумя версиями OpenAPI и формирует JSON‑отчет.
|
|
172
|
+
|
|
173
|
+
**Использование:**
|
|
174
|
+
```bash
|
|
175
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
176
|
+
openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Опции:**
|
|
180
|
+
- `--input` / `-i` - Путь к текущей спецификации OpenAPI (обязательно)
|
|
181
|
+
- `--compare-with` - Путь к предыдущей спецификации
|
|
182
|
+
- `--git` - Git ref для чтения предыдущей версии спецификации (например, `HEAD~1`)
|
|
183
|
+
- `--output-report` - Путь для сохранения diff‑отчёта (по умолчанию: `./openapi-diff-report.json`)
|
|
184
|
+
|
|
185
|
+
#### Miracles и подтверждение
|
|
186
|
+
|
|
187
|
+
В diff‑отчёте может быть раздел `miracles` с обнаруженными переименованиями/коэрсингом типов. В генерации применяются только подтверждённые записи.
|
|
188
|
+
|
|
189
|
+
**Как подтверждать чудеса:**
|
|
190
|
+
1. Запустите `analyze-diff` и откройте отчёт (по умолчанию: `./openapi-diff-report.json`).
|
|
191
|
+
2. Найдите нужную запись в `miracles`.
|
|
192
|
+
3. Измените `"status": "auto-generated"` на `"status": "confirmed"` и закоммитьте отчёт.
|
|
193
|
+
|
|
194
|
+
Пример (фрагмент):
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"miracles": [
|
|
198
|
+
{
|
|
199
|
+
"oldPath": "$.components.schemas.User.properties.user_name",
|
|
200
|
+
"newPath": "$.components.schemas.User.properties.userName",
|
|
201
|
+
"type": "RENAME",
|
|
202
|
+
"confidence": 0.85,
|
|
203
|
+
"status": "confirmed"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
165
209
|
### Файл конфигурации
|
|
166
210
|
|
|
167
211
|
Вместо передачи всех опций через CLI, вы можете использовать файл конфигурации. Создайте `openapi.config.json` в корне вашего проекта:
|
|
@@ -182,7 +226,22 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
182
226
|
"sortByRequired": false,
|
|
183
227
|
"useSeparatedIndexes": false,
|
|
184
228
|
"request": "./custom-request.ts",
|
|
185
|
-
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
229
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts",
|
|
230
|
+
"modelsMode": "interfaces",
|
|
231
|
+
"useHistory": false,
|
|
232
|
+
"diffReport": "./openapi-diff-report.json",
|
|
233
|
+
"models": {
|
|
234
|
+
"mode": "interfaces"
|
|
235
|
+
},
|
|
236
|
+
"analyze": {
|
|
237
|
+
"useHistory": false,
|
|
238
|
+
"reportPath": "./openapi-diff-report.json"
|
|
239
|
+
},
|
|
240
|
+
"miracles": {
|
|
241
|
+
"enabled": true,
|
|
242
|
+
"confidence": 1,
|
|
243
|
+
"types": ["RENAME", "TYPE_COERCION"]
|
|
244
|
+
}
|
|
186
245
|
}
|
|
187
246
|
```
|
|
188
247
|
|
|
@@ -243,6 +302,12 @@ openapi preview-changes --openapi-config ./custom-config.json
|
|
|
243
302
|
| `items` | array | - | Массив конфигураций (для формата multi-options) |
|
|
244
303
|
| `validationLibrary` | string | `none` | Библиотека валидации для генерации схем: `none`, `zod`, `joi`, `yup`, или `jsonschema` |
|
|
245
304
|
| `emptySchemaStrategy` | string | `keep` | Стратегия для пустых схем: `keep`, `semantic`, или `skip` |
|
|
305
|
+
| `modelsMode` | string | `interfaces` | Режим генерации моделей: `interfaces` или `classes` |
|
|
306
|
+
| `useHistory` | boolean | `false` | Применять diff‑отчёт при генерации |
|
|
307
|
+
| `diffReport` | string | `./openapi-diff-report.json` | Путь к diff‑отчёту |
|
|
308
|
+
| `models` | object | - | Секция конфигурации моделей (например, `mode`) |
|
|
309
|
+
| `analyze` | object | - | Секция анализа (например, reportPath, useHistory, ignore) |
|
|
310
|
+
| `miracles` | object | - | Секция чудес (enabled, confidence, types) |
|
|
246
311
|
|
|
247
312
|
**Примечание:** Вы можете использовать команду `init` для генерации шаблона файла конфигурации.
|
|
248
313
|
|
|
@@ -264,6 +329,16 @@ openapi init
|
|
|
264
329
|
openapi generate
|
|
265
330
|
```
|
|
266
331
|
|
|
332
|
+
**С DTO моделями (режим classes):**
|
|
333
|
+
```bash
|
|
334
|
+
openapi generate --input ./spec.json --output ./dist --modelsMode classes
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Сгенерировать diff‑отчёт:**
|
|
338
|
+
```bash
|
|
339
|
+
openapi analyze-diff --input ./openapi/current.yaml --compare-with ./openapi/previous.yaml --output-report ./openapi-diff-report.json
|
|
340
|
+
```
|
|
341
|
+
|
|
267
342
|
**Проверка конфигурации:**
|
|
268
343
|
```bash
|
|
269
344
|
openapi check-config
|
|
@@ -422,6 +497,20 @@ const order: Order = {
|
|
|
422
497
|
- **yup** - Генерация схем валидации Yup
|
|
423
498
|
- **jsonschema** - Генерация схем валидации JSON Schema
|
|
424
499
|
|
|
500
|
+
Если включен `--useHistory` и в diff‑отчёте есть смена типа, валидаторы будут пытаться выполнять коэрсинг:
|
|
501
|
+
- **Zod** использует `z.coerce.*`
|
|
502
|
+
- **Joi** использует `Joi.alternatives().try(...)`
|
|
503
|
+
- **Yup** использует `.transform(...)`
|
|
504
|
+
- **JSON Schema (AJV)** включает `coerceTypes`
|
|
505
|
+
|
|
506
|
+
### Режим моделей `--modelsMode`
|
|
507
|
+
|
|
508
|
+
По умолчанию модели генерируются как интерфейсы/типы. При `--modelsMode classes` генератор создаёт:
|
|
509
|
+
- `*Raw` интерфейсы (JSON‑формат API)
|
|
510
|
+
- `*Dto` классы с геттерами, дефолтами, рекурсивными конструкторами и `toJSON()`
|
|
511
|
+
|
|
512
|
+
Вывод консолидируется в один файл `models.ts`, а `BaseDto`/`dtoUtils` добавляются в `core`.
|
|
513
|
+
|
|
425
514
|
Допустим, у нас есть следующая модель:
|
|
426
515
|
|
|
427
516
|
```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":""}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_test_1 = require("node:test");
|
|
10
|
+
const LoggerMessages_1 = require("../../../common/LoggerMessages");
|
|
11
|
+
const semanticDiffReportSchema_1 = require("../../../core/semanticDiff/semanticDiffReportSchema");
|
|
12
|
+
const analyzeDiff_1 = require("../analyzeDiff");
|
|
13
|
+
const ciSummary_1 = require("../ciSummary");
|
|
14
|
+
const repoRoot = node_path_1.default.join(__dirname, '..', '..', '..', '..');
|
|
15
|
+
function createTempDir(t, prefix) {
|
|
16
|
+
const generatedRoot = node_path_1.default.join(__dirname, 'generated');
|
|
17
|
+
(0, node_fs_1.mkdirSync)(generatedRoot, { recursive: true });
|
|
18
|
+
const tempDir = (0, node_fs_1.mkdtempSync)(node_path_1.default.join(generatedRoot, prefix));
|
|
19
|
+
t.after(() => {
|
|
20
|
+
(0, node_fs_1.rmSync)(tempDir, { recursive: true, force: true });
|
|
21
|
+
});
|
|
22
|
+
return tempDir;
|
|
23
|
+
}
|
|
24
|
+
async function runAnalyzeDiffCli(options) {
|
|
25
|
+
const result = await (0, analyzeDiff_1.analyzeDiff)(options);
|
|
26
|
+
return {
|
|
27
|
+
exitCode: (0, analyzeDiff_1.toAnalyzeDiffExitCode)(result),
|
|
28
|
+
result,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
(0, node_test_1.describe)('@unit: analyzeDiff cli', () => {
|
|
32
|
+
(0, node_test_1.test)('returns exit code 0 and skips when --input has no base source', async (t) => {
|
|
33
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-skip-');
|
|
34
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
35
|
+
const inputSpecPath = node_path_1.default.join(repoRoot, 'test/spec/v3.json');
|
|
36
|
+
const { exitCode, result } = await runAnalyzeDiffCli({
|
|
37
|
+
input: inputSpecPath,
|
|
38
|
+
outputReport: reportPath,
|
|
39
|
+
ci: false,
|
|
40
|
+
});
|
|
41
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
42
|
+
node_assert_1.default.strictEqual(result.skipped, true);
|
|
43
|
+
node_assert_1.default.strictEqual(result.error, undefined);
|
|
44
|
+
});
|
|
45
|
+
(0, node_test_1.test)('returns exit code 0 for --input + --git', async (t) => {
|
|
46
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-git-');
|
|
47
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
48
|
+
const inputSpecPath = node_path_1.default.join(repoRoot, 'test/spec/v3.json');
|
|
49
|
+
const { exitCode } = await runAnalyzeDiffCli({
|
|
50
|
+
input: inputSpecPath,
|
|
51
|
+
outputReport: reportPath,
|
|
52
|
+
git: 'HEAD',
|
|
53
|
+
ci: true,
|
|
54
|
+
});
|
|
55
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
56
|
+
});
|
|
57
|
+
(0, node_test_1.test)('returns exit code 0 for non-breaking diff in ci mode', async (t) => {
|
|
58
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-ok-');
|
|
59
|
+
const oldSpecPath = node_path_1.default.join(tempDir, 'old.json');
|
|
60
|
+
const newSpecPath = node_path_1.default.join(tempDir, 'new.json');
|
|
61
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
62
|
+
(0, node_fs_1.writeFileSync)(oldSpecPath, JSON.stringify({
|
|
63
|
+
openapi: '3.0.0',
|
|
64
|
+
info: { title: 'Old', version: '1.0.0' },
|
|
65
|
+
paths: {
|
|
66
|
+
'/ping': {
|
|
67
|
+
get: {
|
|
68
|
+
responses: {
|
|
69
|
+
'200': { description: 'ok' },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
75
|
+
(0, node_fs_1.writeFileSync)(newSpecPath, JSON.stringify({
|
|
76
|
+
openapi: '3.0.0',
|
|
77
|
+
info: { title: 'New', version: '1.1.0' },
|
|
78
|
+
paths: {
|
|
79
|
+
'/ping': {
|
|
80
|
+
get: {
|
|
81
|
+
responses: {
|
|
82
|
+
'200': { description: 'ok' },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
'/pong': {
|
|
87
|
+
get: {
|
|
88
|
+
responses: {
|
|
89
|
+
'200': { description: 'ok' },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}));
|
|
95
|
+
const { exitCode } = await runAnalyzeDiffCli({
|
|
96
|
+
input: newSpecPath,
|
|
97
|
+
outputReport: reportPath,
|
|
98
|
+
compareWith: oldSpecPath,
|
|
99
|
+
ci: true,
|
|
100
|
+
});
|
|
101
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
102
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(reportPath, 'utf8'));
|
|
103
|
+
const schemaValidation = (0, semanticDiffReportSchema_1.validateSemanticDiffReportSchema)(report);
|
|
104
|
+
node_assert_1.default.strictEqual(schemaValidation.valid, true, schemaValidation.errors.join('\n'));
|
|
105
|
+
node_assert_1.default.strictEqual(report.schemaVersion, '1.1.0');
|
|
106
|
+
node_assert_1.default.strictEqual(report.summary.breaking, 0);
|
|
107
|
+
node_assert_1.default.ok(report.summary.nonBreaking > 0);
|
|
108
|
+
node_assert_1.default.strictEqual(report.recommendation.semver, 'minor');
|
|
109
|
+
node_assert_1.default.ok(report.recommendation.reasons.includes('HAS_BACKWARD_COMPATIBLE_CHANGES'));
|
|
110
|
+
node_assert_1.default.strictEqual(report.governance.summary.errors, 0);
|
|
111
|
+
const ciSummary = (0, ciSummary_1.formatCiMarkdownSummary)(report, reportPath);
|
|
112
|
+
node_assert_1.default.ok(ciSummary.includes('### OpenAPI Semantic Diff'));
|
|
113
|
+
node_assert_1.default.ok(ciSummary.includes('HAS_BACKWARD_COMPATIBLE_CHANGES'));
|
|
114
|
+
});
|
|
115
|
+
(0, node_test_1.test)('returns exit code 1 for breaking diff in ci mode', async (t) => {
|
|
116
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-breaking-');
|
|
117
|
+
const oldSpecPath = node_path_1.default.join(tempDir, 'old.json');
|
|
118
|
+
const newSpecPath = node_path_1.default.join(tempDir, 'new.json');
|
|
119
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
120
|
+
(0, node_fs_1.writeFileSync)(oldSpecPath, JSON.stringify({
|
|
121
|
+
openapi: '3.0.0',
|
|
122
|
+
info: { title: 'Old', version: '1.0.0' },
|
|
123
|
+
paths: {
|
|
124
|
+
'/ping': {
|
|
125
|
+
get: {
|
|
126
|
+
responses: {
|
|
127
|
+
'200': { description: 'ok' },
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
}));
|
|
133
|
+
(0, node_fs_1.writeFileSync)(newSpecPath, JSON.stringify({
|
|
134
|
+
openapi: '3.0.0',
|
|
135
|
+
info: { title: 'New', version: '2.0.0' },
|
|
136
|
+
paths: {},
|
|
137
|
+
}));
|
|
138
|
+
const { exitCode } = await runAnalyzeDiffCli({
|
|
139
|
+
input: newSpecPath,
|
|
140
|
+
outputReport: reportPath,
|
|
141
|
+
compareWith: oldSpecPath,
|
|
142
|
+
ci: true,
|
|
143
|
+
});
|
|
144
|
+
node_assert_1.default.strictEqual(exitCode, 1);
|
|
145
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(reportPath, 'utf8'));
|
|
146
|
+
const schemaValidation = (0, semanticDiffReportSchema_1.validateSemanticDiffReportSchema)(report);
|
|
147
|
+
node_assert_1.default.strictEqual(schemaValidation.valid, true, schemaValidation.errors.join('\n'));
|
|
148
|
+
node_assert_1.default.strictEqual(report.schemaVersion, '1.1.0');
|
|
149
|
+
node_assert_1.default.ok(report.summary.breaking > 0);
|
|
150
|
+
node_assert_1.default.ok(report.changes.some(change => change.severity === 'breaking'));
|
|
151
|
+
node_assert_1.default.strictEqual(report.recommendation.semver, 'major');
|
|
152
|
+
node_assert_1.default.ok(report.recommendation.reasons.includes('HAS_BREAKING_CHANGES'));
|
|
153
|
+
node_assert_1.default.ok(report.governance.violations.some(violation => violation.ruleId === 'NO_BREAKING_WITHOUT_FLAG'));
|
|
154
|
+
const ciSummary = (0, ciSummary_1.formatCiMarkdownSummary)(report, reportPath);
|
|
155
|
+
node_assert_1.default.ok(ciSummary.includes('### OpenAPI Semantic Diff'));
|
|
156
|
+
node_assert_1.default.ok(ciSummary.includes('HAS_BREAKING_CHANGES'));
|
|
157
|
+
});
|
|
158
|
+
(0, node_test_1.test)('returns exit code 0 for breaking diff in ci mode when allow-breaking is enabled', async (t) => {
|
|
159
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-breaking-allowed-');
|
|
160
|
+
const oldSpecPath = node_path_1.default.join(tempDir, 'old.json');
|
|
161
|
+
const newSpecPath = node_path_1.default.join(tempDir, 'new.json');
|
|
162
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
163
|
+
(0, node_fs_1.writeFileSync)(oldSpecPath, JSON.stringify({
|
|
164
|
+
openapi: '3.0.0',
|
|
165
|
+
info: { title: 'Old', version: '1.0.0' },
|
|
166
|
+
paths: {
|
|
167
|
+
'/ping': {
|
|
168
|
+
get: {
|
|
169
|
+
operationId: 'getPing',
|
|
170
|
+
responses: {
|
|
171
|
+
'200': { description: 'ok' },
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
177
|
+
(0, node_fs_1.writeFileSync)(newSpecPath, JSON.stringify({
|
|
178
|
+
openapi: '3.0.0',
|
|
179
|
+
info: { title: 'New', version: '2.0.0' },
|
|
180
|
+
paths: {},
|
|
181
|
+
}));
|
|
182
|
+
const { exitCode } = await runAnalyzeDiffCli({
|
|
183
|
+
input: newSpecPath,
|
|
184
|
+
outputReport: reportPath,
|
|
185
|
+
compareWith: oldSpecPath,
|
|
186
|
+
ci: true,
|
|
187
|
+
allowBreaking: true,
|
|
188
|
+
});
|
|
189
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
190
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(reportPath, 'utf8'));
|
|
191
|
+
const schemaValidation = (0, semanticDiffReportSchema_1.validateSemanticDiffReportSchema)(report);
|
|
192
|
+
node_assert_1.default.strictEqual(schemaValidation.valid, true, schemaValidation.errors.join('\n'));
|
|
193
|
+
node_assert_1.default.strictEqual(report.schemaVersion, '1.1.0');
|
|
194
|
+
node_assert_1.default.ok(report.summary.breaking > 0);
|
|
195
|
+
node_assert_1.default.ok(!report.governance.violations.some(violation => violation.ruleId === 'NO_BREAKING_WITHOUT_FLAG'));
|
|
196
|
+
node_assert_1.default.ok((0, ciSummary_1.formatCiMarkdownSummary)(report, reportPath).includes('### OpenAPI Semantic Diff'));
|
|
197
|
+
});
|
|
198
|
+
(0, node_test_1.test)('returns exit code 0 for breaking diff in ci mode when governance config disables no-breaking rule', async (t) => {
|
|
199
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-breaking-policy-');
|
|
200
|
+
const oldSpecPath = node_path_1.default.join(tempDir, 'old.json');
|
|
201
|
+
const newSpecPath = node_path_1.default.join(tempDir, 'new.json');
|
|
202
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
203
|
+
const governanceConfigPath = node_path_1.default.join(tempDir, 'governance.json');
|
|
204
|
+
(0, node_fs_1.writeFileSync)(oldSpecPath, JSON.stringify({
|
|
205
|
+
openapi: '3.0.0',
|
|
206
|
+
info: { title: 'Old', version: '1.0.0' },
|
|
207
|
+
paths: {
|
|
208
|
+
'/ping': {
|
|
209
|
+
get: {
|
|
210
|
+
operationId: 'getPing',
|
|
211
|
+
responses: {
|
|
212
|
+
'200': { description: 'ok' },
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
}));
|
|
218
|
+
(0, node_fs_1.writeFileSync)(newSpecPath, JSON.stringify({
|
|
219
|
+
openapi: '3.0.0',
|
|
220
|
+
info: { title: 'New', version: '2.0.0' },
|
|
221
|
+
paths: {},
|
|
222
|
+
}));
|
|
223
|
+
(0, node_fs_1.writeFileSync)(governanceConfigPath, JSON.stringify({
|
|
224
|
+
rules: {
|
|
225
|
+
NO_BREAKING_WITHOUT_FLAG: {
|
|
226
|
+
enabled: false,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
}));
|
|
230
|
+
const { exitCode } = await runAnalyzeDiffCli({
|
|
231
|
+
input: newSpecPath,
|
|
232
|
+
outputReport: reportPath,
|
|
233
|
+
compareWith: oldSpecPath,
|
|
234
|
+
ci: true,
|
|
235
|
+
governanceConfig: governanceConfigPath,
|
|
236
|
+
});
|
|
237
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
238
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(reportPath, 'utf8'));
|
|
239
|
+
const schemaValidation = (0, semanticDiffReportSchema_1.validateSemanticDiffReportSchema)(report);
|
|
240
|
+
node_assert_1.default.strictEqual(schemaValidation.valid, true, schemaValidation.errors.join('\n'));
|
|
241
|
+
node_assert_1.default.strictEqual(report.schemaVersion, '1.1.0');
|
|
242
|
+
node_assert_1.default.ok(report.summary.breaking > 0);
|
|
243
|
+
node_assert_1.default.ok(!report.governance.violations.some(violation => violation.ruleId === 'NO_BREAKING_WITHOUT_FLAG'));
|
|
244
|
+
node_assert_1.default.ok((0, ciSummary_1.formatCiMarkdownSummary)(report, reportPath).includes('### OpenAPI Semantic Diff'));
|
|
245
|
+
});
|
|
246
|
+
(0, node_test_1.test)('uses --compare-with over --git when both flags are provided', async (t) => {
|
|
247
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-priority-');
|
|
248
|
+
const oldSpecPath = node_path_1.default.join(tempDir, 'old.json');
|
|
249
|
+
const newSpecPath = node_path_1.default.join(tempDir, 'new.json');
|
|
250
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
251
|
+
(0, node_fs_1.writeFileSync)(oldSpecPath, JSON.stringify({
|
|
252
|
+
openapi: '3.0.0',
|
|
253
|
+
info: { title: 'Old', version: '1.0.0' },
|
|
254
|
+
paths: {
|
|
255
|
+
'/ping': {
|
|
256
|
+
get: {
|
|
257
|
+
responses: {
|
|
258
|
+
'200': { description: 'ok' },
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
}));
|
|
264
|
+
(0, node_fs_1.writeFileSync)(newSpecPath, JSON.stringify({
|
|
265
|
+
openapi: '3.0.0',
|
|
266
|
+
info: { title: 'New', version: '1.1.0' },
|
|
267
|
+
paths: {
|
|
268
|
+
'/ping': {
|
|
269
|
+
get: {
|
|
270
|
+
responses: {
|
|
271
|
+
'200': { description: 'ok' },
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
}));
|
|
277
|
+
const { exitCode, result } = await runAnalyzeDiffCli({
|
|
278
|
+
input: newSpecPath,
|
|
279
|
+
outputReport: reportPath,
|
|
280
|
+
compareWith: oldSpecPath,
|
|
281
|
+
git: 'HEAD~9999',
|
|
282
|
+
ci: true,
|
|
283
|
+
});
|
|
284
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
285
|
+
node_assert_1.default.strictEqual(result.success, true);
|
|
286
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(reportPath, 'utf8'));
|
|
287
|
+
node_assert_1.default.strictEqual(report.summary.breaking, 0);
|
|
288
|
+
node_assert_1.default.strictEqual(report.recommendation.semver, 'patch');
|
|
289
|
+
node_assert_1.default.ok(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.COMPARE_WITH_OVERRIDES_GIT('HEAD~9999').includes('Ignoring git ref'));
|
|
290
|
+
});
|
|
291
|
+
(0, node_test_1.test)('filters semantic changes with analyze.ignore and recalculates summary', async (t) => {
|
|
292
|
+
const tempDir = createTempDir(t, 'openapi-cli-analyze-ignore-');
|
|
293
|
+
const oldSpecPath = node_path_1.default.join(tempDir, 'old.json');
|
|
294
|
+
const newSpecPath = node_path_1.default.join(tempDir, 'new.json');
|
|
295
|
+
const reportPath = node_path_1.default.join(tempDir, 'report.json');
|
|
296
|
+
const configPath = node_path_1.default.join(tempDir, 'openapi.config.json');
|
|
297
|
+
(0, node_fs_1.writeFileSync)(oldSpecPath, JSON.stringify({
|
|
298
|
+
openapi: '3.0.0',
|
|
299
|
+
info: { title: 'Old', version: '1.0.0' },
|
|
300
|
+
paths: {
|
|
301
|
+
'/ping': {
|
|
302
|
+
get: {
|
|
303
|
+
responses: {
|
|
304
|
+
'200': { description: 'ok' },
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
}));
|
|
310
|
+
(0, node_fs_1.writeFileSync)(newSpecPath, JSON.stringify({
|
|
311
|
+
openapi: '3.0.0',
|
|
312
|
+
info: { title: 'New', version: '1.0.1' },
|
|
313
|
+
paths: {
|
|
314
|
+
'/ping': {
|
|
315
|
+
get: {
|
|
316
|
+
responses: {
|
|
317
|
+
'200': { description: 'ok' },
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
'/pong': {
|
|
322
|
+
get: {
|
|
323
|
+
responses: {
|
|
324
|
+
'200': { description: 'ok' },
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
}));
|
|
330
|
+
(0, node_fs_1.writeFileSync)(configPath, JSON.stringify({
|
|
331
|
+
analyze: {
|
|
332
|
+
ignore: [
|
|
333
|
+
{
|
|
334
|
+
path: '#/paths/GET /pong',
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
}, null, 2));
|
|
339
|
+
const { exitCode, result } = await runAnalyzeDiffCli({
|
|
340
|
+
input: newSpecPath,
|
|
341
|
+
outputReport: reportPath,
|
|
342
|
+
compareWith: oldSpecPath,
|
|
343
|
+
openapiConfig: configPath,
|
|
344
|
+
ci: true,
|
|
345
|
+
});
|
|
346
|
+
node_assert_1.default.strictEqual(exitCode, 0);
|
|
347
|
+
node_assert_1.default.strictEqual(result.ignored, 1);
|
|
348
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(reportPath, 'utf8'));
|
|
349
|
+
node_assert_1.default.strictEqual(report.summary.breaking, 0);
|
|
350
|
+
node_assert_1.default.strictEqual(report.summary.nonBreaking, 0);
|
|
351
|
+
node_assert_1.default.strictEqual(report.summary.informational, 0);
|
|
352
|
+
node_assert_1.default.strictEqual(report.recommendation.semver, 'patch');
|
|
353
|
+
node_assert_1.default.ok(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.IGNORED_CHANGES(1).includes('IGNORED: 1 semantic change'));
|
|
354
|
+
});
|
|
355
|
+
(0, node_test_1.test)('fails when --input is missing', async () => {
|
|
356
|
+
const result = await (0, analyzeDiff_1.analyzeDiff)({ git: 'HEAD~1' });
|
|
357
|
+
node_assert_1.default.strictEqual((0, analyzeDiff_1.toAnalyzeDiffExitCode)(result), 1);
|
|
358
|
+
node_assert_1.default.ok(result.error?.includes('"--input" is required for analyze-diff command'));
|
|
359
|
+
});
|
|
360
|
+
(0, node_test_1.test)('fails when analyze-diff is invoked without --input (legacy positional args are not accepted)', async () => {
|
|
361
|
+
const result = await (0, analyzeDiff_1.analyzeDiff)({});
|
|
362
|
+
node_assert_1.default.strictEqual((0, analyzeDiff_1.toAnalyzeDiffExitCode)(result), 1);
|
|
363
|
+
node_assert_1.default.ok(result.error?.includes('"--input" is required for analyze-diff command'));
|
|
364
|
+
});
|
|
365
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeDiffRenameAndInvalidRegex.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.ts"],"names":[],"mappings":""}
|