betty.json_schema module¶
Provide JSON utilities.
- class betty.json_schema.AllOf¶
Bases:
_ContainerA JSON Schema
allOf.
- class betty.json_schema.AnyOf¶
Bases:
_ContainerA JSON Schema
anyOf.
- class betty.json_schema.Array¶
Bases:
_TypeA JSON Schema
arraytype.
- class betty.json_schema.Boolean¶
Bases:
_TypeA JSON Schema
booleantype.
- class betty.json_schema.Def¶
Bases:
strThe name of a named Betty schema.
Using this instead of
strdirectly allows Betty to bundle schemas together under a project namespace.
- class betty.json_schema.Integer¶
Bases:
_TypeA JSON Schema
integertype.
- final class betty.json_schema.JsonSchemaSchema¶
Bases:
SchemaThe JSON Schema Draft 2020-12 schema.
- __init__()¶
- class betty.json_schema.Null¶
Bases:
_TypeA JSON Schema
nulltype.
- class betty.json_schema.Number¶
Bases:
_TypeA JSON Schema
numbertype.
- class betty.json_schema.Object¶
Bases:
_TypeA JSON Schema
objecttype.
- class betty.json_schema.OneOf¶
Bases:
_ContainerA JSON Schema
oneOf.
- class betty.json_schema.Schema¶
Bases:
objectA 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, title: ResolvableLocalizable | None = None, description: ResolvableLocalizable | None = None)¶
- property defs: PortableMapping¶
The JSON Schema’s
$defsdefinitions, 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, /) PortableMapping¶
Embed this schema.
This is where the raw schema may be enhanced before being returned.
- property schema: PortableMapping¶
The raw JSON Schema.
- class betty.json_schema.String¶
Bases:
_TypeA JSON Schema
stringtype.- class Format¶
Bases:
EnumA JSON Schema
stringtype’sformat.- DATE = 'date'¶
- DATE_TIME = 'date-time'¶
- DURATION = 'duration'¶
- EMAIL = 'email'¶
- HOSTNAME = 'hostname'¶
- IDN_EMAIL = 'idn-email'¶
- IDN_HOSTNAME = 'idn-hostname'¶
- IPV4 = 'ipv4'¶
- IPV6 = 'ipv6'¶
- IRI = 'iri'¶
- IRI_REFERENCE = 'iri-reference'¶
- JSON_POINTER = 'json-pointer'¶
- REGEX = 'regex'¶
- RELATIVE_JSON_POINTER = 'relative-json-pointer'¶
- TIME = 'time'¶
- URI = 'uri'¶
- URI_REFERENCE = 'uri-reference'¶
- URI_TEMPLATE = 'uri-template'¶
- UUID = 'uuid'¶