Skip to content

Commit 972bd8f

Browse files
authored
Merge pull request #76 from yaal-coop/issue-75-pydantic-discriminator
pydantic discriminator issue introduced with pydantic 2.9.0
2 parents 6a7d71c + 4574ebc commit 972bd8f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

doc/changelog.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
[0.2.2] - Unreleased
5+
--------------------
6+
7+
Fixed
8+
^^^^^
9+
- :class:`~scim2_models.ListResponse` pydantic discriminator issue introduced with pydantic 2.9.0. #75
10+
411
[0.2.1] - 2024-09-06
512
--------------------
613

scim2_models/rfc7644/list_response.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ def get_schema_from_payload(payload: Any) -> Optional[str]:
3939
if not payload:
4040
return None
4141

42+
payload_schemas = (
43+
payload.get("schemas", [])
44+
if isinstance(payload, dict)
45+
else getattr(payload, "schemas")
46+
)
47+
4248
resource_types_schemas = [
4349
resource_type.model_fields["schemas"].default[0]
4450
for resource_type in resource_types
4551
]
4652
common_schemas = [
47-
schema
48-
for schema in payload.get("schemas", [])
49-
if schema in resource_types_schemas
53+
schema for schema in payload_schemas if schema in resource_types_schemas
5054
]
5155
return common_schemas[0] if common_schemas else None
5256

0 commit comments

Comments
 (0)