Skip to content

Spec serialization

uptimely.spec.serialization reads and writes Spec documents as JSON. Use load_spec to also check the declarations.

serialization

load_document reads JSON without checking that the declarations work together. load_spec performs those checks when it loads the document.

JSON serialization helpers for spec models.

load_document

load_document(path: str | Path) -> dict[str, typing.Any]

Read one JSON document, rejecting unsupported multi-file definitions.

to_document

to_document(spec_definition: Spec) -> dict[str, typing.Any]

Encode document models using the spec document's identifier rules.

write_document

write_document(spec_definition: Spec, path: str | Path) -> str

Write a spec document without mutating the source model.