This package provides a tool that generates Pydantic v2 models for the events that are defined in the JSON schemas that are built as part of this repository. The generated Pydantic models can be used to validate and parse NHS Notify Digital Letters events.
Use make install-dev to install the necessary dependencies for this application.
In order for this tool to function, you must first build the JSON schemas for
the Digital Letters events. This is done automatically when the make config
command is run, but if you need to rebuild them for some reason the simplest
approach is to run the make generate command from the root of this repository.
Once the JSON schemas have been built, Pydantic models can be generated by running the following from this directory:
make generateThis will:
- Read all JSON event schemas from
schemas/digital-letters/2025-10-draft/events/ - Generate Pydantic v2 models using
datamodel-code-generator - Output the models to
../digital-letters-events/digital_letters_events/models/
Generated models are placed in the digital-letters-events package:
../digital-letters-events/digital_letters_events/models/- Individual Pydantic model files../digital-letters-events/digital_letters_events/models/__init__.py- Combined index for easy imports
Run tests using:
make testFor coverage reporting:
make coverage- Python 3.11+
- pip or poetry for dependency management
make install-devmake test