A Python package that lets you add smart forms to FastAPI and Flask. Forms will respond with a JSON scheme that contains all info needed in a React frontend with uniforms to render the forms and handle all validation tasks.
Forms can also consist out of a wizard, so you can create complex form flows consisting out of multiple consecutive forms. The forms and the validation logic are defined by using Pydantic models.
A program can fill a form too: walk_form says where a wizard stands and page_schema renders a page as one
self-contained JSON schema.
Documentation regarding the usage of Forms can be found at workfloworchestrator.org/pydantic-forms.
This project uses uv. Install the project and its dependencies to develop on the code:
uv sync --all-extrasThis creates a .venv, installs pydantic-forms in editable mode, and installs the dev dependency group
(which chains in test and doc) plus the fastapi and orjson extras. There is no need to create or
activate a virtualenv yourself -- prefix commands with uv run and uv will use the right interpreter.
Run the unit-test suite to verify a correct setup.
uv run pytest tests/unit_testsor with xdist:
uv run pytest -n auto tests/unit_testsIf you do not encounter any failures in the test, you should be able to develop features in the pydantic-forms.
If you are working on a project that already uses pydantic-forms and you want to test your new form features
against it, point that project at your local checkout. Run this from the other project:
uv add --editable /path/to/pydantic-formsThis replaces the PyPI dependency with an editable install of your working copy and records it under
[tool.uv.sources] in that project's pyproject.toml. Undo it with:
uv remove pydantic-forms && uv add pydantic-formsWhen your PR is accepted you will get a version number.
You can do the necessary change with a clean, e.g. every change committed, branch:
uv version 0.0.1Note: specifying the version explicitly, instead of relying on uv version --bump patch to increase it, allows
you to set a "RC1" version if needed -- e.g. uv version 0.0.1rc1.
If you want/need the traceback of pydantic in a Form response you can add an env variable:
LOG_LEVEL_PYDANTIC_FORMS=DEBUG
This will add the traceback to the JSONResponse. If the loglevel is set to DEBUG the library will also add the
traceback to the logger.