gemseo / third_party

genson_generator module

A JSON schema generation tool

class gemseo.third_party.genson_generator.Schema(merge_arrays=True, additional_items=True, additional_props=True, match_props=[], exclude_at_merge=None)[source]

Bases: object

Basic schema generator class. Schema objects can be loaded up with existing schemas and objects before being serialized.

Builds a schema generator object.

  • merge_arrays (default True): Assume all array items share the same schema (as they should). The alternate behavior is to create a different schema for each item in every array.

  • additional_items (default ‘True’): If True, allow tuple-validated arrays to be followed by unvalidated items. If False, generate an “additionalItems”: False element so that array items not specified in the schema cause a ValidationError. Not used with list-validated (merged) arrays.

  • additional_props (default ‘True’): If True, allow objects to include unvalidated properties. If False, generate an “additionalProperties”: False element so that properties not specified in the schema cause a ValidationError.

  • match_props (default ‘[]’): List of regular expressions to compare with property keys. Properties with matching keys share the same “patternProperties” schema.

add_description(descr)[source]
Parameters

descr – tue description

add_object(obj, descr=None)[source]

Modify the schema to accomodate an object.

Parameters
  • obj – required

  • a – JSON object to use in generate the schema

add_schema(schema)[source]

Merges in an existing schema.

Parameters
  • schema – required

  • an – existing JSON Schema to merge

to_dict()[source]

Convert the current schema to a dict.

to_json(*args, **kwargs)[source]

Convert the current schema directly to serialized JSON.

Parameters
  • args

  • kwargs

class gemseo.third_party.genson_generator.SchemaDefaultDict(*args, **kwargs)[source]

Bases: collections.defaultdict

A defaultdict implementation that is serializable with pickle and that returns an empty Schema by default

Constructor

exception gemseo.third_party.genson_generator.SchemaError(value)[source]

Bases: Exception