{"id":2271,"library":"safety-schemas","title":"safety-schemas","description":"safety-schemas (version 0.0.18) provides Pydantic models and schemas used by the Safety CLI tool for defining structures like vulnerability database files, policy files, and JSON output formats. It serves as a foundational library for standardizing data structures within the Safety ecosystem. The library is actively maintained with a regular release cadence, often aligned with updates to the main Safety CLI.","status":"active","version":"0.0.18","language":"en","source_language":"en","source_url":"https://github.com/pyupio/safety_schemas","tags":["schemas","pydantic","safety","vulnerability","cli-tooling"],"install":[{"cmd":"pip install safety-schemas","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides the base models for defining schemas.","package":"pydantic","optional":false}],"imports":[{"symbol":"ConfigModel","correct":"from safety_schemas.models import ConfigModel"},{"symbol":"VulnerabilitySeverityLabels","correct":"from safety_schemas.models import VulnerabilitySeverityLabels"},{"symbol":"Stage","correct":"from safety_schemas.models import Stage"},{"symbol":"Ecosystem","correct":"from safety_schemas.models import Ecosystem"}],"quickstart":{"code":"from safety_schemas.models import VulnerabilitySeverityLabels\n\n# Example of using a Pydantic model from safety-schemas\n# This model defines the structure for vulnerability severity labels.\n\ntry:\n    # Instantiate a model instance with valid data\n    severity_labels = VulnerabilitySeverityLabels(\n        critical='Critical',\n        high='High',\n        medium='Medium',\n        low='Low',\n        unknown='Unknown'\n    )\n    print(f\"Successfully created severity labels: {severity_labels.model_dump_json(indent=2)}\")\n\n    # Accessing fields\n    print(f\"High severity label: {severity_labels.high}\")\n\n    # Attempting to create an invalid instance (Pydantic will raise ValidationError)\n    # Note: Pydantic models are strict by default on extra fields unless configured otherwise\n    # For demonstration, let's assume valid input for required fields.\n\nexcept Exception as e:\n    print(f\"Error creating severity labels: {e}\")","lang":"python","description":"This quickstart demonstrates how to import and instantiate a Pydantic model, `VulnerabilitySeverityLabels`, from the `safety_schemas.models` module. It shows basic data assignment, access to model fields, and how Pydantic's validation ensures data integrity upon instantiation."},"warnings":[{"fix":"Ensure you are using the latest version of `safety-schemas` (0.0.18 or newer) as dependency pins are often relaxed in later releases. If conflicts persist, explicitly pin `packaging` and `pydantic` to versions compatible with your `safety-schemas` version, or consider using a dedicated virtual environment.","message":"Older versions of `safety-schemas` (e.g., 0.0.1) had strict upper version pins for `packaging` and `pydantic` that could lead to dependency conflicts, especially with newer Python environments (e.g., Python 3.8+ running Pydantic 2.x). This resulted in `safety` CLI being broken on affected Python versions.","severity":"gotcha","affected_versions":"0.0.1 to potentially other early 0.x.x versions"},{"fix":"Refer to the `safety` CLI's GitHub repository (`pyupio/safety`) to understand how `safety-schemas` models are consumed and integrated within the broader Safety ecosystem. For general Pydantic usage, consult the Pydantic documentation.","message":"The `safety-schemas` library is primarily an internal dependency of the `safety` CLI tool. While its Pydantic models are importable, it lacks extensive standalone documentation for external usage. Direct programmatic use might require inspecting the `safety` CLI source code for usage patterns.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}