{"id":50474347,"url":"https://github.com/18296023612/api-validator","last_synced_at":"2026-06-01T12:02:55.180Z","repository":{"id":361621330,"uuid":"1255157315","full_name":"18296023612/api-validator","owner":"18296023612","description":"AI网关/中转站配置校验工具 - 一键检查YAML配置，避免启动失败。支持One API/New API/自建中转站","archived":false,"fork":false,"pushed_at":"2026-05-31T13:59:56.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-31T15:17:30.782Z","etag":null,"topics":["ai","api-gateway","config-validator","deepseek","devops","go","openai","yaml"],"latest_commit_sha":null,"homepage":"https://github.com/18296023612/api-validator","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/18296023612.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-31T13:32:54.000Z","updated_at":"2026-05-31T13:59:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/18296023612/api-validator","commit_stats":null,"previous_names":["18296023612/api-validator"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/18296023612/api-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18296023612%2Fapi-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18296023612%2Fapi-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18296023612%2Fapi-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18296023612%2Fapi-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/18296023612","download_url":"https://codeload.github.com/18296023612/api-validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18296023612%2Fapi-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33773782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api-gateway","config-validator","deepseek","devops","go","openai","yaml"],"created_at":"2026-06-01T12:02:52.429Z","updated_at":"2026-06-01T12:02:55.169Z","avatar_url":"https://github.com/18296023612.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API 配置校验器 🛡️\n\n\u003e **还在为写错 YAML 配置排查半天吗？一条命令搞定。**\n\n[![Release](https://img.shields.io/github/v/release/18296023612/api-validator)](https://github.com/18296023612/api-validator/releases)\n[![CI](https://github.com/18296023612/api-validator/actions/workflows/go-ci.yml/badge.svg)](https://github.com/18296023612/api-validator/actions/workflows/go-ci.yml)\n[![Go](https://img.shields.io/badge/Go-1.21%2B-blue)](https://go.dev/)\n[![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)\n\n---\n\n## 📺 为什么需要这个工具？\n\n```\n你写了一个 provider 配置：\n\n  providers:\n    - name: deepseek\n      type: openai\n      models:\n        - deepseek-chat\n\n启动 → 报错 → 排查 → 发现 base_url 忘写了 😤\n\n又或者：\n\n  api_key: ${SOME_VAR}\n\n结果 SOME_VAR 忘了设环境变量，服务拿着空字符串去调 API → 401\n```\n\n**这个工具就是来解决这个问题的。** 在你启动服务之前，先跑一条命令检查配置有没有问题。\n\n适用场景：**One API / New API / 自建 AI 中转站**\n\n---\n\n## ✨ 功能一览\n\n| 功能 | 说明 |\n|------|------|\n| ✅ **配置校验** | 检查 server.addr / admin.addr / auth.keys / provider 字段是否完整 |\n| ✅ **目录批量校验** | 一次检查整个 `providers/` 目录 |\n| ✅ **Provider 模板** | 内置 DeepSeek / 火山引擎 / 通义千问 / 智谱 / 百度 / Mock |\n| ✅ **环境变量检测** | 自动发现 `${VAR}` 语法，提示哪些变量没设 |\n| ✅ **多文档 YAML** | 支持 `---` 分隔的复杂文件 |\n| ✅ **项目初始化** | `api-validator init my-project` 一键生成标准配置 |\n| ✅ **零依赖** | 单文件二进制，下载即用 |\n\n---\n\n## 🚀 5 秒上手\n\n### 1️⃣ 下载\n\n从 [Releases](https://github.com/18296023612/api-validator/releases) 下载最新版：\n\n| 平台 | 下载 |\n|------|------|\n| **Windows x64** | [api-validator-windows-amd64.exe](https://github.com/18296023612/api-validator/releases/download/v1.0.0/api-validator-windows-amd64.exe) |\n| **Linux x64** | `go build -o api-validator .`（一条命令编译） |\n| **macOS** | `go build -o api-validator .`（一条命令编译） |\n\n### 2️⃣ 校验配置文件\n\n```bash\n# 校验单个文件\napi-validator validate config.yaml\n\n# 🔍 Config: ./config.yaml\n#   ✓ PASS\n#   ✓ No issues found. Config looks good!\n\n# 校验目录\napi-validator validate ./providers/\n```\n\n### 3️⃣ 发现错误时\n\n```bash\napi-validator validate ./bad-config.yaml\n\n# 🔍 Config: ./bad-config.yaml\n#   ✖ FAIL\n#   ✖ Errors:\n#     • providers[0](deepseek): base_url is required for type openai\n#   ⚠ Warnings:\n#     • providers[0](deepseek): no api_key set\n#     • providers[0](deepseek): no models configured\n```\n\n红色错误 ❌ = 必须修复，黄色警告 ⚠ = 建议处理。\n\n### 4️⃣ 生成新项目骨架\n\n```bash\napi-validator init my-gateway\ncd my-gateway\napi-validator validate config.yaml   # 一键校验\n```\n\n---\n\n## 💡 使用技巧\n\n### 嵌入 CI/CD 流水线\n\n```yaml\n# GitHub Actions 示例\n- name: 校验配置\n  run: |\n    ./api-validator validate config/providers/\n```\n\n### 配合 relay-server / One API 使用\n\n```bash\n# 写配置 → 校验 → 启动\napi-validator validate ./providers/ \u0026\u0026 relay-server\n```\n\n---\n\n## 🔧 支持的 Provider 类型\n\n| 类型 | 说明 |\n|------|------|\n| `openai` | OpenAI 兼容格式（DeepSeek / 火山 / 千问 / 智谱 / 百度...） |\n| `mock` | 本地 Mock 测试，无需 API Key |\n\n## 📄 配置参考（标准模板）\n\n```yaml\nserver:\n  addr: \":8080\"\n  timeout: \"120s\"\n\nadmin:\n  addr: \":8081\"\n\nauth:\n  enabled: true\n  keys:\n    - \"sk-your-key\"\n\nrate_limit:\n  enabled: true\n  rate: 10\n  capacity: 20\n\nproviders:\n  - name: deepseek\n    type: openai\n    base_url: https://api.deepseek.com\n    api_key: ${DEEPSEEK_API_KEY}\n    models:\n      - deepseek-chat\n      - deepseek-reasoner\n```\n\n---\n\n## 🏗️ 自行编译\n\n```bash\ngit clone https://github.com/18296023612/api-validator.git\ncd api-validator\ngo build -o api-validator .\n```\n\n需要 Go 1.21 或更高版本。\n\n---\n\n## 🧪 测试\n\n```bash\ngo test -v ./...\n```\n\n11 个单元测试全部通过 ✅\n\n---\n\n## 📜 许可证\n\nMIT License\n\n---\n\n## ⭐ 支持这个项目\n\n如果这个工具帮到了你，欢迎：\n\n- ⭐ **Star 这个仓库**（让更多人看到）\n- 🐛 **提 Issue**（报 bug 或建议新功能）\n- ☕ **请我喝咖啡**（扫下方赞赏码）\n\n\u003e 国内开发不易，一个 Star 就是最大的支持 🙏\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F18296023612%2Fapi-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F18296023612%2Fapi-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F18296023612%2Fapi-validator/lists"}