OpenAPI验证器Skill openapi-validator

OpenAPI验证器是一款用于自动化验证和检查OpenAPI(Swagger)规范文件的工具。它能确保API设计符合标准格式、安全要求及行业最佳实践,支持版本比对以检测破坏性变更,并可集成Spectral等代码检查工具进行自定义规则校验。适用于API开发、系统设计评审等场景,提升API文档质量与一致性。关键词:OpenAPI验证,API规范检查,安全定义,最佳实践,版本比对,Spectral集成,API设计评审。

后端开发 0 次安装 0 次浏览 更新于 2/26/2026

name: openapi-validator description: 验证OpenAPI规范的正确性、安全性和最佳实践 allowed-tools:

  • Bash
  • Read
  • Write
  • Glob

OpenAPI验证器技能

概述

验证OpenAPI规范的正确性、安全定义、最佳实践合规性以及版本间的破坏性变更检测。

能力

  • 验证OpenAPI 3.0/3.1规范
  • 检查安全定义的完整性
  • 针对API设计最佳实践进行代码检查
  • 比较规范版本
  • 检测版本间的破坏性变更
  • 自定义规则配置
  • 与Spectral和其他代码检查工具集成

目标流程

  • api-design-specification
  • system-design-review

输入模式

{
  "type": "object",
  "required": ["specPath"],
  "properties": {
    "specPath": {
      "type": "string",
      "description": "OpenAPI规范文件的路径"
    },
    "mode": {
      "type": "string",
      "enum": ["validate", "lint", "compare", "security"],
      "default": "validate"
    },
    "compareWith": {
      "type": "string",
      "description": "用于比较的先前规范版本的路径"
    },
    "rules": {
      "type": "object",
      "properties": {
        "ruleset": {
          "type": "string",
          "enum": ["spectral:oas", "custom"],
          "default": "spectral:oas"
        },
        "severity": {
          "type": "string",
          "enum": ["error", "warn", "info"],
          "default": "warn"
        }
      }
    }
  }
}

输出模式

{
  "type": "object",
  "properties": {
    "valid": {
      "type": "boolean"
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": { "type": "string" },
          "message": { "type": "string" },
          "severity": { "type": "string" }
        }
      }
    },
    "warnings": {
      "type": "array"
    },
    "breakingChanges": {
      "type": "array",
      "description": "比较时发现的破坏性变更列表"
    },
    "securityIssues": {
      "type": "array"
    }
  }
}

使用示例

{
  kind: 'skill',
  skill: {
    name: 'openapi-validator',
    context: {
      specPath: 'api/openapi.yaml',
      mode: 'lint',
      rules: {
        ruleset: 'spectral:oas',
        severity: 'warn'
      }
    }
  }
}