betty.json.schema module¶
Provide JSON utilities.
- class betty.json.schema.Def[source]¶
Bases:
str
The name of a named Betty schema.
Using this instead of
str
directly allows Betty to bundle schemas together under a project namespace.
- class betty.json.schema.FileBasedSchema[source]¶
Bases:
Schema
A JSON Schema that is stored in a file.
- class betty.json.schema.JsonSchemaSchema[source]¶
Bases:
FileBasedSchema
The JSON Schema Draft 2020-12 schema.
- class betty.json.schema.Ref[source]¶
Bases:
Schema
A JSON Schema that references a named Betty schema.
- class betty.json.schema.Schema[source]¶
Bases:
object
A JSON Schema.
All schemas using this class MUST follow JSON Schema Draft 2020-12.
To test your own subclasses, use
betty.test_utils.json.schema.SchemaTestBase
.- __init__(*, def_name: str | None = None, schema: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]] | None = None)[source]¶
- property defs: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]]¶
The JSON Schema’s
$defs
definitions, kept separately, so they can be merged when this schema is embedded.Only top-level definitions are supported. You MUST NOT nest definitions. Instead, prefix or suffix their names.
- embed(into: Schema) bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump] [source]¶
Embed this schema.
- property schema: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]]¶
The raw JSON Schema.