Schema¶
Schema for validating configuration against JSON Schema.
The Schema class loads JSON Schema definitions from files or strings, and is used with Config.validate() to validate configuration values.
Example
schema = Schema.load("schema.json") config.validate(schema)
Functions¶
load
staticmethod
¶
load(path: str) -> Schema
Load a schema from a file (JSON or YAML based on extension).
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to the schema file (.yaml, .yml, or .json)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A new Schema object |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the file cannot be parsed |
HoloconfError
|
If the file cannot be read |
from_yaml
staticmethod
¶
from_yaml(yaml: str) -> Schema
Load a schema from a YAML string.
| PARAMETER | DESCRIPTION |
|---|---|
yaml
|
JSON Schema as a YAML string
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A new Schema object |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the YAML is invalid or not a valid JSON Schema |
from_json
staticmethod
¶
from_json(json: str) -> Schema
Load a schema from a JSON string.
| PARAMETER | DESCRIPTION |
|---|---|
json
|
JSON Schema as a JSON string
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A new Schema object |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the JSON is invalid or not a valid JSON Schema |
to_yaml ¶
Output the schema as YAML.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The schema serialized as a YAML string. |
to_json ¶
Output the schema as JSON.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The schema serialized as a JSON string. |
to_markdown ¶
Generate markdown documentation from the schema.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Human-readable markdown documentation describing the schema. |