AgentSkillsCN

github-repo-openapi

从 GitHub 中检索仓库文件内容,以查找并读取 OpenAPI 规范文件。适用于从 GitHub 仓库中拉取 OpenAPI 规范、从仓库中读取文件内容,或发现存储在 GitHub 中的 API 定义时使用。当用户提及 GitHub 仓库内容、仓库中的 OpenAPI 文件、从 GitHub 读取规范,或从源代码控制中获取 API 定义时触发。

SKILL.md
--- frontmatter
name: github-repo-openapi
description: >
  Retrieve repository file contents from GitHub to find and read OpenAPI specification
  files. Use this skill when pulling OpenAPI specs from GitHub repos, reading file
  contents from repositories, or discovering API definitions stored in GitHub. Trigger
  when the user mentions GitHub repository contents, OpenAPI files in repos, reading
  specs from GitHub, or fetching API definitions from source control.

GitHub Repository OpenAPI Contents

Retrieve file contents from GitHub repositories, specifically for locating and reading OpenAPI specification files.

When to Use

  • Fetching OpenAPI/Swagger files from a GitHub repository
  • Reading any file contents from a GitHub repo by path
  • Discovering API specifications stored in version control
  • Pulling API definitions for analysis or comparison

Authentication

Use a Bearer token in the Authorization header:

code
Authorization: Bearer <github_token>

Alternatively, use token <github_token> format.

Key Endpoint

GET /repos/{owner}/{repo}/contents/{path} — Retrieve contents of a file or directory.

Parameters

ParameterLocationRequiredDescription
ownerpathYesRepository owner (user or org)
repopathYesRepository name
pathpathYesFile path (e.g., openapi.yaml)
refqueryNoBranch, tag, or commit SHA (default: default branch)

Response Handling

  • Files: Returns content (base64-encoded), encoding, sha, size, download_url
  • Directories: Returns array of file metadata objects
  • Large files: If > 1MB, use the download_url or Git Blobs API instead

Required Headers

  • Accept: application/vnd.github+json
  • X-GitHub-Api-Version: 2022-11-28

Common OpenAPI File Paths

Look for specs at typical locations: openapi.yaml, openapi.json, swagger.yaml, swagger.json, api/openapi.yml, docs/api.yaml, spec/openapi.yml.

API Reference

For complete schema details including all response fields, error codes, and content types, read references/openapi.yml.