← 返回列表
全部 Skill›工具 Tools›openapi-generator

openapi-generator

作者 @findsun-vn · 语言 en
Generate a valid OpenAPI 3.0.3 contract from structured planner module output.
工具 Tools调试工具通用访问网络待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
0
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Skill: openapi-generator

Purpose

Generate a complete OpenAPI contract that becomes the single API source of truth for:

  • backend implementation
  • frontend integration
  • reviewer validation
  • debugger fixes

OpenAPI Version Rule

Always generate:

  • openapi: 3.0.3

No other version unless explicitly required.


Input Assumption

Input is a structured module plan containing:

  • module name
  • features
  • entities
  • business rules
  • API list
  • DB notes
  • backend/frontend task expectations

The skill must convert that planning output into:

  • tags
  • paths
  • request schemas
  • response schemas
  • wrapper schemas
  • pagination schemas
  • error schemas

Single Source of Truth Rule

openapi.yaml is the API source of truth.

Downstream systems must follow it exactly.

The skill must not:

  • invent major business behavior not implied by planner
  • create random unrelated endpoints
  • drift from module intent

Path Rules

Use RESTful naming:

  • plural resources
  • stable path params
  • clear hierarchy

Examples:

  • /api/users
  • /api/users/{id}

Use path params such as:

  • {id}
  • {slug}

Method Rules

  • GET -> read/list
  • POST -> create
  • PUT -> full update
  • PATCH -> partial/status update
  • DELETE -> soft delete semantics unless clearly stated otherwise

Tag Rules

Use consistent module-based tagging.

Preferred pattern:

  • <module_name>-admin
  • <module_name>-storefront

Tags should reflect actual business access separation.


Request Schema Rules

Request schema naming:

  • CreateXRequest
  • UpdateXRequest

Requests should:

  • reflect planner business rules
  • define required fields
  • be reusable when practical
  • avoid excessive inline schema duplication

Response Schema Rules

Response naming:

  • XResponse

Responses should:

  • represent business response payloads
  • avoid persistence/internal leakage
  • stay reusable

Standard Success Wrapper Rule

All successful responses must use this shape:

{

"code": 0,

"message": "success",

"data": {}

}

This is mandatory.

The skill must model this wrapper clearly and consistently.


Pagination Rule

Paginated list endpoints must use:

{

"code": 0,

"message": "success",

"data": {

"content": [],

"page": 1,

"size": 10,

"total": 100

}

}

Important:

  • the pagination object is the value of data
  • never generate raw top-level paginated success responses without wrapper

Field Rules

Common field patterns:

  • id -> integer/int64
  • created_at -> string/date-time
  • updated_at -> string/date-time
  • status -> enum where planner implies it
  • price -> number/decimal-like schema representation

Do not expose deleted_at unless explicitly required.


Business Rule Mapping

Map planner business rules into OpenAPI:

  • required -> required array
  • enum/status -> enum values
  • unique -> description note
  • auth restriction -> security requirements or endpoint description
  • soft delete -> delete semantics and normal list exclusion assumptions

Error Response Rules

At minimum define consistent error responses for:

  • 400
  • 401
  • 403
  • 404

Keep them structured and reusable.


Security Rules

Where auth is relevant:

  • define bearer auth scheme
  • apply security requirements on protected endpoints
  • distinguish public/storefront/admin behavior clearly

Merge Rules

If an existing openapi.yaml exists:

  • merge new paths
  • merge new schemas
  • preserve unrelated modules
  • do not silently remove existing content

Validation Checklist

Before finalizing:

  • no missing schema refs
  • no duplicate schema names
  • all paths have responses
  • wrapper contract is consistent
  • pagination is correctly nested inside data
  • YAML is valid
  • contract is merge-safe

Forbidden Patterns

  • missing request schema
  • response payloads without wrapper
  • raw top-level paginated success response
  • random inline schema duplication everywhere
  • mixing unrelated module tags carelessly

Final Goal

The final OpenAPI document must be:

  • valid
  • reusable
  • merge-safe
  • contract-first
  • ready for backend and frontend generation
评论
Ffindsun-vn
findsun-vn
findsun-vn/E-Commerce
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@findsun-vn
所属大类工具 Tools / 调试工具
国内可用性通用
最近源活动—
风险提示访问网络
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。