This skill should be used when the user asks to "infer schemas", "generate schemas from examples", "add schemas", "bootstrap schemas", or mentions inferring, generating, or adding schemas to OpenAPI/OAS specifications that have examples but missing schema definitions.
68
83%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
This skill automatically generates schemas from examples in OpenAPI Specification (OAS) files. It analyzes example and examples fields in requests and responses, then produces corresponding schema definitions.
Use this skill when:
examples or example fields but no schema definedpip install pyyamlpython3 skills/api-schema-inferrer/scripts/infer_schemas.py path/to/spec.yaml --dry-runThis shows what schemas would be added without modifying the file.
python3 skills/api-schema-inferrer/scripts/infer_schemas.py path/to/spec.yamlThis will:
spec.yaml.backup)example nested inside a schema: block up to the media-type level (the OAS-canonical sibling location)components.requestBodies and components.responsesSome toolchains (notably AMF) emit specs where example is nested inside schema::
content:
application/json:
schema:
example:
foo: barOAS 3.x defines example as a sibling of schema at the Media Type Object level. Tooling that follows the spec (including the portal generator in this repo) won't render schema-nested examples. The script automatically moves them so both the inferrer and downstream tooling can find them.
The tool:
string, number, integer, boolean, array, object, nullemail, uri, date formats from string patternsBefore:
paths:
/users:
post:
requestBody:
content:
application/json:
examples:
createUser:
value:
name: "John Doe"
email: "john@example.com"
age: 30
responses:
'200':
description: Success
content:
application/json:
example:
id: "123"
status: "active"After running inference:
paths:
/users:
post:
requestBody:
content:
application/json:
schema:
type: object
required: [name, email, age]
properties:
name:
type: string
description: "Auto-generated from example. TODO: Add meaningful description for 'name'"
email:
type: string
format: email
description: "Auto-generated from example. TODO: Add meaningful description for 'email'"
age:
type: integer
description: "Auto-generated from example. TODO: Add meaningful description for 'age'"
examples:
createUser:
value:
name: "John Doe"
email: "john@example.com"
age: 30
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
required: [id, status]
properties:
id:
type: string
description: "Auto-generated from example. TODO: Add meaningful description for 'id'"
status:
type: string
description: "Auto-generated from example. TODO: Add meaningful description for 'status'"
example:
id: "123"
status: "active"After running the inference tool:
enum arrayrequired array if some fields are optionalminLength, maxLength, minimum, maximum, etc. as neededAsk Claude to infer schemas:
"Infer schemas from examples in my API spec at path/to/spec.yaml"
"Generate schemas from the examples in specs/my-api.yaml"
"My spec has examples but no schemas - can you add them?"32e2b58
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.