OpenAPI in Apiome
Apiome reads and writes OpenAPI 3.2, 3.1 (3.1.0, 3.1.1 and 3.1.2) and 3.0, and Swagger 2.0. A document you import keeps every construct it was written with. Each document is checked against the official schema for its own version. You can upgrade a version to a newer OpenAPI version, change what it exports with overlays, and see what it pulls in from other addresses. Exports can be written at any version, bundled, dereferenced or split into files, with a report of anything the target version cannot hold.
Each part has its own page. This page shows how they fit together.
When to use it
- OpenAPI is your source of truth. An item imported from OpenAPI and exported at the same
version comes back as it was read, callbacks, webhooks,
discriminator, examples andx-extensions included. Nothing is dropped without being reported. - You hold older specs. A Swagger 2.0 or OpenAPI 3.0 document can be moved to 3.1 or 3.2 with every change listed before anything is written. The upgraded document becomes a new version, so the original stays as it is.
- Different readers need different documents. Overlays give partners or a public portal their
own descriptions and servers, and each export picks its version and
$reflayout for the tool that reads it.
The lifecycle at a glance
| You want to… | Where | Details |
|---|---|---|
| Know what survives an import and an export, construct by construct | Help & docs | OpenAPI construct matrix, OpenAPI exports |
| Validate a document against the schema for its version | On import, and before every OpenAPI export | OpenAPI 3.2, 3.1, 3.0 and Swagger 2.0 |
| Keep each schema's JSON Schema dialect across versions | On import and export | Schema dialects |
Use OpenAPI 3.2 constructs — QUERY and custom methods, the tag tree, streaming media types, in: querystring | Import, the REST API, View spec on Versions | OpenAPI 3.2 in projects |
| Upgrade Swagger 2.0, 3.0 or 3.1 to a newer version | Versions → row menu → Upgrade OpenAPI version…, or apiome upgrade | Upgrade a spec to a newer OpenAPI version |
| Change what a version exports with OpenAPI Overlays | Versions → Overlays | Manage overlays in Versions |
See external $refs and circular references, refresh and pin them | Versions → References | External references and cycles |
| Export bundled, dereferenced or split into files | Export dialog or Export studio → OpenAPI → $ref handling, or apiome export openapi --refs | Bundled, dereferenced or split into files |
Versions side by side
| Swagger 2.0 | OpenAPI 3.0 | OpenAPI 3.1 | OpenAPI 3.2 | |
|---|---|---|---|---|
| Import | Yes | Yes | Yes | Yes |
| Checked against its schema | Swagger 2.0 schema | OpenAPI 3.0 schema | OpenAPI 3.1 schema (3.1.0, 3.1.1, 3.1.2) | OpenAPI 3.2 schema |
| Export | Downgrade | Downgrade | Default | Newer |
| Upgrade to | 3.0, 3.1, 3.2 | 3.1, 3.2 | 3.2 | — |
| Schemas | Swagger subset | OpenAPI 3.0 subset (nullable) | JSON Schema 2020-12, or the declared dialect | JSON Schema 2020-12, or the declared dialect |
A document whose version has no schema to check against is reported as not validated, never as valid.
How the pieces fit
- Import keeps a copy of what it read. Each operation, schema and the document's other parts are stored as written, alongside the model Apiome builds from them, with the JSON Schema dialect each schema uses. The copy is what lets an unedited operation or schema be written back unchanged.
- Every document is checked against its own version. Import and export pick the official
schema from the
swaggeroropenapifield. A fault comes back with its location. - An export is written at the version you pick. At the same version, the stored copy is written back. At an older version, each construct that version cannot hold is dropped and listed in the fidelity report. At a newer version, schemas are rewritten into JSON Schema 2020-12 and each rewrite is listed. An operation or schema you edited is written from its current model, and the report names it.
- Upgrades and overlays add versions; they never overwrite. Upgrade OpenAPI version… and Apply as version on the Overlays tab both import the new document as a new version of the same project, through the same import checks. The version you started from is kept.
- References are watched, not trusted. The References tab fetches each external
$refunder your tenant's external reference policy, and compares it with the last fetch or the pinned copy. It lists every circular reference. Dereferenced exports keep a cycle as a$refand report it, or refuse the export if you choose error.
From the command line
apiome export openapi --project payments-api --version 1.4.0 --output openapi.json
apiome export openapi --project payments-api --version 1.4.0 --refs split --output openapi.zip
apiome export openapi --project payments-api --version 1.4.0 --refs dereference --ref-cycles error \
--output openapi.json # refuse a circular $ref
apiome export openapi --project payments-api --version 1.4.0 --overlay public.yaml --output public.json
apiome upgrade petstore-swagger.yaml --to 3.2 --output petstore.yaml # plan and write a local upgrade
apiome upgrade --project payments-api --version 1.4.0 --to 3.2 --apply --version-label 2.0.0
See apiome export and apiome upgrade
in the CLI reference.
Where next
- OpenAPI construct matrix — every construct and version, measured on the OpenAPI Initiative's test documents
- Export a spec → OpenAPI
- OpenAPI Overlays — the Overlay 1.0, 1.1 and 1.2 actions
- Arazzo in Apiome — workflows that call your OpenAPI operations