No project description provided
Project description
Dataclasses Avro Schema CLI
Command line interface from dataclasses-avroschema to work with avsc
resources
Requirements
python 3.8+
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
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
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
- repo: https://github.com/marcosschroh/dc-avro.git
rev: 0.7.0
hooks:
- id: lint-avsc
additional_dependencies: [typing_extensions]
Features
- Validate
schema
- Lint
schemas
- Generate
models
fromschemas
- Data deserialization with
schema
- Data serialization with
schema
- View diff between
schemas
- Generate fake data from
schema
Development
- Install requirements:
poetry install
- Code linting:
./scripts/format
- Run tests:
./scripts/test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dc_avro-0.9.1.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file dc_avro-0.9.1.tar.gz
.
File metadata
- Download URL: dc_avro-0.9.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d040f617523c119c66c2091dd22fc4b58cf7e3c276442e76265089ab50e52e8a |
|
MD5 | b5ee84a2e1d261eba9ace00cd256d1a9 |
|
BLAKE2b-256 | 21355eee5fa34b4b0112e64898707be87f0fa59ff9007640c0cc9d8da3b93c9a |
File details
Details for the file dc_avro-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: dc_avro-0.9.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 827039e5c8ccc32f249399ab63e32006db540661b07f6a5664d9c4e230d10a1d |
|
MD5 | 796588aec03f27158bee5ba6433ceb62 |
|
BLAKE2b-256 | 357b83b1f125e4e4d2fac43049d612fa0a0b08ab26c110af5b7477ca13547063 |