json_schema module¶
JSON schema handler.
- class gemseo.core.grammars.json_schema.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 ofFalse
orNone
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
- get(k[, d]) D[k] if k in D, else d. d defaults to None. ¶
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- to_json(*args, **kwargs)¶
Generate a schema and convert it directly to serialized JSON.
- Return type:
str
- to_schema()¶
Generate a schema based on previous inputs.
- Return type:
dict
- values() an object providing a view on D's values ¶
- DEFAULT_URI = 'http://json-schema.org/schema#'¶
- EXTRA_STRATEGIES = (<class 'gemseo.core.grammars.json_schema._MergeStrategy'>, <class 'gemseo.core.grammars.json_schema._Number'>)¶
- NULL_URI = 'NULL'¶
- 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.