Skip to main content

Import an API Blueprint

The API Blueprint importer (apiblueprint) reads an API Blueprint document (.apib, or any file with a FORMAT: 1A line) into the Catalog. API Blueprint is no longer actively developed; once the API is cataloged you can version, diff and lint it, and move it to OpenAPI.

When to use it​

Use the API Blueprint importer for an existing Format 1A blueprint: Markdown with MSON data structures, in one file. The format's repository was archived in November 2024, so bring the blueprint in to catalog, lint and diff what you have, then move it to OpenAPI for new work.

At a glance​

StepWhereDetails
Import an .apib file, or a blueprint saved as .mdImport to catalog → API Blueprint, or apiome import apiblueprintImport it
See what the blueprint became: groups, actions, MSON typesThe catalog itemWhat the catalog item holds
Check it with drafter, the reference parserAutomatic on every import; warnings show in lintWhat drafter adds
Lint itThe apiblueprint lint packLint rules
Migrate to an OpenAPI 3.1 projectConvert to OpenAPI Project on the catalog item, or apiome convert --to openapiMove to OpenAPI
Export back to API BlueprintExport on the catalog itemAPI Blueprint from any source

Import it​

Import the blueprint like any other catalog format: in the import wizard (Import to catalog → API Blueprint), over the REST API (see Import a specification), or from the CLI:

apiome import apiblueprint ./shelter.apib
apiome import apiblueprint ./notes.md

A blueprint saved as Markdown (.md) imports too: its FORMAT: 1A line is what marks it as API Blueprint. Apiome's own reader builds the catalog item, so it imports the same way on every server.

The CLI's test fixtures, in apiome-cli/tests/fixtures/, are a quick way to try it: shelter-apiblueprint.apib (groups, a named request, response headers, MSON inheritance and a mixin) and notes-apiblueprint.md (a minimal blueprint saved as Markdown).

What the catalog item holds​

API BlueprintCatalog item
# Group PetsThe tag of every action in the group (apib_group)
A resource and its actions (## Pets [/pets], ### List pets [GET])One operation per action, with the action's own URI when it gives one
+ Parameters, and a URI template's query ({?status,limit})Path and query parameters, with each + Default: value
+ Members under an enum[…] parameter or memberThe allowed values
The first + Request of an action, named or not (+ Request Minimal (application/json))The request body, its media type and its + Headers
Each + Response 200 (…)A response with that status, its body and its + Headers
+ Attributes (Pet), + Attributes (array[Pet])The body's type
An inline + Attributes body (members, no named type)A type of its own, named after the action: Get owner 200 Response (apib_inline)
# Data Structures, ## Pet (object)A type with one field per member; a name may contain spaces (## Owner Summary (object))
## Cat (Pet)A type with Pet's members, then its own (apib_base)
+ Include ProblemThe members of Problem added to the type (apib_includes)
A member typed object with deeper membersA nested type, named after its parent: Pet.address
required, optional, nullableWhether the field is required, and whether it may be null

A member named again in a subtype or after an + Include replaces the inherited one. An action's further requests (+ Request Invalid) are other transactions: their responses are kept, but only the first request is the operation's body.

Exporting the item back to API Blueprint writes ## Cat (Pet) and + Include lines again, with the inherited members restated under them. A type whose name has spaces or dots is written with underscores (Owner_Summary), because the export keeps names to letters, digits and _.

What drafter adds​

The Apiome server ships drafter 4.0.0, the reference API Blueprint parser. Every import also runs the blueprint through it, once, and keeps two things from its answer, the API Elements (Refract) parse result:

  • Its warnings and errors, as lint findings of the apiblueprint pack (see Lint rules). Zero warnings is a good blueprint.

  • A hash of the API it describes, taken over drafter's element tree with everything that is not the API's contract removed:

    Left outBecause
    Prose between sections, and every descriptionRewording is not a contract change
    The headings of groups, resources, actions and transactionsRenaming a heading is not either
    Example request and response bodies, and MSON sample valuesExamples illustrate the contract
    drafter's warnings, and source positionsThey describe the text, not the API

    Body schemas, resources and their URI templates, methods, parameters and their types, status codes, headers and data structures stay in, so changing any of them changes the hash.

The catalog item records:

KeyHolds
apib_refract_sha256The hash, which is also the item's format hash
apib_refract_algorithmsha256-refract-contract-v1
apib_drafter_versionThe drafter release that produced the tree: 4.0.0

The parse result itself is kept with the item's source. Whether a new catalog version is created is still decided by the catalog's own fingerprint, so the same blueprint gets the same version on a server with drafter and on one without.

Without drafter​

drafter is optional. On a server without it, the blueprint still imports, read by Apiome's reader; the item has no drafter findings and none of the keys above.

Move to OpenAPI​

API Blueprint is no longer actively developed. Once the API is in the catalog, convert it to an OpenAPI 3.1 project. Converting the item is the migration; there is no separate migrator.

  1. On the Catalog, open the API Blueprint item and click “Convert to OpenAPI Project”.
  2. Review the preview: the API Blueprint conversion pack converts each resource and action directly, at an expected tier of high.
  3. Confirm to create the OpenAPI project.

From the CLI, preview first, then convert:

apiome convert <item-id> --to openapi --dry-run --out openapi.json
apiome convert <item-id> --to openapi

The dry-run names the pack that produced the document and what API Blueprint is known to lose:

Conversion pack: API Blueprint (native projection).
- Known loss: Example transactions are not carried over as OpenAPI examples.

Groups become the operations' tags, and request and response headers, data structures and their inheritance come across from the catalog item (see What the catalog item holds). The conversion is Apiome's own (see Per-format conversion packs).