Openapi Spec Generation

作者 wshobson46891e7e60da無授權條款收錄於 2026年10月8日更新於 2026年10月8日

Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.

AI 產生的概覽

指導建立、維護與驗證 REST API 的 OpenAPI 3.1 規格。

功能
此技能提供撰寫、維護與驗證 RESTful API 的 OpenAPI 3.1 規格的模式與指引。內容涵蓋規格結構、設計優先、程式碼優先與混合做法,以及重複使用、範例、錯誤文件與版本控管等最佳實務。它也會指向一個包含範本與完整範例的參考檔案。
適用情境
適用於建立 API 文件、從現有程式碼產生規格、在實作前設計 API 契約、依規格驗證實作,或產生用戶端 SDK。也適合架設 API 文件入口網站。
執行需求
沒有指令碼,僅為說明性內容。需使用技能資料夾中的參考檔案取得範本與範例。

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

yaml
openapi: 3.1.0info:  title: API Title  version: 1.0.0servers:  - url: https://api.example.com/v1paths:  /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

來源與署名

來源:wshobson/agents位於plugins/documentation-generation/skills/openapi-spec-generation提交46891e7

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架