jsonschema-validator-new


Namejsonschema-validator-new JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/sbrunner/jsonschema-validator
SummaryTool to validate files against a JSON Schema
upload_time2023-04-10 10:03:04
maintainer
docs_urlNone
authorStéphane Brunner
requires_python>=3.8,<4
licenseBSD-2-Clause
keywords jsonschema types
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JSON Schema validator

Tools to generate Python types based on TypedDict from a JSON schema

## Quick start

install:

```bash
python3 -m pip install --user jsonschema-validator
```

Convert a JSON schema to a Python file contains the types:

```bash
jsonschema-validator --help
```

## Default

The default values are exported in the Python file, then you can do something like that:

```python
value_with_default = my_object.get('field_name', my_schema.FIELD_DEFAULT)
```

## Validation

This package also provide some validations features for YAML file based on `jsonschema`.

Additional features:

- Obtain the line and columns number in the errors, if the file is loaded with `ruamel.yaml`.
- Export the default provided in the JSON schema.

```python
    import ruamel.yaml
    import pkgutil
    import jsonschema_validator

    schema_data = pkgutil.get_data("<package>", "schema.json")
    with open(filename) as data_file:
        yaml = ruamel.yaml.YAML()  # type: ignore
        data = yaml.load(data_file)
    errors, data = jsonschema_validator.validate(filename, data, schema)
    if errors:
        print("\n".join(errors))
        sys.exit(1)
```

## Pre-commit hooks

This project provides pre-commit hooks to automatically generate the files.

```yaml
repos:
  - repo: https://github.com/camptocamp/jsonschema-validator
    rev: <version> # Use the ref you want to point at
    hools:
      - id: jsonschema-validator
        files: |
          (?x)^(
              ...
          )$
```

## Contributing

Install the pre-commit hooks:

```bash
pip install pre-commit
pre-commit install --allow-missing-config
```

The `prospector` tests should pass.

The code should be typed.

The code should be tested with `pytests`.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sbrunner/jsonschema-validator",
    "name": "jsonschema-validator-new",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4",
    "maintainer_email": "",
    "keywords": "jsonschema,types",
    "author": "St\u00e9phane Brunner",
    "author_email": "stephane.brunner@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bd/35/8f4f628092cb0be6c26f22c3813fa3e4e04cf52f870baf943e6758ea2a0f/jsonschema_validator_new-0.1.0.tar.gz",
    "platform": null,
    "description": "# JSON Schema validator\n\nTools to generate Python types based on TypedDict from a JSON schema\n\n## Quick start\n\ninstall:\n\n```bash\npython3 -m pip install --user jsonschema-validator\n```\n\nConvert a JSON schema to a Python file contains the types:\n\n```bash\njsonschema-validator --help\n```\n\n## Default\n\nThe default values are exported in the Python file, then you can do something like that:\n\n```python\nvalue_with_default = my_object.get('field_name', my_schema.FIELD_DEFAULT)\n```\n\n## Validation\n\nThis package also provide some validations features for YAML file based on `jsonschema`.\n\nAdditional features:\n\n- Obtain the line and columns number in the errors, if the file is loaded with `ruamel.yaml`.\n- Export the default provided in the JSON schema.\n\n```python\n    import ruamel.yaml\n    import pkgutil\n    import jsonschema_validator\n\n    schema_data = pkgutil.get_data(\"<package>\", \"schema.json\")\n    with open(filename) as data_file:\n        yaml = ruamel.yaml.YAML()  # type: ignore\n        data = yaml.load(data_file)\n    errors, data = jsonschema_validator.validate(filename, data, schema)\n    if errors:\n        print(\"\\n\".join(errors))\n        sys.exit(1)\n```\n\n## Pre-commit hooks\n\nThis project provides pre-commit hooks to automatically generate the files.\n\n```yaml\nrepos:\n  - repo: https://github.com/camptocamp/jsonschema-validator\n    rev: <version> # Use the ref you want to point at\n    hools:\n      - id: jsonschema-validator\n        files: |\n          (?x)^(\n              ...\n          )$\n```\n\n## Contributing\n\nInstall the pre-commit hooks:\n\n```bash\npip install pre-commit\npre-commit install --allow-missing-config\n```\n\nThe `prospector` tests should pass.\n\nThe code should be typed.\n\nThe code should be tested with `pytests`.\n\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause",
    "summary": "Tool to validate files against a JSON Schema",
    "version": "0.1.0",
    "split_keywords": [
        "jsonschema",
        "types"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29607cc7d6855a2e5e39122683708c1a9b32cc0ca7e7f8ed6926ea33680efa3b",
                "md5": "ab628bc155113e29c278a70192ba6227",
                "sha256": "f93e1a4ca92079f28fbad2b43a1733b5d51c6cc4c7fd327689a63a90b77cf4ff"
            },
            "downloads": -1,
            "filename": "jsonschema_validator_new-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ab628bc155113e29c278a70192ba6227",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4",
            "size": 7612,
            "upload_time": "2023-04-10T10:03:02",
            "upload_time_iso_8601": "2023-04-10T10:03:02.047295Z",
            "url": "https://files.pythonhosted.org/packages/29/60/7cc7d6855a2e5e39122683708c1a9b32cc0ca7e7f8ed6926ea33680efa3b/jsonschema_validator_new-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd358f4f628092cb0be6c26f22c3813fa3e4e04cf52f870baf943e6758ea2a0f",
                "md5": "6ccbf7eaaf22ceaed33bbe9d92353978",
                "sha256": "deac226a3288222e9f1eb73267e496e33a598270529b31629f2407620a6dde37"
            },
            "downloads": -1,
            "filename": "jsonschema_validator_new-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6ccbf7eaaf22ceaed33bbe9d92353978",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4",
            "size": 6823,
            "upload_time": "2023-04-10T10:03:04",
            "upload_time_iso_8601": "2023-04-10T10:03:04.235526Z",
            "url": "https://files.pythonhosted.org/packages/bd/35/8f4f628092cb0be6c26f22c3813fa3e4e04cf52f870baf943e6758ea2a0f/jsonschema_validator_new-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-10 10:03:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "sbrunner",
    "github_project": "jsonschema-validator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "jsonschema-validator-new"
}
        
Elapsed time: 0.05315s