Schema#
- class ocdskit.schema.Field(schema=None, pointer_components=None, path_components=None, definition_pointer_components=None, definition_path_components=None, required=None, deprecated=<factory>, multilingual=None)[source]#
Initializes a schema field object.
- Parameters:
- pointer_components: tuple = None#
the JSON pointer to the field in the schema, e.g.
('properties', 'tender', 'properties', 'id')
- definition_pointer_components: tuple = None#
the JSON pointer to the definition in which the field is defined, e.g.
('definitions', 'Item')
- definition_path_components: tuple = None#
the path to the definition in which the field is defined, e.g.
('Item')
- multilingual: bool = None#
whether the field has a corresponding field in the schema’s
patternProperties
- sep = '.'#
the separator to use in string representations of paths
- property pointer#
Returns the JSON pointer to the field in the schema, e.g.
/properties/tender/properties/id
.
- property definition_pointer#
Returns the JSON pointer to the definition in which the field is defined, e.g.
/definitions/Item
.
- property path#
Returns the path to the field in data with
self.sep
as separator, e.g.tender.id
.
- property definition_path#
Returns the path to the definition in which the field is defined with
self.sep
as separator, e.g.Item
.
- asdict(sep=None, exclude=None)[source]#
Returns the field as a dict, with keys for:
schema
,pointer
,path
,definition_pointer
,definition_path
,required
,deprecated
,multilingual
.
- __annotations__ = {'definition_path_components': <class 'tuple'>, 'definition_pointer_components': <class 'tuple'>, 'deprecated': <class 'dict'>, 'multilingual': <class 'bool'>, 'path_components': <class 'tuple'>, 'pointer_components': <class 'tuple'>, 'required': <class 'bool'>, 'schema': <class 'dict'>}#
- __dataclass_fields__ = {'definition_path_components': Field(name='definition_path_components',type=<class 'tuple'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'definition_pointer_components': Field(name='definition_pointer_components',type=<class 'tuple'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'deprecated': Field(name='deprecated',type=<class 'dict'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'multilingual': Field(name='multilingual',type=<class 'bool'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'path_components': Field(name='path_components',type=<class 'tuple'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'pointer_components': Field(name='pointer_components',type=<class 'tuple'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'required': Field(name='required',type=<class 'bool'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'schema': Field(name='schema',type=<class 'dict'>,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}#
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)#
- __eq__(other)#
Return self==value.
- __hash__ = None#
- __init__(schema=None, pointer_components=None, path_components=None, definition_pointer_components=None, definition_path_components=None, required=None, deprecated=<factory>, multilingual=None)#
- ocdskit.schema.get_schema_fields(schema, pointer=None, path=None, definition_pointer=None, definition_path=None, deprecated=None)[source]#
Yields a
Field
object for each field (whether underproperties
orpatternProperties
) in a JSON schema.- Parameters:
schema (dict) – a JSON schema
pointer (tuple) – the JSON pointer to the field in the schema, e.g.
('properties', 'tender', 'properties', 'id')
path (tuple) – the path to the field in data, e.g.
('tender', 'id')
definition_pointer (tuple) – the JSON pointer to the definition in which the field is defined, e.g.
('definitions', 'Item')
definition_path (tuple) – the path to the definition in which the field is defined, e.g.
('Item')
deprecated (dict) – if the field, or an ancestor of the field, sets
deprecated
, thedeprecated
object