schema.rules.json
Path: apis/<api>/schema.rules.json
The schema mapper turns spec operations into resources and operations using auto-detection heuristics plus the user rules in this file. Rules are re-applied on every import, so your mapping survives spec changes; rules that no longer match anything are reported as orphans in the import diff.
Example
{
"version": 1,
"rules": [
{
"id": "4cea2bab-29d7-4741-a3cf-c397d0d4d246",
"type": "remap",
"match": { "operationId": "updatePetWithForm" },
"assignTo": { "resource": "Pet", "operation": "updateWithForm" },
"createdAt": "2026-05-10T17:51:51.637Z"
}
]
}
Fields
| Field | Type | Description |
|---|---|---|
version | 1 | File format version. |
rules | array | The ordered list of rules. |
Every rule shares three fields: id (a UUID, unique in the file), type, and createdAt
(ISO 8601). The rest depends on type.
Rule types
remap
Assign a spec operation to a resource and operation name.
{ "type": "remap", "match": { "operationId": "updatePetWithForm" }, "assignTo": { "resource": "Pet", "operation": "updateWithForm" } }
match accepts any of operationId, path, method.
rename
Rename a mapped operation or a resource. target selects which.
{ "type": "rename", "target": "operation", "match": { "operationId": "findPetsByStatus" }, "renameTo": "findByStatus" }
{ "type": "rename", "target": "resource", "match": { "name": "pet" }, "renameTo": "Pet" }
setParent
Set (or clear) a resource's parent. parent: null clears it.
{ "type": "setParent", "match": { "name": "order" }, "parent": { "resource": "store" } }
ignore
Drop an operation from the effective schema.
{ "type": "ignore", "match": { "operationId": "uploadFile" } }
define
Declare a locally-defined resource/operation that isn't in the spec. This rule holds only the
organizational info (which resource, what name); the full definition lives in
_resource.json.
{ "type": "define", "resource": "Pet", "name": "vaccinations" }
Notes
- Rules are normally created through the CLI (
craftr schema map,rename,set-parent,ignore,define) or the app; you rarely write this file by hand. - On re-import, a rule whose
matchno longer resolves is flagged as an orphan rule in the diff, where you choose to keep, remove, or remap it. See Importing a spec.