object_schema

SchemaAnyOf

class wysdom.SchemaAnyOf(allowed_schemas: Iterable[wysdom.base_schema.Schema.Schema], schema_ref_name: Optional[str] = None)

Bases: wysdom.base_schema.Schema.Schema

A schema requiring a match with any of the permitted schemas supplied.

Parameters
  • allowed_schemas – A list (or other Iterable) containing the permitted Schema objects.

  • schema_ref_name – An optional unique reference name to use when this schema is referred to by other schemas.

allowed_schemas: Tuple[wysdom.base_schema.Schema.Schema] = None
property jsonschema_definition

The underlying jsonschema-compatible schema definition for this schema.

Returns

A jsonschema-compatible dictionary.

property referenced_schemas

A dict of named schemas (i.e. schemas with a defined schema_ref_name) that are referenced in this schema, including itself if applicable.

Returns

A dict of Schema objects indexed by their schema_ref_name.

schema_ref_name: Optional[str] = None

SchemaArray

class wysdom.SchemaArray(items: Union[Type, wysdom.base_schema.Schema.Schema])

Bases: wysdom.base_schema.Schema.Schema

A schema specifying an array (corresponding to a Python list)

Parameters

items – The permitted data type or schema for the items of this array. Must be one of: A primitive Python type (str, int, bool, float) A subclass of UserObject An instance of Schema

items: wysdom.base_schema.Schema.Schema = None
property jsonschema_definition

The underlying jsonschema-compatible schema definition for this schema.

Returns

A jsonschema-compatible dictionary.

property referenced_schemas

A dict of named schemas (i.e. schemas with a defined schema_ref_name) that are referenced in this schema, including itself if applicable.

Returns

A dict of Schema objects indexed by their schema_ref_name.

SchemaDict

class wysdom.SchemaDict(items: Union[Type, wysdom.base_schema.Schema.Schema], key_pattern: Optional[str] = None)

Bases: wysdom.object_schema.SchemaObject.SchemaObject

A schema specifying an object with dynamic properties (corresponding to a Python dict)

Parameters
  • items – The permitted data type or schema for the properties of this object. Must be one of: A primitive Python type (str, int, bool, float) A subclass of UserObject An instance of Schema

  • key_pattern – A regex pattern to validate the keys of the dictionary against.

SchemaObject

class wysdom.SchemaObject(properties: Optional[Dict[str, wysdom.base_schema.Schema.Schema]] = None, required: Optional[Set[str]] = None, additional_properties: Union[bool, wysdom.base_schema.Schema.Schema] = False, object_type: Type = <class 'dict'>, schema_ref_name: Optional[str] = None, property_names: Optional[wysdom.base_schema.Schema.Schema] = None)

Bases: wysdom.base_schema.SchemaType.SchemaType

A schema specifying an object with named properties.

Parameters
  • properties – A dictionary of Schema objects defining the expected names and types of this object’s properties.

  • additional_properties – Defines whether this object permits additional dynamically-named properties. Can be True or False, or can be set to a specific Schema to restrict the permitted types of any additional properties.

  • object_type – A custom object type to use when creating object instances from this schema.

  • schema_ref_name – An optional unique reference name to use when this schema is referred to by other schemas.

  • property_names – An optional Schema that property names must be validated against.

additional_properties: Union[bool, wysdom.base_schema.Schema.Schema] = False
property jsonschema_definition

The underlying jsonschema-compatible schema definition for this schema.

Returns

A jsonschema-compatible dictionary.

properties: Optional[Dict[str, wysdom.base_schema.Schema.Schema]] = None
property_names: Optional[wysdom.base_schema.Schema.Schema] = None
property referenced_schemas

A dict of named schemas (i.e. schemas with a defined schema_ref_name) that are referenced in this schema, including itself if applicable.

Returns

A dict of Schema objects indexed by their schema_ref_name.

required: Set[str] = None
schema_ref_name: Optional[str] = None
type_name: str = 'object'

resolve_arg_to_type

wysdom.object_schema.resolve_arg_to_type.resolve_arg_to_schema(arg: Union[Type, wysdom.base_schema.Schema.Schema])wysdom.base_schema.Schema.Schema

Resolve an argument of heterogeneous type to a Schema instance.

Parameters

arg – Argument to resolve to a Schema. Must be one of: A primitive Python type (str, int, bool, float) A subclass of UserObject An instance of Schema.

Returns

A Schema instance corresponding to the supplied argument.