This pull request introduces optional runtime validation schemas for API client responses using Pydantic models, and adds automation and documentation to support their use and maintenance. The main themes are: adding schema generation and usage, updating developer workflow and dependencies, and documenting the new feature.
- Added a script (
scripts/generate_schemas.py) that generates Pydantic validation schemas from OpenAPI specs for algod, kmd, and indexer clients, producing 208 schema files in total. These schemas enable runtime type and bounds validation of API responses. - Added and exported all generated schemas in
src/algokit_algod_client/schemas/__init__.pyfor easy import and usage in client code.
- Introduced a new
poetask (generate-schemas) inpyproject.tomlto automate schema generation, and updated the CI workflow to generate schemas and check for uncommitted changes to ensure schema files remain in sync with OpenAPI specs. - Added
pydantic>=2.0.0,<3as a development dependency, and excluded generated schemas from mypy type checking inpyproject.toml. - Updated linting configuration to ignore specific rules for generated API client and schema files.
- Added a new documentation file (
api/oas-generator/VALIDATION.md) detailing the purpose, usage, features, and maintenance of the validation schemas. - Updated
README.mdwith a section introducing validation schemas, installation requirements, usage examples, and links to further documentation.