{"id":5824,"library":"voluptuous-serialize","title":"Voluptuous Serialize","description":"Voluptuous Serialize is a Python library designed to convert `voluptuous` schemas into dictionaries, making them easily serializable (e.g., to JSON). It is built upon the `voluptuous` data validation library, extending its utility by providing a structured representation of schemas. The current version is 2.7.0, and it appears to have an active release cadence, with the latest version released in August 2025.","status":"active","version":"2.7.0","language":"en","source_language":"en","source_url":"https://github.com/home-assistant-libs/voluptuous-serialize","tags":["voluptuous","schema","serialization","json","validation","home-assistant"],"install":[{"cmd":"pip install voluptuous-serialize","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core dependency for defining schemas that voluptuous-serialize converts.","package":"voluptuous","optional":false}],"imports":[{"note":"The main function to serialize a voluptuous schema.","symbol":"convert","correct":"from voluptuous_serialize import convert"},{"note":"Standard import alias for creating voluptuous schemas.","symbol":"vol","correct":"import voluptuous as vol"}],"quickstart":{"code":"import voluptuous as vol\nfrom voluptuous_serialize import convert\n\nschema = vol.Schema({\n    vol.Required(\"name\"): vol.All(str, vol.Length(min=5)),\n    vol.Required(\"age\"): vol.All(vol.Coerce(int), vol.Range(min=18)),\n    vol.Optional(\"email\", default=\"\"): str,\n    vol.Optional(\"tags\", default=[]): [str]\n})\n\nserialized_schema = convert(schema)\nprint(serialized_schema)\n\n# Example of output structure (simplified):\n# [\n#     {'name': 'name', 'type': 'string', 'lengthMin': 5, 'required': True},\n#     {'name': 'age', 'type': 'integer', 'valueMin': 18, 'required': True},\n#     {'name': 'email', 'type': 'string', 'default': '', 'required': False},\n#     {'name': 'tags', 'type': 'array', 'items': {'type': 'string'}, 'default': [], 'required': False}\n# ]","lang":"python","description":"This quickstart demonstrates how to define a `voluptuous` schema and then use `voluptuous-serialize.convert` to transform it into a dictionary representation. The output is a list of dictionaries, each describing a field in the schema, including its name, type, and validation rules."},"warnings":[{"fix":"Replace `vol.Optional('key', optional=True)` or schema outputs containing `\"optional\": true` with `vol.Optional('key')` which results in `\"required\": false` in the serialized output.","message":"The use of `\"optional\": true` within schema definitions is deprecated. Users should instead rely on the `\"required\"` key to indicate optional fields (i.e., `\"required\": false`).","severity":"deprecated","affected_versions":"All versions where 'required' key is the preferred method (explicitly mentioned in 2.7.0 docs)."},{"fix":"Be aware that external use might require monitoring updates closely for HA-specific changes. Consider if your use case aligns with the implicit design goals of a library primarily maintained for another project.","message":"The library's GitHub README explicitly states it's for 'internal use of HA only' (Home Assistant). While usable by others, this suggests development priorities may align specifically with Home Assistant's needs, potentially leading to design choices or breaking changes that prioritize HA compatibility over general-purpose use cases.","severity":"gotcha","affected_versions":"All versions, as this is a stated intent/scope."},{"fix":"Users should be aware of the upstream maintenance status. Report issues to both `voluptuous-serialize` and, if applicable, directly to the `voluptuous` project, and consider contributing fixes if critical issues arise.","message":"The upstream `voluptuous` library, which `voluptuous-serialize` depends on, is in 'CONTRIBUTIONS ONLY' mode, as stated on its GitHub page. This implies that the original author is no longer actively fixing issues or adding features, relying solely on community pull requests. This could impact the long-term stability and responsiveness to bugs in the underlying validation logic.","severity":"gotcha","affected_versions":"All versions, due to upstream dependency status."}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}