Communitygithub.com

shuangying0001-beep/parse-api-doc

接口文档转字段映射(ERP/OpenAPI 一键结构化):把 API 文档解析成字段名/类型/必填/端点,直接出映射。适合对接第三方、低代码搭建。

parse-api-doc 是什么?

parse-api-doc is a Claude Code agent skill that 接口文档转字段映射(ERP/OpenAPI 一键结构化):把 API 文档解析成字段名/类型/必填/端点,直接出映射。适合对接第三方、低代码搭建。.

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add shuangying0001-beep/parse-api-doc

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

parse-api-doc — Intelligent API Document Field Parser

Parse any format of API/field documentation into a structured field list + field mapping, used for integrating third-party systems. Pure function implementation (Node ESM, zero dependencies), can be directly imported, and serves as a reference implementation for AI-driven field extraction.

Use Cases

  • When you receive API documentation from an ERP / open platform / internal middleware and need to quickly know "what fields exist, their types, and which are required"
  • When you need to map fields from an external document to your own collection/storage fields (fuzzy matching aliases for inconsistent field names)
  • When extracting fields in batch from Markdown tables, JSON Schema, sample JSON, or plain-text field lists

Supported Input Formats (Auto-Detected)

  1. Markdown table: | Field | Type | Required | Description |
  2. JSON Schema: Contains "properties" + "type"
  3. Sample JSON: { "asin": "B0XXX", "title": "Title" }
  4. Plain-text field list: asin: Product ID / title (string) Product Title

Usage

import { parseErpDocument, matchField, loadVocabulary } from './scripts/doc-parser.mjs';

const doc = `
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| asin | string | Yes | Product ID |
| title | string | No | Product Title |
`;

const result = parseErpDocument(doc);
console.log(result.detectedFormat);   // markdown_table
console.log(result.productFields);    // [{name,type,required,description}]
console.log(result.fieldMappings);    // [{erpField,erpType,erpRequired,erpDescription,collectorField}]
console.log(result.endpoint);         // Automatically inferred method+path

Core API

  • parseErpDocument(content, options?) → DocParseResult
    • options.vocabulary: Custom field vocabulary (default includes a common set of e-commerce/API fields; inject your own)
    • Returns: { success, detectedFormat, productFields[], endpoint, requestStructure, responseStructure, fieldMappings[], error? }
  • matchField(name, vocabulary?) → Matched standard field key (fuzzy/alias matching, normalized case and _-)
  • loadVocabulary(text) → Build a vocabulary from text (for ad-hoc extension)

Field Mapping Vocabulary (Injectable)

The default vocabulary covers common fields (asin/title/price/rating/bsr/image/brand...). When integrating with your own system, pass your custom vocabulary:

const myVocab = [
  { key: 'sku', aliases: ['sku', '货号', 'SKU'] },
  { key: 'stock', aliases: ['stock', '库存', 'quantity'] },
];
parseErpDocument(doc, { vocabulary: myVocab });

Notes

  • On parse failure, success=false and an error.code is provided (EMPTY_CONTENT / PARSE_ERROR / NO_FIELDS_FOUND), along with error.suggestion offering targeted fix advice.
  • This is a structure extraction tool; it does not make network calls or send any data—purely local parsing.

相关技能