{"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":"python","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,"search_vec":"'0.0.18':8 'activ':50 'align':58 'cadenc':56 'cli':18,65,71 'cli-tool':70 'data':41 'databas':25 'defin':21 'ecosystem':46 'file':26,28 'format':32 'foundat':37 'json':30 'librari':38,48 'like':23 'main':63 'maintain':51 'model':11 'often':57 'output':31 'polici':27 'provid':9 'pydant':10,67 'regular':54 'releas':55 'safeti':2,5,17,45,64,68 'safety-schema':1,4 'schema':3,6,13,66 'serv':34 'standard':40 'structur':22,42 'tool':19,72 'updat':60 'use':14 'version':7 'vulner':24,69 'within':43","created_at":"2026-04-09T18:50:50.258536+00:00","updated_at":"2026-04-16T21:17:21.369682+00:00","problems":[{"fix":"pip install safety-schemas","cause":"The `safety-schemas` library has not been installed in your Python environment or is not accessible on the Python path.","error":"ModuleNotFoundError: No module named 'safety_schemas'"},{"fix":"from safety_schemas.models import Vulnerability","cause":"Pydantic models like 'Vulnerability' are located within the `safety_schemas.models` submodule, not directly under the top-level `safety_schemas` package.","error":"ImportError: cannot import name 'Vulnerability' from 'safety_schemas'"},{"fix":"from safety_schemas.models import Vulnerability\n\n# Ensure all required fields are present and correctly typed\nvalid_data = {\n    \"package_name\": \"example-package\",\n    \"vulnerability_id\": \"GHSA-xxxx-xxxx-xxxx\",\n    \"analyzed_version\": \"1.0.0\",\n    \"vulnerable_version_range\": \"<1.0.0\",\n    \"published_date\": \"2023-01-01T00:00:00Z\",\n    \"advisory\": \"A test advisory description.\"\n}\nvulnerability_instance = Vulnerability(**valid_data)","cause":"The data provided to instantiate a `safety-schemas` Pydantic model does not conform to its defined schema, leading to validation failure.","error":"pydantic.ValidationError"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.0.20","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pyupio/safety_schemas","docs":null,"changelog":null,"pypi":"https://pypi.org/project/safety-schemas/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","auth-security","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}