← 返回 Skills 市场
wangjipeng977

Json To Api

作者 王继鹏 · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
152
总下载
1
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install json-to-api
功能描述
Use when (1) user provides JSON data and asks to design a REST API endpoint around it. (2) user says "create an API for this", "design an endpoint", "write t...
使用说明 (SKILL.md)

JSON to API

Use when (1) user provides JSON data and asks to design a REST API endpoint around it. (2) user says "create an API for this", "design an endpoint", "write the OpenAPI spec for this JSON", or "make this a web API". (3) user pastes a JSON payload and wants the corresponding request/response schema.

Core Position

This skill solves the specific problem of: raw JSON data needs a proper API contract — endpoints, HTTP methods, status codes, and schemas — not just a data dump.

This skill IS NOT:

  • A data transformation tool — it designs the interface, not the implementation
  • A backend code generator — it produces specs, not runnable server code
  • An API client — it designs the server-side contract

This skill IS activated ONLY when: JSON data + API design intent are both present.

Modes

/json-to-api

Default mode. Designs REST API endpoints from JSON data with full OpenAPI 3.0 spec.

When to use: User provides JSON and wants endpoint design, HTTP methods, and request/response schemas.

/json-to-api/expand

Adds pagination, filtering, sorting, and embedded resource support to the base design.

When to use: The JSON represents a collection and user wants a production-grade API surface.

Execution Steps

Step 1 — Analyze the JSON Structure

  1. Receive JSON (pasted, file, or path)
  2. Detect data type:
    • Single object: likely a resource with GET (one), PUT/PATCH (update), DELETE
    • Array of objects: likely a collection with GET (list), POST (create)
    • Nested object: indicates sub-resources or embedded entities
    • Flat key-value: simple configuration or state object
  3. Identify resource candidates:
    • Top-level keys become resource names
    • Nested objects become sub-resources
    • Arrays become collection endpoints
  4. Infer data types for each field: string, number, boolean, null, array, object

Step 2 — Design API Surface

Determine resources and endpoints:

JSON Shape HTTP Method Endpoint
Single object GET GET /{resource}/{id}
Array of objects GET (list), POST (create) GET /{resource}, POST /{resource}
Nested resource GET GET /{resource}/{id}/{sub-resource}
Object with ID field PUT, PATCH, DELETE PUT /{resource}/{id}

Step 3 — Write OpenAPI 3.0 Schema

Generate the full OpenAPI spec:

openapi: 3.0.0
info:
  title: Resource API
  version: 1.0.0
paths:
  /resources:
    get:
      summary: List all resources
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Resource'

For each schema field:

  • Map JSON types to OpenAPI types
  • Mark required fields (non-nullable, must be present)
  • Add example values from the provided JSON

Step 4 — Validate

  • All JSON fields are represented in the schema
  • HTTP methods are appropriate for the resource type
  • Status codes are standard (200, 201, 400, 404, 500)
  • No invented endpoints not implied by the JSON structure

Mandatory Rules

Do not

  • Do not invent API endpoints not implied by the JSON structure
  • Do not set arbitrary status codes (use standard REST conventions)
  • Do not add authentication schemes not mentioned by the user
  • Do not assume database schema — design the API surface only

Do

  • Use plural nouns for collection endpoints (/users, not /user)
  • Map JSON field names to camelCase in the schema
  • Include the provided JSON as an example in the schema
  • Follow REST conventions: GET (no body), POST/PUT/PATCH (JSON body), DELETE (no body)

Quality Bar

A good output:

  • Every field in the JSON appears in the schema with correct type
  • HTTP methods and endpoints match JSON structure
  • OpenAPI spec is valid YAML and renderable in Swagger UI
  • Examples in schema match the provided JSON values

A bad output:

  • Missing fields from the original JSON
  • Wrong HTTP method for the operation (GET with body)
  • Non-standard status codes (201 for GET, 200 for DELETE)
  • camelCase/snake_case inconsistency in field naming

Good vs. Bad Examples

Scenario Bad Output Good Output
Array of users GET /user (singular) GET /users (plural)
Nested address object Flattened into user object GET /users/{id}/addresses as sub-resource
Optional phone field Marked as required Marked optional with nullable: true
Created timestamp Number type String with format: date-time

References

  • references/ — OpenAPI 3.0 schema templates, HTTP method conventions, status code guide
安全使用建议
Do not treat this as a completed security clearance; rerun the review with readable metadata.json and artifact files before installing or publishing the skill.
能力评估
Purpose & Capability
Unable to assess purpose-to-capability coherence because every local file-read command failed before shell execution.
Instruction Scope
Unable to inspect SKILL.md or runtime instructions, so no artifact-backed scope concern can be reported.
Install Mechanism
Unable to inspect metadata or install artifacts; no evidence-backed install risk can be confirmed.
Credentials
Unable to verify requested environment access against artifact contents.
Persistence & Privilege
Unable to inspect artifacts for persistence, credentials, or privilege behavior.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install json-to-api
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /json-to-api 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
Update README with real Features and 功能特性 content
v1.0.0
Initial release
元数据
Slug json-to-api
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Json To Api 是什么?

Use when (1) user provides JSON data and asks to design a REST API endpoint around it. (2) user says "create an API for this", "design an endpoint", "write t... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 152 次。

如何安装 Json To Api?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install json-to-api」即可一键安装,无需额外配置。

Json To Api 是免费的吗?

是的,Json To Api 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Json To Api 支持哪些平台?

Json To Api 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Json To Api?

由 王继鹏(@wangjipeng977)开发并维护,当前版本 v1.0.1。

💬 留言讨论