Skip to content

Portable Schema

Human reviewed 2026-11-30

Portable Schema is how a structure is written down and served. It is JSON Schema 2020-12, the dialect core's serialization module already writes, plus a small agreed set of extension keywords and fixed rules where the standard leaves a choice. It is a library by fago, with validators in PHP and JavaScript that give the same answers on one set of test fixtures.

A served contract

A client that wants to send a valid write should learn the rules before it sends, not by being refused. Today core's serialization module describes what a normalizer outputs, and nothing describes what an operation on a config object or an entity accepts. Each operation serves a schema of what it accepts, composed from the keys its module declares and the ones that are read. A Tool API tool, a headless form and the OpenAPI document then read the same schema.

Portable Schema one schema per operation, of the input it accepts Operation permission checks storage Generated form the elements it draws Tool API tool its input schema HTTP endpoint its OpenAPI document Drush the input it accepts describes runs
Each way in reads the same schema, and each runs the same operation, with the same permission and checks.

As an example, these are two keys in the document for saving core's site information settings, whose PHP is on Structures. They are plain JSON Schema with one extension keyword, portable-check, naming a constraint the server also runs:

"mail": {
  "title": "Email address",
  "description": "The From address in automated emails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this email being flagged as spam.)",
  "type": "string",
  "format": "email",
  "portable-check": {
    "drupal:Email": {}
  }
},
"page": {
  "title": "Pages",
  "type": "object",
  "properties": {
    "front": {
      "title": "Default front page",
      "description": "Specify a relative URL to display as the front page.",
      "type": "string",
      "pattern": "^/",
      "default": "/user/login",
      "portable-check": {
        "drupal:ValidPath": {}
      }
    },
    "403": {
      "title": "Default 403 (access denied) page",
      "description": "This page is displayed when the requested document is denied to the current user. Leave blank to display a generic \"access denied\" page.",
      "type": ["string", "null"],
      "pattern": "^/",
      "portable-check": {
        "drupal:ValidPath": {}
      }
    },
    "404": {
      "title": "Default 404 (not found) page",
      "description": "This page is displayed when no other content matches the requested document. Leave blank to display a generic \"page not found\" page.",
      "type": ["string", "null"],
      "pattern": "^/",
      "portable-check": {
        "drupal:ValidPath": {}
      }
    }
  },
  "additionalProperties": false,
  "required": ["front"]
}

The served contract is never stricter than the validation that judges the write: what validation accepts, the schema accepts. Where a rule cannot be stated as a keyword, the schema stays wider and names the rule for the server to check. Tests run each example's accepted and refused values through validation and through a standard JSON Schema validator.

Core's constraints in the document

Core's constraint plugins stay. Each lands in the document in one of four ways, so a client knows which checks it can run itself and which only the server runs:

Kind Core's constraints In the document
Converts to a keyword Range, Length, Count, NotBlank, Regex, UniqueItems, Choice minimum and maximum, minLength and maxLength, minItems and maxItems, pattern, uniqueItems, and oneOf with each choice's label. A client checks these itself.
A keyword and a server check Email, Uuid format, with the constraint also named under portable-check, since the format admits values the constraint refuses
Runs only on the server ValidPath, a reference that must name an existing entity, a check written in code Named under portable-check with its options. The client knows the check exists and the server runs it.
Deferred A list from the site too long to write out, such as the entities to choose from Left out and marked deferred, with an x-portable-links link where a client fetches the list

Where a keyword says the same as a constraint, such as maxLength for Length or pattern for Regex, declare the keyword: any JSON Schema validator runs it, and a drupal: check is left for rules only the server can judge.

Extension keywords

Plain JSON Schema keywords come first. Most of what core's definitions cannot say today has a standard keyword that core's output does not use yet: maxLength, default, if/then for a rule between keys, writeOnly for a secret. A generic validator reads all of them. A small set needs extension keywords:

What it is for Keyword
A rule only the server can check, such as a constraint with no standard keyword, and its message portable-check, x-portable-messages
A group of keys chosen by another key's value portable-typeBy
Hints for drawing a form: widget, placeholder, grouping, weight. Written only when a caller asks, so the contract names no widget x-portable-ui
Where to ask the server for what the document leaves out, such as an entity lookup x-portable-links

TBD

Which dialect core adopts, and how its validators relate to the one core uses for component props, is an open question.


Portable Schema is part of the foundation of the path into core.