openapi-reader

Read, parse, browse, and search OpenAPI/Swagger specifications in local files or remote URLs, supporting Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1 in JSON and YAML formats. Used when the user needs to view API documentation, list endpoints, search by keyword, filter by method/tag/path, or inspect request parameters and response schemas. Trigger phrases include OpenAPI, Swagger, API documentation, interface documentation, interface specification, swagger.json, openapi.json, openapi.yaml, swagger.yaml, REST API, and interface list.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "openapi-reader" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5599b0ff1d49ee68c40ec0e0424f2f5fda1c798324f1dbbb0b05cb68e8b32ea7. Verify the upstream source and version against https://skillhub.cn/skills/user_608d0df3/openapi-reader before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Read, parse, browse, and search OpenAPI/Swagger specifications in local files or remote URLs, supporting Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1 in JSON and YAML formats. Used when the user needs to view API documentation, list endpoints, search by keyword, filter by method/tag/path, or inspect request parameters and response schemas. Trigger phrases include OpenAPI, Swagger, API documentation, interface documentation, interface specification, swagger.json, openapi.json, openapi.yaml, swagger.yaml, REST API, and interface list.

0 Downloads

Introduction source: third_party · user_608d0df3 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: openapi-reader
description: "读取、解析、浏览并搜索本地文件或远程 URL 中的 OpenAPI / Swagger 接口规范。支持 Swagger 2.0、OpenAPI 3.0、OpenAPI 3.1 的 JSON 与 YAML 格式。当用户需要查看接口文档、列出接口、按关键词搜索、按 method/tag/path 过滤、或查看请求参数与响应 Schema 时使用。触发词:OpenAPI、Swagger、API 文档、接口文档、接口规范、swagger.json、openapi.json、openapi.yaml、swagger.yaml、REST API、接口列表。"
agent_created: true

OpenAPI 接口规范阅读器

读取、浏览并搜索 OpenAPI / Swagger 接口规范 —— 在线或离线皆可。

快速开始

内置脚本 scripts/parse_openapi.py 提供快速、确定性的解析。当用户要看、列、或搜索某个接口规范时,先运行脚本获取结构化概览,如有需要再结合上下文做针对性分析。

python scripts/parse_openapi.py SOURCE [options]
  • SOURCE:本地文件路径或远程 URL(JSON 或 YAML 均可)
  • Python:任意 Python 3 解释器,无需指定特定路径

前置条件

  • Python 3.8 或以上
  • PyYAML(解析 YAML 规范所需):脚本运行时会自动检测并安装;自动安装失败(无网络 / 无权限)时,按提示手动执行 python -m pip install pyyaml 即可

工作流程

1. 加载接口规范

场景 命令
本地 JSON 文件 python scripts/parse_openapi.py /path/to/openapi.json
本地 YAML 文件 python scripts/parse_openapi.py /path/to/swagger.yaml
远程 URL python scripts/parse_openapi.py https://petstore3.swagger.io/api/v3/openapi.json

脚本会自动识别格式,并在开头打印摘要(标题、版本、Base URL)。

2. 列出全部接口

python scripts/parse_openapi.py SOURCE

输出每个接口的 HTTP 方法、路径、标签(tag)、摘要(summary)以及是否已废弃(deprecated)标记。

3. 过滤接口

过滤维度 参数 示例
按 HTTP 方法 --method GET --method POST
按路径子串 --path /users --path /pet
按标签 --tag users --tag Pet
关键词模糊搜索 --search "create" --search "用户登录"
排除已废弃接口 --exclude-deprecated
显示完整详情 --detail 展示参数与响应 Schema

多个过滤条件之间是「与(AND)」关系。示例:

python scripts/parse_openapi.py spec.yaml --method GET --tag users --search "profile"

4. 模糊搜索(--search)

--search 参数会在以下字段上做带相关性评分的模糊搜索:

  • 路径(/users/{id})
  • 摘要(summary,如 Get user by ID)
  • 描述(description,较长的说明文字)
  • operationId(如 getUserById)
  • 标签(tags,如 users)

结果按相关性评分排序,分数越高匹配越好。支持部分匹配、多词查询,以及中英文混合查询。

5. 查看接口详情

