Schema Builder¶
-
file_config.schema_builder.
Regex
(pattern)[source]¶ A custom typing type to store regular expressions for schema building.
- Parameters
pattern (str) – The regular expression
- Returns
A new Regex type instance
- Return type
-
file_config.schema_builder.
_build
(value, property_path=None)[source]¶ The generic schema definition build method.
-
file_config.schema_builder.
_build_array_type
(var, property_path=None)[source]¶ Builds schema definitions for array type values.
-
file_config.schema_builder.
_build_attribute_modifiers
(var, attribute_mapping, ignore=None)[source]¶ Handles adding schema modifiers for a given config var and some mapping.
- Parameters
- Raises
ValueError – When the given
var
is not an config varValueError – When jsonschema modifiers are given the wrong type
- Returns
A dictionary of the built modifiers
- Return type
Dict[str, Any]
-
file_config.schema_builder.
_build_bool_type
(var, property_path=None)[source]¶ Builds schema definitions for boolean type values.
-
file_config.schema_builder.
_build_config
(config_cls, property_path=None)[source]¶ Builds the schema definition for a given config class.
- Parameters
config_cls (class) – The config class to build a schema definition for
property_path (List[str]) – The property path of the current type, defaults to None, optional
- Raises
ValueError – When the given
config_cls
is not a config decorated class- Returns
The built schema definition
- Return type
Dict[str, Any]
-
file_config.schema_builder.
_build_enum_type
(var, property_path=None)[source]¶ Builds schema definitions for enum type values.
-
file_config.schema_builder.
_build_integer_type
(var, property_path=None)[source]¶ Builds schema definitions for integer type values.
-
file_config.schema_builder.
_build_null_type
(var, property_path=None)[source]¶ Builds schema definitions for null type values.
-
file_config.schema_builder.
_build_number_type
(var, property_path=None)[source]¶ Builds schema definitions for number type values.
-
file_config.schema_builder.
_build_object_type
(var, property_path=None)[source]¶ Builds schema definitions for object type values.
-
file_config.schema_builder.
_build_string_type
(var, property_path=None)[source]¶ Builds schema definitions for string type values.
-
file_config.schema_builder.
_build_type
(type_, value, property_path=None)[source]¶ Builds the schema definition based on the given type for the given value.
-
file_config.schema_builder.
_build_var
(var, property_path=None)[source]¶ Builds a schema definition for a given config var.
- Parameters
var (attr._make.Attribute) – The var to generate a schema definition for
property_path (List[str]) – The property path of the current type, defaults to None, optional
- Raises
ValueError – When the given
var
is not a file_config var- Returns
The built schema definition
- Return type
Dict[str, Any]
-
file_config.schema_builder.
build_schema
(config_cls)[source]¶ Builds the JSONSchema for a given config class.
Important
Although you can configure the generated JSONSchema’s
$id
and$schema
properties through thefile_config._file_config.config()
decorator, this method will default those values for you. You should be wary of using a$schema
draft of anything less than draft-07 as we rely on the specified functionality for handling both union and regex pattern matching types.- Parameters
config_cls (class) – The config class to build the JSONSchema for
- Returns
The resulting JSONSchema
- Return type