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

typing.Type

file_config.schema_builder._build(value, property_path=None)[source]

The generic schema definition build method.

Parameters
  • value – The value to build a schema definition for

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

Returns

The built schema definition

Return type

Dict[str, Any]

file_config.schema_builder._build_array_type(var, property_path=None)[source]

Builds schema definitions for array type values.

Parameters
  • var – The array type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

  • property_path – [type], optional

Returns

The built schema definition

Return type

Dict[str, Any]

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
  • var (attr._make.Attribute) – The config var to build modifiers for

  • str] attribute_mapping (Dict[str,) – A mapping of attribute to jsonschema modifiers

  • ignore (List[str]) – A list of mapping keys to ignore, defaults to None

Raises
  • ValueError – When the given var is not an config var

  • ValueError – 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.

Parameters
  • var – The boolean type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

  • property_path – [type], optional

Returns

The built schema definition

Return type

Dict[str, Any]

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.

Parameters
  • var – The enum type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

Returns

The built schema definition

Return type

Dict[str, Any]

file_config.schema_builder._build_integer_type(var, property_path=None)[source]

Builds schema definitions for integer type values.

Parameters
  • var – The integer type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

  • property_path – [type], optional

Returns

The built schema definition

Return type

Dict[str, Any]

file_config.schema_builder._build_null_type(var, property_path=None)[source]

Builds schema definitions for null type values.

Parameters
  • var – The null type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

Returns

The built schema definition

Return type

Dict[str, Any]

file_config.schema_builder._build_number_type(var, property_path=None)[source]

Builds schema definitions for number type values.

Parameters
  • var – The number type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

  • property_path – [type], optional

Returns

The built schema definition

Return type

Dict[str, Any]

file_config.schema_builder._build_object_type(var, property_path=None)[source]

Builds schema definitions for object type values.

Parameters
  • var – The object type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

  • property_path – [type], optional

Returns

The built schema definition

Return type

Dict[str, Any]

file_config.schema_builder._build_string_type(var, property_path=None)[source]

Builds schema definitions for string type values.

Parameters
  • var – The string type value

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

  • property_path – [type], optional

Returns

The built schema definition

Return type

Dict[str, Any]

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.

Parameters
  • type – The type of the value

  • value – The value to build the schema definition for

  • property_path (List[str]) – The property path of the current type, defaults to None, optional

Returns

The built schema definition

Return type

Dict[str, Any]

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 the file_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

dict