gemseo.core.grammars.json_schema module#

JSON schema handler.

class MutableMappingSchemaBuilder(schema_uri='DEFAULT')[source]#

Bases: Mapping[str, Any], SchemaBuilder

A mutable genson SchemaBuilder with a dictionary-like interface.

The SchemaBuilder does not provide a way to mutate directly the properties of a schema (these are stored deeply). For ease of usage, this class brings the properties closer to the surface, and the mutability is only provided by the ability to delete a property.

Parameters:

schema_uri --

value of the $schema keyword. If not given, it will use the value of the first available $schema keyword on an added schema or else the default: 'http://json-schema.org/schema#'. A value of False or None will direct GenSON to leave out the "$schema" keyword.

By default it is set to "DEFAULT".

NODE_CLASS#

alias of MutableMappingSchemaBuilderSchemaNode

add_object(obj, update)[source]#
Parameters:
  • update (bool) -- Whether to update or merge the schema.

  • obj (Obj)

Return type:

None

add_schema(schema, update)[source]#
Parameters:
  • update (bool) -- Whether to update or merge the schema.

  • schema (Schema)

Return type:

None

check_property_names(*names)[source]#

Check that the names are existing properties.

Parameters:

*names (str) -- The names to be checked.

Raises:

KeyError -- If a name is not an existing property.

Return type:

None

EXTRA_STRATEGIES = (<class 'gemseo.core.grammars.json_schema._MergeStrategy'>, <class 'gemseo.core.grammars.json_schema._Number'>)#
STRATEGIES = (<class 'gemseo.core.grammars.json_schema._MergeStrategy'>, <class 'gemseo.core.grammars.json_schema._Number'>, <class 'genson.schema.strategies.scalar.Null'>, <class 'genson.schema.strategies.scalar.Boolean'>, <class 'genson.schema.strategies.scalar.Number'>, <class 'genson.schema.strategies.scalar.String'>, <class 'genson.schema.strategies.array.List'>, <class 'genson.schema.strategies.array.Tuple'>, <class 'genson.schema.strategies.object.Object'>)#
property properties: MutableMapping[str, SchemaNode]#

Return the properties.

Returns:

The existing properties, otherwise an empty dictionary.

property required: set[str]#

Return the required properties.

Returns:

The required properties, otherwise an empty set.