使用 --detail 展示每个接口的请求参数(名称、位置、类型、是否必填)与响应 Schema:

python scripts/parse_openapi.py spec.yaml --path /users/{id} --detail

6. JSON 格式输出

如需程序化处理或进一步分析,可输出为 JSON:

python scripts/parse_openapi.py spec.yaml --output json

7. 深层上下文分析

当用户需要详细 Schema 信息(嵌套对象、枚举等)时,可结合脚本输出,直接用 Read 工具读取规范文件,或使用 WebFetch 抓取,再在上下文中分析具体段落。

8. 本地缓存(避免重复下载)

远程 URL 会被缓存到系统临时目录(openapi_reader_cache/)。同一 URL 的重复调用会跳过重新下载。

自然语言触发词(用户意图 → 参数): 当用户说「强制刷新」「忽略缓存」「重新拉一下」「源更新了,再看一次」时,加上 --refresh;当用户说「TTL 设成 60 秒」「缓存 60 秒」「更频繁检查更新」时,加上 --cache-ttl 60。用户自己不需要输入这些参数,由你把意图翻译成对应参数。

失效策略 —— 如何保证始终读到最新规范:

  • 若服务器返回 ETag / Last-Modified,脚本每次都会发起条件请求:源未变时服务器返回 304(复用缓存),源已更新时返回 200 + 新内容。可精确检测源的变更。
  • 若服务器不返回校验器,则启用 TTL 兜底(默认 300 秒):TTL 内复用,过期后自动重新下载。
  • --refresh(-r)绕过缓存,立即强制重新下载。
  • --cache-ttl N 覆盖 TTL 秒数(如 --cache-ttl 60)。
  • 本地文件每次都直接读取(永远最新,不缓存)。

摘要行会显示缓存状态:已下载、缓存(TTL 有效)、缓存(已校验,未变更) 或 缓存(网络错误,使用旧副本)。

手动清理所有缓存:删除临时目录 openapi_reader_cache。

关键行为

  • 版本识别:自动识别 Swagger 2.0 与 OpenAPI 3.x,并统一处理路径、参数、服务器 URL。
  • 内联解析:对 Schema 标签做基础 $ref 解析;嵌套的 $ref 以标签形式展示,供用户手动追溯。
  • 每次运行先显示摘要:用户应在每次运行时看到标题、版本、来源与接口总数。
  • 中文支持:模糊搜索支持中文查询,如「用户」「登录」「订单」。

故障排查

问题 解决方案
提示「未安装 PyYAML」 脚本会自动安装;若自动安装失败,手动执行 python -m pip install pyyaml
提示「找不到文件」 检查路径;本地文件建议使用绝对路径
提示「无法解析规范」 确认 URL 可访问或文件是合法的 JSON/YAML
URL 获取超时 使用 --python 参数,或先用 WebFetch 下载
YAML 规范解析失败 确认当前 Python 环境已安装 PyYAML

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 支持本地文件与远程 URL 的 OpenAPI/Swagger 规范读取与解析
  • 覆盖 Swagger 2.0、OpenAPI 3.0/3.1 的 JSON 与 YAML 格式
  • 提供接口列表、过滤、模糊搜索、详情查看等完整功能闭环
Trigger Precision95/100

Highlights

  • 触发词覆盖全面,包含 OpenAPI、Swagger、API 文档、接口规范、常见文件名等关键词
  • 边界清晰,能有效匹配开发者查看 API 文档的核心意图
Structure and Standards90/100

Areas to improve

  • description 内容重复 Reported severity: Minor

    顶层 frontmatter 与 skill_body 内部均包含完整 description,存在冗余

    Recommendation: 建议保留一处,避免重复维护

Highlights

  • 文档结构清晰,包含快速开始、前置条件、工作流程、关键行为、故障排查等完整章节
  • 提供端到端示例与多种使用场景说明
Execution Reliability88/100

Highlights

  • 内置 parse_openapi.py 脚本,参数说明详尽,覆盖主要异常场景
  • 远程缓存具备 ETag/Last-Modified 校验与 TTL 兜底机制,保证数据新鲜度
  • 自动检测并安装 PyYAML 依赖,降低用户使用门槛
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 25, 123
Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • petstore3.swagger.io

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.