Communitygithub.com

YepAPI/skills

从 Zod 架构自动生成 OpenAPI 3.1 规范,提供交互式文档(Swagger/Scalar)、版本管理以及每个端点的示例请求。

skills 是什么?

YepAPI/skills 是一个专注于 API 文档生成的 AI Agent 技能,它遵循 OpenAPI 3.1 规范,鼓励从代码自动生成规范,而非手动编写。该技能支持通过 `zod-openapi` 或 `@asteasolutions/zod-to-openapi` 等库,将 Zod 架构自动转换为 OpenAPI 规范,确保文档与验证逻辑同步。它提供两种交互式文档选项:Scalar(现代、快速)和 Swagger UI,可在 `/docs` 或 `/api-docs` 路径下访问。每个端点必须包含摘要、描述、请求体架构和带有示例的所有响应码,错误响应采用一致的 `{ error, code, details }` 格式。版本管理建议使用 URL 路径(如 `/api/v1/`)处理破坏性变更,端点按资源(如 `/users`、`/products`)分组并通过标签在文档中结构化展示。该技能适用于 Hono、Express 等框架,适合需要高质量、自动化文档的 REST API 开发者。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/api-documentation

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

API 文档

规则

  • OpenAPI 3.1 规范作为唯一权威来源 — 从代码生成,而非手动编写
  • Zod 架构转 OpenAPI:使用 zod-openapi 或 @asteasolutions/zod-to-openapi — 定义一次,验证和文档同步
  • 交互式文档:Scalar(现代、快速)或 Swagger UI — 在 /docs 或 /api-docs 提供服务
  • 每个端点必须包含:摘要、描述、请求体架构、所有响应码及示例
  • 每个端点必须提供示例请求/响应 — 使用真实数据,而非 "string" 占位符
  • 版本策略:对破坏性变更使用 URL 路径(/api/v1/、/api/v2/)— 比头部版本管理更简单
  • 错误响应:以一致的格式记录所有错误形状 — { error: string, code: string, details?: object }
  • 身份验证:在安全方案部分记录认证方案(Bearer 令牌、API 密钥)
  • 按资源分组端点:/users、/products、/orders — 在文档 UI 中使用标签进行分组

模式

// 使用 zod-to-openapi 与 Hono/Express
import { z } from "zod";
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
extendZodWithOpenApi(z);

const UserSchema = z.object({
  id: z.string().uuid().openapi({ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" }),
  name: z.string().openapi({ example: "Jane Smith" }),
  email: z.string().email().openapi({ example: "[email protected]" }),
}).openapi("User");

const CreateUserSchema = UserSchema.omit({ id: true }).openapi("CreateUser");

// 注册端点
registry.registerPath({
  method: "post",
  path: "/api/v1/users",
  summary: "创建用户",
  request: { body: { content: { "application/json": { schema: CreateUserSchema } } } },
  responses: {
    201: { description: "用户创建成功", content: { "application/json": { schema: UserSchema } } },
    400: { description: "校验错误" },
  },
});

避免

  • 手动编写 OpenAPI YAML — 从 Zod 架构或路由定义生成
  • 缺少错误响应文档 — 记录 400、401、403、404、500
  • 使用 "string" 或 0 等通用示例 — 使用能展示真实数据形状的现实值
  • 文档与实现脱节 — 从验证所用的同一架构生成规范

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

相关技能