Data Models¶
These dataclasses are returned by the Python API and used throughout okf-schema.
Validation¶
- class okf_schema._internal.models.Finding(code, message, path=None)¶
A single validation finding (error, warning or informational note).
- Parameters:
code (str)
message (str)
path (Path | None)
- class okf_schema._internal.models.Report(errors=<factory>, warnings=<factory>, infos=<factory>)¶
Aggregated validation report for an OKF bundle.
- property is_conformant: bool¶
Return True if the report contains no errors.
- add_error(code, message, path=None)¶
Append an error finding to the report.
- Parameters:
code (
str) – Stable machine-readable finding code.message (
str) – Human-readable explanation.path (
Path|None) – Optional path associated with the finding.
- Return type:
None
Examples
>>> from okf_schema._internal.models import Report >>> report = Report() >>> report.add_error("missing-title", "Title is required") >>> report.is_conformant False
- add_warning(code, message, path=None)¶
Append a warning finding to the report.
- Parameters:
code (
str) – Stable machine-readable finding code.message (
str) – Human-readable explanation.path (
Path|None) – Optional path associated with the finding.
- Return type:
None
Examples
>>> from okf_schema._internal.models import Report >>> report = Report() >>> report.add_warning("missing-description", "Description is recommended") >>> len(report.warnings) 1
- add_info(code, message, path=None)¶
Append an informational finding to the report.
Informational findings never make a report non-conformant and are never counted by
--strict.- Parameters:
code (
str) – Stable machine-readable finding code.message (
str) – Human-readable explanation.path (
Path|None) – Optional path associated with the finding.
- Return type:
None
Examples
>>> from okf_schema._internal.models import Report >>> report = Report() >>> report.add_info("I1", "schema file is empty") >>> report.is_conformant, len(report.infos) (True, 1)
- add_schema_diagnostics(diagnostics)¶
Route schema-loading diagnostics to warnings or informational notes.
- Parameters:
diagnostics (
list[Finding]) – Findings returned byokf_schema.validator.load_schema_database_with_diagnostics(). Codes starting withWbecome warnings; the others become informational notes.- Return type:
None
Examples
>>> from okf_schema._internal.models import Finding, Report >>> report = Report() >>> report.add_schema_diagnostics([Finding("I1", "empty"), Finding("W17", "bad")]) >>> len(report.infos), len(report.warnings) (1, 1)
Concepts¶
- class okf_schema._internal.models.ConceptInfo(title, description, type)¶
Extracted metadata from an OKF concept file.
- Parameters:
title (str)
description (str)
type (str)
- class okf_schema._internal.models.ConceptSummary(path, type, title, stale=False)¶
Summary of a single concept in an OKF bundle.
- Parameters:
path (str)
type (str)
title (str)
stale (bool)
- class okf_schema._internal.models.ConceptDetail(frontmatter, body, trust_tier='unverified', stale=False)¶
Detailed view of a single concept file.
- Parameters:
frontmatter (dict[str, object])
body (str)
trust_tier (str)
stale (bool)
Statistics¶
- class okf_schema._internal.models.BundleStats(total_files, total_concepts, files_without_frontmatter, total_size, total_links, broken_links, types_distribution, tags_distribution, directories)¶
Statistics for an OKF bundle.
- Parameters:
total_files (int)
total_concepts (int)
files_without_frontmatter (int)
total_size (int)
total_links (int)
broken_links (int)
types_distribution (dict[str, int])
tags_distribution (dict[str, int])
directories (int)