import_openapi
Import OpenAPI/Swagger specifications into Apifox projects to maintain API documentation. Supports OpenAPI 3.0/3.1 and Swagger 2.0 formats with options for batch imports, intelligent scope detection, and deprecation marking.
Instructions
维护 Apifox 接口文档:将 OpenAPI/Swagger 规范导入到 Apifox 项目。支持 OpenAPI 3.0/3.1 和 Swagger 2.0 格式。
⭐ 最佳实践(强烈推荐):
【分批导入】按模块分批导入(如先导入 /api/users,再导入 /api/products),而非一次性导入所有接口
【智能范围检测】每次只导入一个功能模块的完整规范,系统会自动识别范围
【启用废弃标记】设置 markDeprecatedEndpoints: true,自动保留并标记已删除的接口
分批导入的好处:更安全、更可控、支持模块独立维护、避免大规模误操作。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| options | No | 导入选项(可选) | |
| spec | Yes | OpenAPI/Swagger 规范的 JSON 对象。必须包含 openapi 或 swagger 字段、info 字段、paths 字段 |
Input Schema (JSON Schema)
{
"properties": {
"options": {
"description": "导入选项(可选)",
"properties": {
"confirmHighDeprecation": {
"description": "确认高比例废弃操作。当废弃比例超过 50% 时,必须设置为 true 才能继续。这是一个安全机制,防止误操作导致大量接口被标记为废弃。如果不设置此参数,操作会被阻止并返回错误信息。",
"type": "boolean"
},
"endpointOverwriteBehavior": {
"description": "接口覆盖行为,默认为 OVERWRITE_EXISTING",
"enum": [
"OVERWRITE_EXISTING",
"AUTO_MERGE",
"KEEP_EXISTING",
"CREATE_NEW"
],
"type": "string"
},
"markDeprecatedEndpoints": {
"description": "是否自动标记废弃的接口(推荐启用)。启用后会:1) 导出现有接口;2) 智能检测导入范围(如只导入 /api/marketing 模块);3) 只对比该范围内的接口;4) 标记已删除的接口为 deprecated。支持部分模块导入,不会误标记其他模块。默认为 false",
"type": "boolean"
},
"schemaOverwriteBehavior": {
"description": "数据模型覆盖行为,默认为 OVERWRITE_EXISTING",
"enum": [
"OVERWRITE_EXISTING",
"AUTO_MERGE",
"KEEP_EXISTING",
"CREATE_NEW"
],
"type": "string"
}
},
"type": "object"
},
"spec": {
"description": "OpenAPI/Swagger 规范的 JSON 对象。必须包含 openapi 或 swagger 字段、info 字段、paths 字段",
"type": "object"
}
},
"required": [
"spec"
],
"type": "object"
}