Skip to main content

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 and x- 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 $ref layout for the tool that reads it.

The lifecycle at a glance​

You want to…WhereDetails
Know what survives an import and an export, construct by constructHelp & docsOpenAPI construct matrix, OpenAPI exports
Validate a document against the schema for its versionOn import, and before every OpenAPI exportOpenAPI 3.2, 3.1, 3.0 and Swagger 2.0
Keep each schema's JSON Schema dialect across versionsOn import and exportSchema dialects
Use OpenAPI 3.2 constructs — QUERY and custom methods, the tag tree, streaming media types, in: querystringImport, the REST API, View spec on VersionsOpenAPI 3.2 in projects
Upgrade Swagger 2.0, 3.0 or 3.1 to a newer versionVersions → row menu → Upgrade OpenAPI version…, or apiome upgradeUpgrade a spec to a newer OpenAPI version
Change what a version exports with OpenAPI OverlaysVersions → OverlaysManage overlays in Versions
See external $refs and circular references, refresh and pin themVersions → ReferencesExternal references and cycles
Export bundled, dereferenced or split into filesExport dialog or Export studio → OpenAPI → $ref handling, or apiome export openapi --refsBundled, dereferenced or split into files

Versions side by side​

Swagger 2.0OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
ImportYesYesYesYes
Checked against its schemaSwagger 2.0 schemaOpenAPI 3.0 schemaOpenAPI 3.1 schema (3.1.0, 3.1.1, 3.1.2)OpenAPI 3.2 schema
ExportDowngradeDowngradeDefaultNewer
Upgrade to3.0, 3.1, 3.23.1, 3.23.2—
SchemasSwagger subsetOpenAPI 3.0 subset (nullable)JSON Schema 2020-12, or the declared dialectJSON 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​

  1. 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.
  2. Every document is checked against its own version. Import and export pick the official schema from the swagger or openapi field. A fault comes back with its location.
  3. 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.
  4. 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.
  5. References are watched, not trusted. The References tab fetches each external $ref under 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 $ref and 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​