yaal-coop / scim2-models

SCIM resources serialization and validation with Pydantic

Home Page:https://scim2-models.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mark complex sub-attributes URNs at model definition

azmeuk opened this issue · comments

Currently, complex sub-attributes are given a private URN on model validation.

def mark_with_schema(self):
"""Navigate through attributes and subattributes of type
ComplexAttribute, and mark them with a '_schema' attribute.
'_schema' will later be used by 'get_attribute_urn'.
"""

Those URNs are used later in model validation:

def scim_response_serializer(self, value: Any, info: SerializationInfo) -> Any:
"""Serialize the fields according to returability indications passed in
the serialization context."""
returnability = self.get_field_annotation(info.field_name, Returned)
attribute_urn = self.get_attribute_urn(info.field_name)

We should investigate how to mark URNs at model definition instead, for example by using things like __set_name__?

Fixed by #48