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...
---
name: json-to-api
description: >
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.
license: MIT
metadata:
version: "1.0"
category: data
author: wangjipeng
sources:
- https://github.com/MiniMax-AI/skills
---
# 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:
```yaml
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 guidedon't have the plugin yet? install it then click "run inline in claude" again.
added explicit inputs section with json payload and intent as required parameters, expanded procedure into four numbered steps with discrete inputs/outputs, formalized decision points for json shape classification and mode selection, structured output contract with example yaml, and defined concrete outcome signals so user knows when the spec is correct.
---
name: json-to-api
description: design rest api endpoints from json data with openapi 3.0 spec
license: MIT
metadata:
version: "1.0"
category: data
author: wangjipeng
sources:
- https://github.com/MiniMax-AI/skills
---
# json-to-api
## intent
use this skill when a user provides json data and asks you to design a rest api contract around it. triggers include "create an api for this", "design an endpoint", "write the openapi spec", "make this a web api", or "what would the request/response schema look like". the skill produces endpoint definitions, http methods, status codes, and full openapi 3.0 schemas derived from the json structure, not implementation code or a running server.
## inputs
- **json payload** (required): pasted json, file path, or raw object. can be single object, array, nested structure, or flat key-value config.
- **user intent** (required): explicit request to design an api, create endpoints, or write a spec. without this, skill does not activate.
- **resource name preference** (optional): user-stated name for the primary resource (e.g., "call this 'users'"). if absent, infer from json keys.
- **mode flag** (optional): `/json-to-api` for base spec, or `/json-to-api/expand` for production features (pagination, filtering, sorting, sub-resources).
## procedure
**step 1: parse and classify the json structure**
input: raw json payload.
1. receive the json (validate it parses without syntax error).
2. classify the root data type:
- single object: likely a resource entity (e.g., `{id: 1, name: "alice"}`).
- array of objects: likely a collection (e.g., `[{id: 1, ...}, {id: 2, ...}]`).
- nested object: indicates sub-resources or embedded relationships (e.g., `{user: {id: 1, address: {street: "..."}}}`).
- flat key-value: configuration or state object (e.g., `{apikey: "...", timeout: 30}`).
3. identify candidate resources by examining top-level keys and nesting depth. mark each key as either a primary resource, sub-resource, or property.
4. infer field types: string, number, boolean, null, array, object. note which fields are always present vs. sometimes absent or null.
output: resource map (e.g., users, addresses, tags) and field inventory with types and optionality.
**step 2: design http endpoints and methods**
input: resource map from step 1.
1. for each primary resource, assign standard http verbs based on json shape:
- single object: `get /{resource}/{id}` (retrieve), `put /{resource}/{id}` (full replace), `patch /{resource}/{id}` (partial update), `delete /{resource}/{id}` (remove).
- array of objects: `get /{resource}` (list all), `post /{resource}` (create new).
- sub-resources (nested objects): `get /{resource}/{id}/{subresource}`, `patch /{resource}/{id}/{subresource}`.
2. use plural nouns for collection endpoints (`/users`, not `/user`).
3. do not invent endpoints not implied by the json structure.
4. assign standard http status codes: 200 (success), 201 (created), 204 (no content), 400 (bad request), 404 (not found), 500 (server error).
output: endpoint table (method, path, summary, expected body, expected response shape).
**step 3: build openapi 3.0 specification**
input: endpoint table and field inventory from steps 1 and 2.
1. initialize openapi 3.0 skeleton with title, version, and servers (if provided).
2. for each endpoint, add a path object with operationId, summary, parameters (query, path), requestBody (for post/put/patch), and responses.
3. for each resource, create a schema component:
- map json field names to openapi types (string, integer, number, boolean, array, object).
- mark required fields (fields always present in the json).
- mark optional fields with `nullable: true` or omit from required array.
- include `example` values copied directly from the provided json.
- use `format: date-time` for timestamp strings (if evident from value or user context).
4. for array responses, wrap items in a `data` envelope: `{data: [{...}, {...}]}` or `{data: [...], count: 2}`.
5. validate that every field in the original json appears in the schema.
output: complete openapi 3.0 yaml file, valid and renderable in swagger ui.
**step 4: validate and document**
input: openapi spec from step 3.
1. checklist:
- every json field is in the schema with correct type.
- http methods follow rest conventions (no get with request body, no put without body, etc.).
- status codes are standard, not arbitrary.
- endpoint paths and names are consistent in casing (plural collections, singular ids).
- schema property names are consistent (camelCase vs. snake_case matches json).
- examples in schema match provided json values exactly.
2. flag any deviations and correct them.
3. add brief description to each endpoint explaining its purpose.
output: validated openapi spec ready for delivery.
## decision points
**if user provides json AND explicit api design intent:**
activate skill and proceed through steps 1-4.
**else if user provides json but no api intent:**
clarify: "do you want me to design api endpoints for this json, or something else (transform, validate, document)?"
do not proceed with skill.
**if json is a single flat object (no nesting, no arrays):**
design a single resource with get/{resource}/{id}, put, patch, delete. do not invent collection endpoints.
**else if json is an array of objects:**
design list (get /{resource}) and create (post /{resource}) endpoints. include individual resource endpoints (get /{resource}/{id}, put, delete).
**if json has nested objects:**
decide: treat nested objects as sub-resources (separate endpoints) or as embedded properties (include in parent schema). default to sub-resources if nesting is 2+ levels deep or if user mentions "relationship" or "association".
**if user requests `/json-to-api/expand` mode:**
add pagination (limit, offset, or cursor), filtering (query params per field), sorting (sort param), and explicit sub-resource endpoints. include query param schemas in the spec.
**if json has nullable or optional fields:**
mark them as not required in schema. set `nullable: true` if field appears in json as null.
**if json has timestamp or date fields (iso8601 strings or unix integers):**
use `format: date-time` or `format: date` in schema, not generic string type.
**if user has not stated a primary resource name:**
infer from json top-level keys or context. if ambiguous, ask user: "should the primary resource be called 'users' or 'accounts'?"
**if json contains authentication tokens, passwords, or secrets:**
flag them as sensitive in the schema documentation. recommend not including in example; suggest `format: password` for schema clarity.
**if json payload is malformed or does not parse:**
stop and report syntax error with line number. do not guess or auto-correct.
## output contract
deliverable: one valid openapi 3.0 specification in yaml format.
structure:
- openapi 3.0.0 header with info object (title, version, description).
- servers array (empty if no base url provided; user can add later).
- paths object with one entry per endpoint (get, post, put, patch, delete).
- components.schemas object with all resource schema definitions.
- each schema includes type, required array, properties (with types, examples, descriptions), and additionalProperties: false (strict).
file location: return as yaml code block in response, labeled "openapi-spec.yaml". if user requests file, save to local path or provide download link.
example structure (abbreviated):
```yaml
openapi: 3.0.0
info:
title: Users API
version: 1.0.0
paths:
/users:
get:
operationId: listUsers
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/UserList'
post:
operationId: createUser
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserInput'
responses:
'201':
description: Created
/users/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: integer
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
required:
- id
- name
properties:
id:
type: integer
example: 1
name:
type: string
example: "Alice"
additionalProperties: false
UserList:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/User'
count:
type: integer
example: 2
validation: spec must be parseable as yaml, must pass openapi 3.0.0 schema validation, and must render without errors in swagger ui or redoc.
user knows the skill worked when:
/users), parameterized resource endpoints (/users/{id}), nested sub-resources if applicable.if any of these signals is absent, the skill output is incomplete or incorrect. ask user for clarification or re-run step 4 (validate).
original author: wangjipeng (github.com/MiniMax-AI/skills)
credits: this enriched version adds explicit decision logic, edge case handling (malformed json, authentication fields, timestamp inference), expanded validation rules, and detailed outcome signals per implexa standards. ```