Skip to content

@mitre/hdf-openapi ​

OpenAPI 3.1 components for the Heimdall Data Format, generated from the HDF JSON Schema 2020-12 bundles.

Status: this package publishes the schema components document, hdf-components.oas.json, and problems.json — the documentation for every RFC 9457 problem type the HDF taxonomy defines.

The reference API document moved to hdf-data-platform on 2026-10-13 and is no longer built here. It was generated from the HDF MCP server's tool contract; it is now written there as route declarations with the document generated from them. If you are looking for the API's OpenAPI document, it is published by that repository, not this one.

The MCP-to-API parity check went with it. Do not rebuild it — a parity check between a source and its derivative cannot survive the removal of the derivation, and what replaced the guarantee is still open. The record is The withdrawn MCP-to-API parity check.

Why this exists ​

HDF publishes eight document types as JSON Schema 2020-12 bundles. Anyone building an HTTP service over HDF previously hand-translated those schemas into OpenAPI and hand-invented an API to go with them — and both then drifted from the format they were meant to describe.

The bundles are not drop-in OpenAPI components. The bundler embeds each primitive as a URL-keyed resource carrying its own $id, so the eight bundles together hold 19 such resource wrappers and well over a hundred named definitions (the exact figure is EXPECTED_DEFINITIONS in src/components.ts, which the build refuses to disagree with), with hundreds of $refs — some absolute, some local pointers that resolve against the enclosing resource rather than the file. OpenAPI component keys cannot be URLs, and pointer-based code generators resolve by JSON pointer, not by $id. Translating that by hand is both tedious and easy to get subtly wrong.

So this package generates the components instead. Nothing here is hand-authored — they come from the tracked schema embed. The only thing in this repository that reads this package is the docs site, whose generators publish both documents, their per-version archives and a page per problem type from dist/.

problems.json is the other published artifact: ADR-0010 §6's single code-to-status mapping, plus a title, a cause and a client-facing remedy per problem type. It stays here because the taxonomy it documents is the MCP server's, and because the type URIs it describes are hosted on this repository's site, where RFC 9457 §3.1.1 expects them to dereference. Anything serving HDF over HTTP can build a conforming problem body from it without re-deriving the mapping.

Installation ​

bash
npm install @mitre/hdf-openapi

Usage ​

Read the components document ​

ts
import components from '@mitre/hdf-openapi/hdf-components.oas.json' with { type: 'json' };

const results = components.components.schemas.HdfResults;

The generated document is the consumer surface. The transform that produces it (buildComponentsDocument) runs at build time only and is not exported, because it reads the HDF schema bundles, which this package does not ship.

The eight roots ​

Each HDF document type is a component named after it:

Document typeComponent
hdf-resultsHdfResults
hdf-baselineHdfBaseline
hdf-comparisonHdfComparison
hdf-systemHdfSystem
hdf-planHdfPlan
hdf-amendmentsHdfAmendments
hdf-evidence-packageHdfEvidencePackage
hdf-requirement-change-eventHdfRequirementChangeEvent

Every other definition is hoisted to #/components/schemas/<Name> under its own name, and every $ref is rewritten to a local component pointer.

What the transform guarantees ​

  • 2020-12 features pass through unchanged, and a test asserts the complete keyword histogram of the output against an independent walk of the input, so a dropped keyword fails the build rather than surfacing in a downstream codegen. unevaluatedProperties, if/then/else, dependentRequired, boolean-false subschemas, contains + const and type: [string, null] enums are all left as the schemas define them. They are legal in OpenAPI 3.1, and tool support for them is measured rather than assumed.
  • Refs are resolved, not string-replaced. A local #/$defs/X is resolved against the resource that encloses it, and the target's existence is checked in the scope the ref names. A global string replace would silently retarget refs inside an embedded primitive.
  • Duplicates collapse, conflicts fail. The hdf-results resource is embedded inside comparison and change-event; identical definitions deduplicate, while a same-name definition with a different body fails the build rather than picking a winner.
  • The input is the tracked embed. Generation reads hdf-validators/go/schemas/, the reviewed copy, never the gitignored hdf-schema/dist/. The file set must match the bundler's own list, so a document type that appeared or vanished fails the build.
  • info.version is the schema version from the bundles' $id, not this package's version. The two move independently.

