Name | jsonschematools JSON |
Version |
0.2.0
JSON |
| download |
home_page | |
Summary | Utilities for working with JSON Schema. |
upload_time | 2024-01-08 19:07:36 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.11 |
license | |
keywords |
json
python
schema
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# jsonschematools
## Description
`jsonschematools` is a Python library that provides utilities for working with JSON Schema. It includes features for adding and updating enums in the `$defs` section of a JSON schema, and updating a property of a JSON schema with an existing enum reference.
## Installation
To install `jsonschematools`, you can use pip:
```bash
pip install jsonschematools
```
## Usage
Here is a basic example of how to use `jsonschematools`:
```python
from jsonschematools.enums import add_or_update_enum_in_defs, update_property_with_enum
# Define a basic schema
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"tags": {"type": "array", "items": {"type": "string"}},
},
"$defs": {},
}
# Add a new enum to the schema
schema = add_or_update_enum_in_defs(schema, "Colors", ["Red", "Blue", "Green"])
# schema now looks like this:
# {
# "type": "object",
# "properties": {
# "name": {
# "type": "string"
# },
# "tags": {
# "type": "array",
# "items": {
# "type": "string"
# }
# }
# },
# "$defs": {
# "Colors": {
# "type": "string",
# "enum": [
# "Red",
# "Blue",
# "Green"
# ]
# }
# }
# }
# Update a property with the new enum
schema = update_property_with_enum(schema, "Colors", "tags")
# schema now looks like this:
# {
# "type": "object",
# "properties": {
# "name": {
# "type": "string"
# },
# "tags": {
# "type": "array",
# "items": {
# "$ref": "#/$defs/Colors"
# }
# }
# },
# "$defs": {
# "Colors": {
# "type": "string",
# "enum": [
# "Red",
# "Blue",
# "Green"
# ]
# }
# }
# }
```
## Testing
Tests are written using pytest. To run the tests, use the following command:
```bash
pytest
```
## Contributing
Contributions are welcome! Please fork the repository and create a pull request with your changes.
## License
`jsonschematools` is licensed under the MIT License.
## Contact
For any questions or concerns, please open an issue on GitHub.
Raw data
{
"_id": null,
"home_page": "",
"name": "jsonschematools",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "json,python,schema",
"author": "",
"author_email": "Dustin Wyatt <dustin.wyatt@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/20/3c/4587670ac66730adb471600869f2c6cbf183a1e1c13aee1ba75fd6109800/jsonschematools-0.2.0.tar.gz",
"platform": null,
"description": "# jsonschematools\n\n## Description\n`jsonschematools` is a Python library that provides utilities for working with JSON Schema. It includes features for adding and updating enums in the `$defs` section of a JSON schema, and updating a property of a JSON schema with an existing enum reference.\n\n## Installation\nTo install `jsonschematools`, you can use pip:\n\n```bash\npip install jsonschematools\n```\n\n## Usage\nHere is a basic example of how to use `jsonschematools`:\n\n```python\nfrom jsonschematools.enums import add_or_update_enum_in_defs, update_property_with_enum\n\n# Define a basic schema\nschema = {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\"type\": \"string\"},\n \"tags\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}},\n },\n \"$defs\": {},\n}\n\n# Add a new enum to the schema\nschema = add_or_update_enum_in_defs(schema, \"Colors\", [\"Red\", \"Blue\", \"Green\"])\n\n# schema now looks like this:\n# {\n# \"type\": \"object\",\n# \"properties\": {\n# \"name\": {\n# \"type\": \"string\"\n# },\n# \"tags\": {\n# \"type\": \"array\",\n# \"items\": {\n# \"type\": \"string\"\n# }\n# }\n# },\n# \"$defs\": {\n# \"Colors\": {\n# \"type\": \"string\",\n# \"enum\": [\n# \"Red\",\n# \"Blue\",\n# \"Green\"\n# ]\n# }\n# }\n# }\n\n# Update a property with the new enum\nschema = update_property_with_enum(schema, \"Colors\", \"tags\")\n\n# schema now looks like this:\n# {\n# \"type\": \"object\",\n# \"properties\": {\n# \"name\": {\n# \"type\": \"string\"\n# },\n# \"tags\": {\n# \"type\": \"array\",\n# \"items\": {\n# \"$ref\": \"#/$defs/Colors\"\n# }\n# }\n# },\n# \"$defs\": {\n# \"Colors\": {\n# \"type\": \"string\",\n# \"enum\": [\n# \"Red\",\n# \"Blue\",\n# \"Green\"\n# ]\n# }\n# }\n# }\n```\n\n## Testing\nTests are written using pytest. To run the tests, use the following command:\n\n```bash\npytest\n```\n\n## Contributing\nContributions are welcome! Please fork the repository and create a pull request with your changes.\n\n## License\n`jsonschematools` is licensed under the MIT License.\n\n## Contact\nFor any questions or concerns, please open an issue on GitHub.\n",
"bugtrack_url": null,
"license": "",
"summary": "Utilities for working with JSON Schema.",
"version": "0.2.0",
"project_urls": {
"Repository": "https://github.com/dmwyatt/jsonschematools"
},
"split_keywords": [
"json",
"python",
"schema"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "405f94c949447c8b5420ed95e9ec45f30735c807cfcd7c77fb37631c3a61b3a9",
"md5": "2ed6e70efe6ac727accd1c1b6a6283ce",
"sha256": "0a9cd88a96631f653611d9aa36b1d4277e04998c9f620a1c146af3cc28e3ad03"
},
"downloads": -1,
"filename": "jsonschematools-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2ed6e70efe6ac727accd1c1b6a6283ce",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 5636,
"upload_time": "2024-01-08T19:07:32",
"upload_time_iso_8601": "2024-01-08T19:07:32.529566Z",
"url": "https://files.pythonhosted.org/packages/40/5f/94c949447c8b5420ed95e9ec45f30735c807cfcd7c77fb37631c3a61b3a9/jsonschematools-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "203c4587670ac66730adb471600869f2c6cbf183a1e1c13aee1ba75fd6109800",
"md5": "68e515de2dd5e57cecf44d9ff566123e",
"sha256": "ef1b0fc071c7633f9f4b9a313a1e31cf08ce698efc860c68e4c12875c5b05277"
},
"downloads": -1,
"filename": "jsonschematools-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "68e515de2dd5e57cecf44d9ff566123e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 6069,
"upload_time": "2024-01-08T19:07:36",
"upload_time_iso_8601": "2024-01-08T19:07:36.201599Z",
"url": "https://files.pythonhosted.org/packages/20/3c/4587670ac66730adb471600869f2c6cbf183a1e1c13aee1ba75fd6109800/jsonschematools-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-08 19:07:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dmwyatt",
"github_project": "jsonschematools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "jsonschematools"
}