首页/AI 后端工程/openapi-spec-generation
O

openapi-spec-generation

by @wshobsonv
4.5(120)

此技能可帮助开发者高效生成和维护 OpenAPI 3.1 规范,支持从现有代码或设计优先模式创建。它能确保 API 合约的准确性与一致性,加速 API 文档生成、SDK 开发及跨团队协作,显著提升后端开发效率和API质量。

openapiapi-designapi-documentationbackend-developmentsdk-generationGitHub
安装方式
npx skills add https://github.com/wshobson/agents --skill openapi-spec-generation
compare_arrows

Before / After 效果对比

1
使用前

手动更新和维护复杂的 OpenAPI 规范耗时巨大,且极易引入错误,导致文档与实际 API 不符,严重阻碍开发进度和团队协作。

使用后

通过自动化生成和验证,OpenAPI 规范能快速更新并保持与代码同步,大幅减少手动工作量,确保 API 合约的准确性和一致性。

SKILL.md

OpenAPI Spec Generation

Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs.

When to Use This Skill

  • Creating API documentation from scratch
  • Generating OpenAPI specs from existing code
  • Designing API contracts (design-first approach)
  • Validating API implementations against specs
  • Generating client SDKs from specs
  • Setting up API documentation portals

Core Concepts

1. OpenAPI 3.1 Structure

openapi: 3.1.0
info:
  title: API Title
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
paths:
  /resources:
    get: ...
components:
  schemas: ...
  securitySchemes: ...

2. Design Approaches

ApproachDescriptionBest For
Design-FirstWrite spec before codeNew APIs, contracts
Code-FirstGenerate spec from codeExisting APIs
HybridAnnotate code, generate specEvolving APIs

Templates and detailed worked examples

Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.

Best Practices

Do's

  • Use $ref - Reuse schemas, parameters, responses
  • Add examples - Real-world values help consumers
  • Document errors - All possible error codes
  • Version your API - In URL or header
  • Use semantic versioning - For spec changes

Don'ts

  • Don't use generic descriptions - Be specific
  • Don't skip security - Define all schemes
  • Don't forget nullable - Be explicit about null
  • Don't mix styles - Consistent naming throughout
  • Don't hardcode URLs - Use server variables

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量12.7K
评分4.5 / 5.0
版本
更新日期2026年7月7日
对比案例1 组

用户评分

4.5(120)
5
37%
4
43%
3
13%
2
5%
1
2%

为此 Skill 评分

0.0

兼容平台

🤖claude-code

时间线

创建2026年5月29日
最后更新2026年7月7日
🎁 Agent 知识卡片
调研问卷