Skip to content

okforest/type-schema

errorOKForest conventions

Concepts match their type’s JSON Schema in .okforest/types/, and each schema there is a usable JSON Schema for one type.

OKF lets each team name its types and add any fields it likes (§4.1), so nothing in the format keeps a team’s Metric concepts alike. A JSON Schema for the type, in .okforest/types/ (metric.schema.json), says which fields they carry, what each may hold, and which they must have; every concept of that type must match it. The schema’s title is the type, as concepts write it in type. OKF’s own fields (title, tags, verified, …) are left to the okf/* rules, so a schema lists only its type’s fields, and can still name one, such as tags, to narrow it. Under OKF 0.3, a type’s own fields are extension keys, starting with x- (§4.1), as x-unit does here. A schema that can’t be used (not JSON, no title, a second schema for the same type, a $ref that leads nowhere) is reported on its file, and no concept is checked against it.

This file breaks the rule:

churn.md
---
type: Metric
title: Monthly churn
description: The share of customers who cancel in a month.
x-unit: percentage
---
Churn is the customers who cancel in a month, divided by the customers at its start.

okforest validate reports:

churn.md
2:1 error Missing `x-owner`, which the Metric type requires. okforest/type-schema
5:1 error `x-unit` must be one of `percent`, `count`, `usd` (got `percentage`). okforest/type-schema

Fixed:

churn.md
---
type: Metric
title: Monthly churn
description: The share of customers who cancel in a month.
x-unit: percent
x-owner: data-team@acme.example
---
Churn is the customers who cancel in a month, divided by the customers at its start.