pydantic-schema-sync


Namepydantic-schema-sync JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummarySynchronise Pydantic model schemas with JSONSchema files
upload_time2024-08-28 09:59:11
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pydantic-schema-sync

Synchronise Pydantic model schemas with JSONSchema files.

## Usage

### CLI

```
usage: model-schema-sync [-h] [--model MODEL] [--schema_path SCHEMA_PATH]
                         [--mjs_kwargs MJS_KWARGS]

Config for syncing Pydantic model schemas to disk.

options:
  -h, --help            show this help message and exit
  --model MODEL         Dotted import path to the Pydantic model
  --schema_path SCHEMA_PATH
                        File path to save the schema at
  --mjs_kwargs MJS_KWARGS
                        Kwargs to pass `.model_json_schema()`
```

To serialise the schema of the model named `SyncCLI` (in the package `pydantic_schema_sync`'s `cli` module)
to the file `schema.json`, passing the `by_alias=False` param to `.model_json_schema()`:

```sh
model-schema-sync \
  --model pydantic_schema_sync.cli.SyncCLI \
  --schema_path schema.json \
  --mjs_kwargs '{"by_alias": false}'
```

### Python

From a model class:

```py
from pydantic_schema_sync import sync_schema

# Using field alias (default)
sync_schema(model=Foo, schema_path="schema.json")

# Unaliased field
sync_schema(model=Foo, schema_path="schema.json", mjs_kwargs={"by_alias": False})
```

From a path to a model class:

```py
from pydantic_schema_sync import sync_schema_from_path

# This path must be in an installed package
path_to_model_cls = "pydantic_schema_sync.cli.SyncCLI"
sync_schema_from_path(model=path_to_model_cls, schema_path="schema.json")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pydantic-schema-sync",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Louis Maddox <louismmx@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/50/ec/5d2e28afa43184ae50d7f7a6a986e95db4acd672b81dd2f30a6cc992cdef/pydantic_schema_sync-0.1.5.tar.gz",
    "platform": null,
    "description": "# pydantic-schema-sync\n\nSynchronise Pydantic model schemas with JSONSchema files.\n\n## Usage\n\n### CLI\n\n```\nusage: model-schema-sync [-h] [--model MODEL] [--schema_path SCHEMA_PATH]\n                         [--mjs_kwargs MJS_KWARGS]\n\nConfig for syncing Pydantic model schemas to disk.\n\noptions:\n  -h, --help            show this help message and exit\n  --model MODEL         Dotted import path to the Pydantic model\n  --schema_path SCHEMA_PATH\n                        File path to save the schema at\n  --mjs_kwargs MJS_KWARGS\n                        Kwargs to pass `.model_json_schema()`\n```\n\nTo serialise the schema of the model named `SyncCLI` (in the package `pydantic_schema_sync`'s `cli` module)\nto the file `schema.json`, passing the `by_alias=False` param to `.model_json_schema()`:\n\n```sh\nmodel-schema-sync \\\n  --model pydantic_schema_sync.cli.SyncCLI \\\n  --schema_path schema.json \\\n  --mjs_kwargs '{\"by_alias\": false}'\n```\n\n### Python\n\nFrom a model class:\n\n```py\nfrom pydantic_schema_sync import sync_schema\n\n# Using field alias (default)\nsync_schema(model=Foo, schema_path=\"schema.json\")\n\n# Unaliased field\nsync_schema(model=Foo, schema_path=\"schema.json\", mjs_kwargs={\"by_alias\": False})\n```\n\nFrom a path to a model class:\n\n```py\nfrom pydantic_schema_sync import sync_schema_from_path\n\n# This path must be in an installed package\npath_to_model_cls = \"pydantic_schema_sync.cli.SyncCLI\"\nsync_schema_from_path(model=path_to_model_cls, schema_path=\"schema.json\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Synchronise Pydantic model schemas with JSONSchema files",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/lmmx/pydantic-schema-sync",
        "Repository": "https://github.com/lmmx/pydantic-schema-sync.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c0544642738c3dd5b52e78e9098ef127bab6c699423870e72bc87636a2720aee",
                "md5": "a1d1ff61f05573e8dd267127633b78d9",
                "sha256": "049ef26c07238a0703ae568d4eb56e7141addb44875bf4ddd7951fbe5b4c18fd"
            },
            "downloads": -1,
            "filename": "pydantic_schema_sync-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1d1ff61f05573e8dd267127633b78d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 3441,
            "upload_time": "2024-08-28T09:59:10",
            "upload_time_iso_8601": "2024-08-28T09:59:10.093356Z",
            "url": "https://files.pythonhosted.org/packages/c0/54/4642738c3dd5b52e78e9098ef127bab6c699423870e72bc87636a2720aee/pydantic_schema_sync-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50ec5d2e28afa43184ae50d7f7a6a986e95db4acd672b81dd2f30a6cc992cdef",
                "md5": "68d2a50ac5867f0d143d80f6c66a025b",
                "sha256": "3bbf533c701caa76df1653a157948ef04812edac5967b96a54cd4669f0d310d9"
            },
            "downloads": -1,
            "filename": "pydantic_schema_sync-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "68d2a50ac5867f0d143d80f6c66a025b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 2767,
            "upload_time": "2024-08-28T09:59:11",
            "upload_time_iso_8601": "2024-08-28T09:59:11.489312Z",
            "url": "https://files.pythonhosted.org/packages/50/ec/5d2e28afa43184ae50d7f7a6a986e95db4acd672b81dd2f30a6cc992cdef/pydantic_schema_sync-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-28 09:59:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lmmx",
    "github_project": "pydantic-schema-sync",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pydantic-schema-sync"
}
        
Elapsed time: 0.31682s