OpenAPI Overlays
An OpenAPI Overlay is a small document that changes a base OpenAPI description without editing
it: add a production server, hide an internal path, rewrite descriptions for a public audience. Each
overlay lists actions, and each action picks parts of the base with a JSONPath target and
updates, copies or removes them. Apiome applies the overlays to the base before it reads the API,
and records which overlay changed each value. You can also apply overlays when you export,
so one version ships with partner-specific servers or descriptions without a fork, and
store a chain of overlays on a version so every export and publish uses it.
Supported revisions
The overlay field at the top of the document says which revision it is written for. Apiome reads
the first two numbers (1.1.0 and 1.1.3 are both 1.1):
| Revision | What it can do |
|---|---|
| 1.0 | target, update and remove. An update on a list adds one entry. |
| 1.1 | Adds copy (take one part of the document and merge it somewhere else) and changing a single value. Lists are joined when merged. |
| 1.2 | Adds reusable actions (components.actions, used with $ref) and $self, the overlay's own address. |
An overlay that declares any other revision, such as overlay: 1.3.0, is refused with the message
Apiome reads Overlay 1.0, 1.1 and 1.2. It is not applied with rules it was not written for.
Import a base with its overlays
An overlay only makes sense next to its base, so import them together:
- Put the base OpenAPI document and its overlays in one
.ziparchive. Tryapiome-ui/examples/openapi/36-overlay-1-1-set/(a base and an Overlay 1.1 document). - Import the archive, with the base document as the archive's root.
The fileset rule:
- The archive must hold exactly one base document (a file with an
openapiorswaggerfield). Any number of overlays can sit beside it, and other files are left alone. - Overlays are applied in file-name order, each to the result of the one before, so the last overlay wins any conflict.
- An overlay uploaded without its base is refused with
INPUT_OVERLAY_BASE_MISSING. You can still lint it on its own.
Pre-flight (POST /v1/tenants/{tenant}/import/preflight, and the Quality step of the import
wizard; see Import a specification) applies
the overlays and reports their findings next to the API's own. The import preview lists each value
an overlay set, replaced, appended or removed.
Overlay rules
Overlay problems are lint findings in the overlay rule pack, so a style guide can raise any of them to an error:
| Rule | Default | Flags |
|---|---|---|
overlay.unmatched-target | warning | An action whose target matches nothing in the base, so it changed nothing |
overlay.action-invalid | warning | An action that cannot be applied as written for its revision |
overlay.target-expression-invalid | warning | A target or copy that is not a valid JSONPath expression |
overlay.extends-unresolved | warning | An extends that names a different document from the base it was applied to |
overlay.version-unsupported | error | An overlay revision Apiome does not read |
These replace the earlier intake.overlay-unmatched-target and intake.overlay-action-invalid
rules. A style guide that set those ids should set the overlay.* ones instead.
Apply overlays on export
Overlays also work on the way out: the version stays as it is, and the exported document gets
the overlay's changes. Use this to publish the same API with a partner's servers, descriptions or
x- extensions.
- Export studio: the Overlays step. Click “Add overlay files”, pick one or more overlay files, and set their order. See Export studio.
- CLI:
apiome export openapi … --overlay partner.yamlorapiome export <format> <item> --out … --overlay partner.yaml. Repeat--overlayto apply several, in the order given. - REST:
overlays: [{name, document}]onPOST /v1/export/{tenant}/jobsand onPOST /v1/export/{tenant}/verify.
The overlays apply to the version's OpenAPI document before anything else runs. The fidelity
report, the validation, the export quality policy and the file you download all describe the
overlaid document. The export lists every value an overlay changed (see
Understand export fidelity), and an action whose target
matches nothing is an overlay.unmatched-target finding. It is never skipped silently.
Overlays modify OpenAPI documents, so a version imported from another format (GraphQL, Protobuf,
…) is refused with OVERLAY_SOURCE_UNSUPPORTED. An overlay Apiome cannot read (for example
overlay: 1.3.0) is refused with OVERLAY_INVALID.
Stored overlay chains
A version can keep its own ordered chain of overlays — the place for curation that must not change the source: accepted agent descriptions, Export Studio tweaks, lint fixes you would rather keep out of the repository. The chain applies only when the version is exported or published. The version's model, the Studio, lint, diff and SDK generation never see it.
Where chains come from:
| Source | How it gets there |
|---|---|
| Uploaded | The version's Overlays tab: click “Upload overlay”, or click “New overlay” to write one in the app. |
| Export Studio | The Overlays step's save button next to an uploaded file. See Export studio. |
| Agent enrichment | Agent access → Save as overlay copies a toolset's accepted descriptions. See Agent access. |
| Lint fix | Accepted by the API (source: lint-fix) for saved fix plans. |
The rules:
- Order. Stored overlays apply first, top down, then any overlays an export adds. A chain holds at most 10 overlays, and stored plus added overlays share that limit.
- Write-once. An overlay is never edited in place. Replacing one removes it and adds the new
document at the same place, as one audit event (
version.overlay_replaced). Each overlay carries asha256:fingerprint of its document. - Drafts only. A published version's chain is read-only; a change is refused with
409 overlay-version-published. - Exports apply it. Every export and Verify of the version applies its chain unless you switch
Apply stored overlays off (REST:
apply_stored_overlays: false). In the ledger, a stored overlay is namedstored:<name>. - Publishing records it. When a version with a chain is published, Apiome renders it and
records the source document's fingerprint beside the resolved document's, with any findings.
The schema download (
GET /v1/schema/…) is not changed by the chain. - Nothing goes silent. If a Studio edit removes what an overlay targets, the next render reports
overlay.unmatched-targetinstead of skipping it. - Apply as a version. The chain can become part of a new version: the rendered document is
imported through the import quality gate (
POST …/overlays/apply), and the new version starts with an empty chain. See Manage overlays in Versions.
Preview on the Overlays tab renders the chain exactly as an export does — the same code — so what it shows is what the export gets.
With the API:
GET /v1/versions/{tenant}/{project}/{version}/overlays # the chain + publish render
POST /v1/versions/{tenant}/{project}/{version}/overlays # {name, source, document, position?}
PUT /v1/versions/{tenant}/{project}/{version}/overlays/{id} # replace in place
DELETE /v1/versions/{tenant}/{project}/{version}/overlays/{id}
GET /v1/versions/{tenant}/{project}/{version}/overlays/preview # resolved document + ledger
Reading needs permission to view versions; changing the chain needs permission to edit them. See the Versions reference.
Lint an overlay on its own
You can check an overlay without its base:
POST /v1/lint/overlay
Content-Type: application/json
{ "document": "overlay: 1.1.0\ninfo: …\nactions: …", "filename": "public.yaml" }
The answer lists the findings and a status for every overlay rule: passed, failed or
skipped. The two rules that need the base, overlay.unmatched-target and
overlay.extends-unresolved, are always skipped with reason no-base. They are never reported
as passed. See the Lint reference.
Where next
- Import a specification: the import wizard and pre-flight
- Export studio: apply overlays when you export
- Versions: a version's stored overlay chain
- Supported formats: the Overlay row in the version table
- Built-in lint rules: every rule, including the overlay pack