Open azmeuk opened 5 months ago
This test should pass:
def test_canonical_values():
class Model(Resource):
class Foo(str, Enum):
bar = "bar"
baz = "baz"
schemas: List[str] = ["urn:example:2.0:Model"]
foo: Optional[Foo]
valid = Model(foo="bar")
assert valid.foo == "bar"
valid = Model(foo="invalid")
assert valid.foo is None
RFC7643 §2.3.1 indicates that string types with canonical values defined can or cannot have other values, depending on the server configuration:
In §7 it is indicated that values can be ignored:
Currently scim2_models defines custom enums, but that makes pydantic enforce those values only.
https://github.com/yaal-coop/scim2-models/blob/56287ad73027f6e6825d41e0b0c6ef0a339f4f18/scim2_models/rfc7643/user.py#L44-L48
https://github.com/yaal-coop/scim2-models/blob/56287ad73027f6e6825d41e0b0c6ef0a339f4f18/scim2_models/rfc7643/user.py#L56-L57
In that situation scim2-models should accept both arbitrary and enum values.
Also, when #6 is implemented, scim2-models should generate dynamic enums.