Tooling compatibility is measured, not assumed ​

test/baseline/keywords.json records what real tooling actually does with the published document, and pnpm run matrix fails if any of it moves. Four things are tracked:

  • Which keywords the document uses, with counts, so a schema change that introduces a keyword nothing in the matrix supports is a failing diff rather than a consumer's discovery.

  • Redocly at zero findings, every severity — and the per-rule counts its waivers are absorbing, measured by re-running with every waiver stripped. A waiver can therefore never quietly grow to cover a new finding. Every waiver in redocly.yaml carries the reason it does not apply to a document schema, and because those counts mix suppressed false positives with any future genuine finding, movement in them needs human triage rather than a blind re-record.

  • Whether each generator can consume the document at all. openapi-typescript can. oapi-codegen 2.8.0 cannot: its parser (kin-openapi) rejects a boolean subschema, which HDF uses to express the three-tier BOM rule (properties: { model: false } on a non-ai-model BOM). The refusal and its trigger are recorded rather than worked around, because the construct is a real constraint and dropping it would weaken the schema to suit one tool.

  • Per keyword, whether a generator's output depends on it — measured differentially: generate from a probe schema carrying the keyword, generate again with that one keyword deleted, compare the bytes. Both generators honour the structural keywords ($ref, properties, required, items, type, enum, allOf/anyOf/oneOf, format) and both discard every validation constraint: minimum, maximum, minLength, minItems, pattern, contains, not, dependentRequired, if/then/else and unevaluatedProperties. Generated types are shape-only. Anything that must actually enforce the schema has to run a validator — which is why ADR-0008 §7 derives Zod from this document rather than trusting generated types.

None of that is optional. pnpm test re-measures the lints and openapi-typescript and fails on any drift from the baseline, and CI's check-openapi-matrix job installs oapi-codegen at the version mise.toml pins and runs the full matrix, so the Go half is gated too. That wiring is itself checked: the root pnpm run lint:matrix-wiring, which runs in pnpm check and in CI, fails when the job is gone, because an ungated baseline is the real hazard. The package's own pnpm test does not check it.

oapi-codegen is a Go binary, not an npm dependency, which is why pnpm test measures only the half it can reach. mise.toml at the repository root pins it at the version the baseline records, and mise install installs that release. Run the matrix under mise exec -- (or with mise activated in your shell) so that release, not another oapi-codegen on PATH, is the one measured. To run the whole matrix locally:

bash
mise install                           # oapi-codegen at the pinned version, with the rest of the toolchain
mise exec -- pnpm run matrix           # verify against the tracked baseline
mise exec -- pnpm run matrix:update    # re-record after a deliberate tooling or schema change
pnpm run lint:openapi    # Redocly alone

With the binary present, pnpm test upgrades itself to the full both-generator comparison; without it, the npm half runs and CI covers the rest.

Conformance is checked separately and more strictly than any linter manages: test/conformance.test.ts extracts every component back to a standalone 2020-12 schema and compiles each one, then validates every root example, every definition example and the @mitre/hdf-fixtures corpus with a 2020-12 engine. The counts are asserted in that test rather than quoted here, so they cannot rot in two places. This repository's own validators are draft-07 and ignore unevaluatedProperties, so they would accept documents the schema text rejects.

Versioning ​

The components document's info.version tracks the schema $id version, read from the bundle rather than from this package's version — the two axes are independent and have already diverged.

The reference API's versioning, and the contract digest that enforced it, moved with the document. What stays here cannot drift the same way: this document's version is read from the schema bundle rather than hand-set, so it cannot disagree with its own content, and EXPECTED_DEFINITIONS fails the build when the content changes without review.

Design ​

dev-docs/adr-0008-openapi-schema-and-reference-api.md, in the hdf-libs repository, records the decisions, the alternatives considered, and the measured forces behind them. ADR-0012 puts this package in context: it stays in hdf-libs because it derives from this repository's schemas and MCP contract, and it is the contract the sibling platform repository implements.

License ​

Apache-2.0. See LICENSE.md.

Released under the Apache 2.0 License.