Skip to main content

Dataclasses Avro Schema CLI

Command line interface from dataclasses-avroschema to work with avsc resources

Tests GitHub license codecov python version

Requirements

python 3.10+

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 from schemas
  • Data deserialization with schema
  • Data serialization with schema
  • 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

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.13.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dc_avro-0.13.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file dc_avro-0.13.0.tar.gz.

File metadata

  • Download URL: dc_avro-0.13.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for dc_avro-0.13.0.tar.gz
Algorithm Hash digest
SHA256 985c6c089cdf4201a31240642312c7e1aebf553890eaf7689cda3c5f305c90e1
MD5 46ec723e457e45ef766afe2fb36a5ae5
BLAKE2b-256 b36196941cc1e2a4e875cf5c08c2ab9da7d3e4209cb08b7b8f0ef3bd6427f3c5

See more details on using hashes here.

File details

Details for the file dc_avro-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: dc_avro-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for dc_avro-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2883cc563d631004296b0581deee635286b0f0c30e67f9a8d2a13f000ce916e5
MD5 d7d5f3f3d5e1dd84e0db6a752aa4d067
BLAKE2b-256 0f27e566a63a03fec8be15e29c4172f8eb428f29d80bf9b2d672a12ea3c37d7a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page