|
29 | 29 | from ..attributes import is_complex_attribute |
30 | 30 | from ..base import BaseModel |
31 | 31 | from ..base import BaseModelType |
32 | | -from ..reference import ExternalReference |
33 | | -from ..reference import URIReference |
| 32 | +from ..reference import Reference |
34 | 33 | from ..utils import UNION_TYPES |
35 | 34 | from ..utils import normalize_attribute_name |
36 | 35 |
|
@@ -317,22 +316,6 @@ def model_to_schema(model: type[BaseModel]) -> "Schema": |
317 | 316 | return schema |
318 | 317 |
|
319 | 318 |
|
320 | | -def get_reference_types(type) -> list[str]: |
321 | | - first_arg = get_args(type)[0] |
322 | | - types = get_args(first_arg) if get_origin(first_arg) in UNION_TYPES else [first_arg] |
323 | | - |
324 | | - def serialize_ref_type(ref_type: type) -> str: |
325 | | - if ref_type == URIReference: |
326 | | - return "uri" |
327 | | - |
328 | | - elif ref_type == ExternalReference: |
329 | | - return "external" |
330 | | - |
331 | | - return get_args(ref_type)[0] |
332 | | - |
333 | | - return list(map(serialize_ref_type, types)) |
334 | | - |
335 | | - |
336 | 319 | def model_attribute_to_scim_attribute( |
337 | 320 | model: type[BaseModel], attribute_name: str |
338 | 321 | ) -> "Attribute": |
@@ -369,7 +352,7 @@ def model_attribute_to_scim_attribute( |
369 | 352 | returned=model.get_field_annotation(attribute_name, Returned), |
370 | 353 | uniqueness=model.get_field_annotation(attribute_name, Uniqueness), |
371 | 354 | sub_attributes=sub_attributes, |
372 | | - reference_types=get_reference_types(root_type) |
| 355 | + reference_types=Reference.get_types(root_type) |
373 | 356 | if attribute_type == Attribute.Type.reference |
374 | 357 | else None, |
375 | 358 | ) |
0 commit comments