Skip to main content

Import types into the type registry

Type import is complete. One call turns a JSON Schema 2020-12 document, an Apiome type-definition bundle or the components/schemas of an OpenAPI 3.1 description into reusable types in the type registry, on the Primitives REST API.

  • Three sources. source_kind is json-schema (each $defs entry becomes a type, or the whole document when it has none), type-def-bundle (each entry under types) or openapi (each entry under components/schemas). Every type is checked as a JSON Schema 2020-12 schema.
  • References stay intact. A reference that only works inside the source, such as #/$defs/Money or #/components/schemas/Money, is rewritten to a relative registry reference (./money), so imported types still point at each other. A string that only declares format: email, uuid, uri, date, date-time or time is pointed at the matching core type; set map_core_formats to false to leave it alone.
  • Review before you save. POST /v1/primitives/{tenant}/import/review is a dry run: each type comes back as new, identical or conflict, with its validation report and the rewrites that would be made. Nothing is saved.
  • Nothing is replaced silently. POST /v1/primitives/{tenant}/import skips identical types and keeps an existing type on a conflict, unless resolutions says overwrite or rename for it.
  • From anywhere. POST /v1/primitives/{tenant}/import/stage fetches and parses pasted text, a URL or a file in a public GitHub repository, as JSON or YAML, and lists the types it found.
  • A record of every import. GET /v1/primitives/{tenant}/imports lists past imports with what each one created, overwrote, renamed and skipped.

The same import is in the app: Build → Primitives & types → “Import from schema” — see Import types.