Skip to content

Commit f228849

Browse files
committed
fix: add the Required.true flag to schemas
1 parent d131d07 commit f228849

18 files changed

Lines changed: 68 additions & 27 deletions

scim2_models/rfc7643/enterprise_user.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class Manager(ComplexAttribute):
2626

2727

2828
class EnterpriseUser(Extension):
29-
schemas: list[str] = ["urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"]
29+
schemas: Annotated[list[str], Required.true] = [
30+
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
31+
]
3032

3133
employee_number: Optional[str] = None
3234
"""Numeric or alphanumeric identifier assigned to a person, typically based

scim2_models/rfc7643/group.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ..base import MultiValuedComplexAttribute
99
from ..base import Mutability
1010
from ..base import Reference
11+
from ..base import Required
1112
from .resource import Resource
1213

1314

@@ -31,7 +32,9 @@ class GroupMember(MultiValuedComplexAttribute):
3132

3233

3334
class Group(Resource):
34-
schemas: list[str] = ["urn:ietf:params:scim:schemas:core:2.0:Group"]
35+
schemas: Annotated[list[str], Required.true] = [
36+
"urn:ietf:params:scim:schemas:core:2.0:Group"
37+
]
3538

3639
display_name: Optional[str] = None
3740
"""A human-readable name for the Group."""

scim2_models/rfc7643/resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __new__(cls, name, bases, attrs, **kwargs):
136136

137137

138138
class Resource(BaseModel, Generic[AnyExtension], metaclass=ResourceMetaclass):
139-
schemas: list[str]
139+
schemas: Annotated[list[str], Required.true]
140140
"""The "schemas" attribute is a REQUIRED attribute and is an array of
141141
Strings containing URIs that are used to indicate the namespaces of the
142142
SCIM schemas that define the attributes present in the current JSON
@@ -229,7 +229,7 @@ def get_by_payload(resource_types: list[type], payload: dict, **kwargs):
229229
return Resource.get_by_schema(resource_types, schema, **kwargs)
230230

231231
@field_serializer("schemas")
232-
def set_extension_schemas(self, schemas: list[str]):
232+
def set_extension_schemas(self, schemas: Annotated[list[str], Required.true]):
233233
"""Add model extension ids to the 'schemas' attribute."""
234234
extension_schemas = self.get_extension_models().keys()
235235
schemas = self.schemas + [

scim2_models/rfc7643/resource_type.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class SchemaExtension(ComplexAttribute):
3535

3636

3737
class ResourceType(Resource):
38-
schemas: list[str] = ["urn:ietf:params:scim:schemas:core:2.0:ResourceType"]
38+
schemas: Annotated[list[str], Required.true] = [
39+
"urn:ietf:params:scim:schemas:core:2.0:ResourceType"
40+
]
3941

4042
name: Annotated[Optional[str], Mutability.read_only, Required.true] = None
4143
"""The resource type name.

scim2_models/rfc7643/schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def make_python_model(
6565
if attr.name
6666
}
6767
pydantic_attributes["schemas"] = (
68-
Optional[list[str]],
68+
Annotated[list[str], Required.true],
6969
Field(default=[obj.id]),
7070
)
7171

@@ -240,7 +240,9 @@ def to_python(self) -> Optional[tuple[Any, Field]]:
240240

241241

242242
class Schema(Resource):
243-
schemas: list[str] = ["urn:ietf:params:scim:schemas:core:2.0:Schema"]
243+
schemas: Annotated[list[str], Required.true] = [
244+
"urn:ietf:params:scim:schemas:core:2.0:Schema"
245+
]
244246

245247
id: Annotated[Optional[str], Mutability.read_only, Required.true] = None
246248
"""The unique URI of the schema."""

scim2_models/rfc7643/service_provider_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ class Type(str, Enum):
9494

9595

9696
class ServiceProviderConfig(Resource):
97-
schemas: list[str] = ["urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"]
97+
schemas: Annotated[list[str], Required.true] = [
98+
"urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"
99+
]
98100

99101
id: Annotated[
100102
Optional[str], Mutability.read_only, Returned.default, Uniqueness.global_

scim2_models/rfc7643/user.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ class X509Certificate(MultiValuedComplexAttribute):
214214

215215

216216
class User(Resource):
217-
schemas: list[str] = ["urn:ietf:params:scim:schemas:core:2.0:User"]
217+
schemas: Annotated[list[str], Required.true] = [
218+
"urn:ietf:params:scim:schemas:core:2.0:User"
219+
]
218220

219221
user_name: Annotated[Optional[str], Uniqueness.server, Required.true] = None
220222
"""Unique identifier for the User, typically used by the user to directly

scim2_models/rfc7644/bulk.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pydantic import PlainSerializer
88

99
from ..base import ComplexAttribute
10+
from ..base import Required
1011
from ..utils import int_to_str
1112
from .message import Message
1213

@@ -53,7 +54,9 @@ class BulkRequest(Message):
5354
The models for Bulk operations are defined, but their behavior is not implemented nor tested yet.
5455
"""
5556

56-
schemas: list[str] = ["urn:ietf:params:scim:api:messages:2.0:BulkRequest"]
57+
schemas: Annotated[list[str], Required.true] = [
58+
"urn:ietf:params:scim:api:messages:2.0:BulkRequest"
59+
]
5760

5861
fail_on_errors: Optional[int] = None
5962
"""An integer specifying the number of errors that the service provider
@@ -74,7 +77,9 @@ class BulkResponse(Message):
7477
The models for Bulk operations are defined, but their behavior is not implemented nor tested yet.
7578
"""
7679

77-
schemas: list[str] = ["urn:ietf:params:scim:api:messages:2.0:BulkResponse"]
80+
schemas: Annotated[list[str], Required.true] = [
81+
"urn:ietf:params:scim:api:messages:2.0:BulkResponse"
82+
]
7883

7984
operations: Optional[list[BulkOperation]] = Field(
8085
None, serialization_alias="Operations"

scim2_models/rfc7644/error.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33

44
from pydantic import PlainSerializer
55

6+
from ..base import Required
67
from ..utils import int_to_str
78
from .message import Message
89

910

1011
class Error(Message):
1112
"""Representation of SCIM API errors."""
1213

13-
schemas: list[str] = ["urn:ietf:params:scim:api:messages:2.0:Error"]
14+
schemas: Annotated[list[str], Required.true] = [
15+
"urn:ietf:params:scim:api:messages:2.0:Error"
16+
]
1417

1518
status: Annotated[Optional[int], PlainSerializer(int_to_str)] = None
1619
"""The HTTP status code (see Section 6 of [RFC7231]) expressed as a JSON

scim2_models/rfc7644/list_response.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from ..base import BaseModel
1919
from ..base import BaseModelType
2020
from ..base import Context
21+
from ..base import Required
2122
from ..rfc7643.resource import AnyResource
2223
from .message import Message
2324

@@ -78,7 +79,9 @@ def __new__(cls, name, bases, attrs, **kwargs):
7879

7980

8081
class ListResponse(Message, Generic[AnyResource], metaclass=ListResponseMetaclass):
81-
schemas: list[str] = ["urn:ietf:params:scim:api:messages:2.0:ListResponse"]
82+
schemas: Annotated[list[str], Required.true] = [
83+
"urn:ietf:params:scim:api:messages:2.0:ListResponse"
84+
]
8285

8386
total_results: Optional[int] = None
8487
"""The total number of results returned by the list or query operation."""

0 commit comments

Comments
 (0)