Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)41k · #6690

openapi-spec-generation

Skill này làm gì

Công cụ này giúp tạo và sắp xếp tài liệu API (các giao diện cho phép chương trình giao tiếp với nhau). Nó có thể tạo tài liệu này từ code của bạn hoặc từ một bản thiết kế trước đó.

Khi nào nên dùng

  • ✓Khi bạn cần tài liệu hóa một API mới.
  • ✓Khi bạn muốn tạo tài liệu cho một API có sẵn trong code.
  • ✓Khi bạn cần tạo hướng dẫn để các chương trình khác dùng API của bạn.

Liên kết skill

https://github.com/wshobson/agents/blob/main/plugins/documentation-generation/skills/openapi-spec-generation/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/wshobson/agents/blob/main/plugins/documentation-generation/skills/openapi-spec-generation/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo tài liệu OpenAPI cho API này, nhận dữ liệu người dùng.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích code hoặc file thiết kế để hiểu cách API hoạt động. Sau đó, nó tạo ra một file theo chuẩn (OpenAPI 3.1) mô tả đầy đủ chi tiết của API.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Approach Description Best For
Design-First Write spec before code New APIs, contracts
Code-First Generate spec from code Existing APIs
Hybrid Annotate code, generate spec Evolving 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
Câu hỏi thường gặp

OpenAPI là gì?

Đó là định dạng chuẩn để mô tả API, giống như một bản đồ giải thích cách sử dụng một dịch vụ trực tuyến.

Khác nhau giữa “Design-First” và “Code-First” là gì?

“Design-First” là tạo bản đồ (tài liệu) trước khi xây con đường (API). “Code-First” là xây con đường rồi tạo bản đồ từ nó.

Tại sao dùng “$ref”?

Nó giống như một lối tắt để tránh lặp lại thông tin. Nếu bạn mô tả một kiểu dữ liệu ở một chỗ, bạn có thể dùng “$ref” để tái sử dụng mô tả đó ở chỗ khác.

Chi tiết

Mô tả gốc của tác giả

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.

repo: wshobson/agents

Độ phổ biến

Sao GitHub
41k
Vị trí xếp hạng
#6690
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự