# Dataclasses Avro Schema CLI
Command line interface from [dataclasses-avroschema](https://github.com/marcosschroh/dataclasses-avroschema) to work with `avsc` resources
[](https://github.com/marcosschroh/dc-avro/actions/workflows/tests.yaml)
[](https://github.com/marcosschroh/dc-avro/blob/master/LICENSE)
[](https://codecov.io/gh/marcosschroh/dc-avro)

## Requirements
`python 3.9+`
## Documentation
https://marcosschroh.github.io/dc-avro/
## Usage
You can validate one `avro schema` either from a `local file` or `url`:
Assuming that we have a local file `schema.avsc` that contains an `avro schema`, we can check whether it is valid
```bash
dc-avro validate-schema --path schema.avsc
Valid schema!! 👍
{
'type': 'record',
'name': 'UserAdvance',
'fields': [
{'name': 'name', 'type': 'string'},
{'name': 'age', 'type': 'long'},
{'name': 'pets', 'type': {'type': 'array', 'items': 'string', 'name': 'pet'}},
{'name': 'accounts', 'type': {'type': 'map', 'values': 'long', 'name': 'account'}},
{'name': 'favorite_colors', 'type': {'type': 'enum', 'name': 'FavoriteColor', 'symbols': ['BLUE', 'YELLOW', 'GREEN']}},
{'name': 'has_car', 'type': 'boolean', 'default': False},
{'name': 'country', 'type': 'string', 'default': 'Argentina'},
{'name': 'address', 'type': ['null', 'string'], 'default': None},
{'name': 'md5', 'type': {'type': 'fixed', 'name': 'md5', 'size': 16}}
]
}
```
You can validate several `.avsc` files with `lint` command
```bash
dc-avro lint tests/schemas/example.avsc tests/schemas/example_v2.avsc
👍 Total valid schemas: 2
tests/schemas/example.avsc
tests/schemas/example_v2.avsc
```
To see all the commands execute `dc-avro --help`
## Usage in pre-commit
Add the following lines to your `.pre-commit-config.yaml` file to enable avro schemas linting
```yaml
- repo: https://github.com/marcosschroh/dc-avro.git
rev: 0.7.0
hooks:
- id: lint-avsc
additional_dependencies: [typing_extensions]
```
## Features
* [x] Validate `schema`
* [x] Lint `schemas`
* [x] Generate `models` from `schemas`
* [x] Data deserialization with `schema`
* [x] Data serialization with `schema`
* [x] View diff between `schemas`
* [ ] Generate fake data from `schema`
## Development
1. Install requirements: `poetry install`
2. Code linting: `./scripts/format`
3. Run tests: `./scripts/test`
Raw data
{
"_id": null,
"home_page": null,
"name": "dc-avro",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "avro, schemas, dataclasses, pydantic, lint",
"author": "Marcos Schroh",
"author_email": "marcos.schroh@kpn.com",
"download_url": "https://files.pythonhosted.org/packages/56/46/a4638a6d4f6ceb2694d376d5ee6633fbb5d888d1ee566cc3e5f2725007f9/dc_avro-0.10.0.tar.gz",
"platform": null,
"description": "# Dataclasses Avro Schema CLI\n\nCommand line interface from [dataclasses-avroschema](https://github.com/marcosschroh/dataclasses-avroschema) to work with `avsc` resources\n\n[](https://github.com/marcosschroh/dc-avro/actions/workflows/tests.yaml)\n[](https://github.com/marcosschroh/dc-avro/blob/master/LICENSE)\n[](https://codecov.io/gh/marcosschroh/dc-avro)\n\n\n## Requirements\n\n`python 3.9+`\n\n## Documentation\n\nhttps://marcosschroh.github.io/dc-avro/\n\n## Usage\n\nYou can validate one `avro schema` either from a `local file` or `url`:\n\nAssuming that we have a local file `schema.avsc` that contains an `avro schema`, we can check whether it is valid\n\n```bash\ndc-avro validate-schema --path schema.avsc\n\nValid schema!! \ud83d\udc4d \n\n{\n 'type': 'record',\n 'name': 'UserAdvance',\n 'fields': [\n {'name': 'name', 'type': 'string'},\n {'name': 'age', 'type': 'long'},\n {'name': 'pets', 'type': {'type': 'array', 'items': 'string', 'name': 'pet'}},\n {'name': 'accounts', 'type': {'type': 'map', 'values': 'long', 'name': 'account'}},\n {'name': 'favorite_colors', 'type': {'type': 'enum', 'name': 'FavoriteColor', 'symbols': ['BLUE', 'YELLOW', 'GREEN']}},\n {'name': 'has_car', 'type': 'boolean', 'default': False},\n {'name': 'country', 'type': 'string', 'default': 'Argentina'},\n {'name': 'address', 'type': ['null', 'string'], 'default': None},\n {'name': 'md5', 'type': {'type': 'fixed', 'name': 'md5', 'size': 16}}\n ]\n}\n```\n\nYou can validate several `.avsc` files with `lint` command\n\n```bash\ndc-avro lint tests/schemas/example.avsc tests/schemas/example_v2.avsc\n\n\ud83d\udc4d Total valid schemas: 2\ntests/schemas/example.avsc\ntests/schemas/example_v2.avsc\n```\n\nTo see all the commands execute `dc-avro --help`\n\n## Usage in pre-commit\n\nAdd the following lines to your `.pre-commit-config.yaml` file to enable avro schemas linting\n\n```yaml\n - repo: https://github.com/marcosschroh/dc-avro.git\n rev: 0.7.0\n hooks:\n - id: lint-avsc\n additional_dependencies: [typing_extensions]\n```\n\n## Features\n\n* [x] Validate `schema`\n* [x] Lint `schemas`\n* [x] Generate `models` from `schemas`\n* [x] Data deserialization with `schema`\n* [x] Data serialization with `schema`\n* [x] View diff between `schemas`\n* [ ] Generate fake data from `schema`\n\n## Development\n\n1. Install requirements: `poetry install`\n2. Code linting: `./scripts/format`\n3. Run tests: `./scripts/test`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": null,
"version": "0.10.0",
"project_urls": null,
"split_keywords": [
"avro",
" schemas",
" dataclasses",
" pydantic",
" lint"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1f3d842b02deea99e14bdae511d2f5e2056e404f2e58c8a63c5ff1fb0a18467e",
"md5": "bc8328e7ac11d3c8b49349fb6ca54c2f",
"sha256": "04b49265355ccccabb17206992171560c7114ceda9058fe19068992095b69f64"
},
"downloads": -1,
"filename": "dc_avro-0.10.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bc8328e7ac11d3c8b49349fb6ca54c2f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 7938,
"upload_time": "2025-01-20T15:10:13",
"upload_time_iso_8601": "2025-01-20T15:10:13.218371Z",
"url": "https://files.pythonhosted.org/packages/1f/3d/842b02deea99e14bdae511d2f5e2056e404f2e58c8a63c5ff1fb0a18467e/dc_avro-0.10.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5646a4638a6d4f6ceb2694d376d5ee6633fbb5d888d1ee566cc3e5f2725007f9",
"md5": "4263ad3447e30e7727a21cc37a22e2b8",
"sha256": "76fed8ae66eb51c583b50b50a323c7cebc5ef0927b3223155f8f4559adada103"
},
"downloads": -1,
"filename": "dc_avro-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "4263ad3447e30e7727a21cc37a22e2b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 6490,
"upload_time": "2025-01-20T15:10:14",
"upload_time_iso_8601": "2025-01-20T15:10:14.136321Z",
"url": "https://files.pythonhosted.org/packages/56/46/a4638a6d4f6ceb2694d376d5ee6633fbb5d888d1ee566cc3e5f2725007f9/dc_avro-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-20 15:10:14",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "dc-avro"
}