{"id":8624,"library":"scim2-models","title":"SCIM2 Models","description":"scim2-models is a Python library providing Pydantic models for SCIM (System for Cross-domain Identity Management) schemas, specifically RFC7643 and RFC7644. It facilitates the serialization and validation of SCIM2 payloads using native Python objects. The library includes features like context-aware validation and dynamic schema extensions, serving as a foundational block for building SCIM2 servers and clients. The current version is 0.6.12, and it is actively maintained with frequent releases.","status":"active","version":"0.6.12","language":"en","source_language":"en","source_url":"https://github.com/python-scim/scim2-models","tags":["SCIM","identity management","provisioning","pydantic","validation","schemas","RFC7643","RFC7644"],"install":[{"cmd":"pip install scim2-models","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for defining and validating SCIM schemas.","package":"pydantic"}],"imports":[{"note":"Commonly imported SCIM core resource.","symbol":"User","correct":"from scim2_models.resources import User"},{"note":"Commonly imported SCIM core resource.","symbol":"Group","correct":"from scim2_models.resources import Group"},{"note":"Used for managing SCIM schemas themselves.","symbol":"Schema","correct":"from scim2_models.schemas import Schema"}],"quickstart":{"code":"from scim2_models.resources import User\nfrom pydantic import ValidationError\n\nuser_data = {\n    \"schemas\": [\"urn:ietf:params:scim:schemas:core:2.0:User\"],\n    \"userName\": \"bjensen@example.com\",\n    \"id\": \"2819c223-7f76-453a-919d-413861904646\",\n    \"name\": {\n        \"givenName\": \"Babs\",\n        \"familyName\": \"Jensen\"\n    },\n    \"emails\": [\n        {\n            \"value\": \"bjensen@example.com\",\n            \"type\": \"work\",\n            \"primary\": True\n        }\n    ],\n    \"meta\": {\n        \"resourceType\": \"User\",\n        \"created\": \"2024-04-13T12:00:00Z\",\n        \"lastModified\": \"2024-04-13T12:00:00Z\",\n        \"location\": \"https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646\"\n    }\n}\n\ntry:\n    user = User.model_validate(user_data)\n    print(f\"Successfully validated user: {user.user_name}\")\n    print(f\"User ID: {user.id}\")\nexcept ValidationError as e:\n    print(f\"Validation error: {e}\")\n\n# You can also create a user directly\nnew_user = User(\n    userName=\"testuser\",\n    emails=[{\"value\": \"test@example.com\", \"type\": \"work\", \"primary\": True}]\n)\nprint(f\"Created new user: {new_user.model_dump_json(indent=2)}\")","lang":"python","description":"This quickstart demonstrates how to validate an existing SCIM User payload against the `User` model and how to construct a new `User` object directly. The `model_validate` method from Pydantic is used for parsing dictionary data, and `model_dump_json` for serialization."},"warnings":[{"fix":"If you have custom SCIM resource models, update them to use `__schema__ = [\"urn:ietf:params:scim:schemas:core:2.0:User\"]` (or your specific URN) as a class variable instead of a default value for a 'schemas' field.","message":"In version 0.6.0, the mechanism for defining schema URNs on custom SCIM resource models changed. Resources now define their schema URN with a `__schema__` class variable instead of a `schemas` default value.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Be prepared for potential API adjustments when upgrading, and consult the changelog for details on each new release.","message":"The library is officially marked as '3 - Alpha' status on PyPI. This indicates that the API might still be unstable, and backward-incompatible changes could occur in minor versions without strict adherence to semantic versioning until a stable '1.0' release.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Always consider the SCIM operation context when validating payloads. If validation errors occur unexpectedly, verify that the `context` parameter (if used) correctly reflects the intended SCIM operation.","message":"The library supports context-aware validation (e.g., for creation, query, or replacement operations). This means that validation behavior can differ based on the `context` parameter provided to validation methods. An attribute that is optional during a PUT (replacement) might be required during a POST (creation).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Review the SCIM RFCs (e.g., RFC7643 Section 2 for core resources) or your custom schema definitions to identify all mandatory attributes. Ensure the JSON payload includes all required fields with correct data types.","cause":"The input JSON payload is missing a required attribute as defined by the SCIM schema (RFC7643/7644) or a custom schema extension. This is a common Pydantic validation error when data does not conform.","error":"pydantic.ValidationError: ... field required (type=value_error.missing)"},{"fix":"If you were accessing a class-level `schemas` attribute, update your code to use the `__schema__` class variable directly or instantiate the model and access the `schemas` field from the instance (which is dynamically populated based on `__schema__`). For custom models, ensure `__schema__` is defined as a class variable.","cause":"This error typically occurs if you've upgraded from `scim2-models <0.6.0` to `0.6.0` or later and your code or custom models relied on accessing a `schemas` attribute directly from a resource class. The `schemas` field was replaced by the `__schema__` class variable.","error":"AttributeError: type object 'User' has no attribute 'schemas'"}]}