Schema¶
- class ocdskit.schema.Field(name, schema, deprecated_self, deprecated, pointer, path_components, definition, pattern=False, multilingual=False, required=False, merge_by_id=False, codelist='', open_codelist=False)[source]¶
Initialize a schema field object.
- Parameters:
- pointer: str¶
The JSON pointer to the field in the schema, e.g.
/properties/tender/properties/id. Used, for example, to look up a modified field’s original schema in the release schema.
- multilingual: bool = False¶
Whether the field has a corresponding field in the schema’s
patternProperties(like in OCDS 1.1).
- sep = '.'¶
The separator to use in string representations of paths.
- property path¶
Return the path to the field in data with
self.sepas separator, e.g.tender.id.
- asdict(sep=None, exclude=())[source]¶
Return the field as a dict, with keys for all properties except
path_components.
- __annotations__ = {'codelist': 'str', 'definition': 'str', 'deprecated': 'dict', 'deprecated_self': 'dict', 'merge_by_id': 'bool', 'multilingual': 'bool', 'name': 'str', 'open_codelist': 'bool', 'path_components': 'tuple', 'pattern': 'bool', 'pointer': 'str', 'required': 'bool', 'schema': 'dict'}¶
- __dataclass_fields__ = {'codelist': Field(name='codelist',type='str',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'definition': Field(name='definition',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'deprecated': Field(name='deprecated',type='dict',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'deprecated_self': Field(name='deprecated_self',type='dict',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'merge_by_id': Field(name='merge_by_id',type='bool',default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'multilingual': Field(name='multilingual',type='bool',default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'name': Field(name='name',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'open_codelist': Field(name='open_codelist',type='bool',default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'path_components': Field(name='path_components',type='tuple',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'pattern': Field(name='pattern',type='bool',default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'pointer': Field(name='pointer',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'required': Field(name='required',type='bool',default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'schema': Field(name='schema',type='dict',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)¶
- __eq__(other)¶
Return self==value.
- __firstlineno__ = 9¶
- __hash__ = None¶
- __init__(name, schema, deprecated_self, deprecated, pointer, path_components, definition, pattern=False, multilingual=False, required=False, merge_by_id=False, codelist='', open_codelist=False)¶
- __match_args__ = ('name', 'schema', 'deprecated_self', 'deprecated', 'pointer', 'path_components', 'definition', 'pattern', 'multilingual', 'required', 'merge_by_id', 'codelist', 'open_codelist')¶
- __replace__(**changes)¶
- __static_attributes__ = ()¶
- ocdskit.schema.get_schema_fields(schema, pointer='', path_components=(), definition='', deprecated=None, *, whole_list_merge=False, array=False)[source]¶
Yield a
Fieldfor each name underpropertiesorpatternProperties.- Parameters:
schema (dict) – A dereferenced JSON schema. If using
jsonref, and if subschemas set both$refand other properties, the schema must be dereferenced with eitherproxies=Trueormerge_props=True.pointer (str) – The JSON pointer to the field in the schema, e.g.
/properties/tender/properties/id.path_components (tuple) – The path to the field in data, e.g.
('tender', 'id').definition (str) – The definition in which the field is defined, e.g.
'Item'.deprecated (dict | None) – If the field, or an ancestor of the field, sets
deprecated, thedeprecatedobject.whole_list_merge (bool) – Whether the field, or an ancestor of the field, sets
wholelistMerge.array (bool) – Whether the field is under
items/propertiesoritems/patternProperties.