Contributing¶
Thank you for helping improve Pydantic JSON Schema.
Prerequisites¶
| Tool | Required | Purpose |
|---|---|---|
| Python 3.12+ | yes | Supported runtime for development and tests |
uv |
yes | Dependency management and Python command runner |
just |
yes | Project command runner used by local and CI workflows |
Node.js / npx |
yes | Runs markdownlint-cli2 through the just lint recipe |
Setup¶
-
Fork the repository on GitHub.
-
Clone your fork:
-
Install dependencies and hooks:
The just install recipe runs uv sync --frozen --all-extras --all-packages and installs
pre-commit hooks.
Development Workflow¶
Run just to list all available commands.
| Need | Command | What it runs |
|---|---|---|
| Format code | just format |
ruff format and autofix-only ruff check |
| Lint everything | just lint |
ruff, mypy, codespell, and markdownlint-cli2 |
| Run tests | just test |
pytest with coverage reporting |
| Run all supported Python versions | just test-all-python |
Python 3.12, 3.13, and 3.14 test runs |
| Generate HTML coverage | just testcov |
just test plus coverage html |
| Run pre-commit hooks | just precommit |
pre-commit run --all-files |
| Run the full local gate | just all |
format, lint, tests, and docs build |
Before opening a PR, run:
Documentation Workflow¶
| Need | Command |
|---|---|
| Build the documentation | just docs-build |
| Serve documentation locally | just docs-serve |
| Format and refresh documentation examples | just docs-format |
After just docs-serve, open http://127.0.0.1:8000.
Documentation examples are verified in two ways:
- Python code blocks in documentation files are linted and executed by
tests/test_docs.py. - Python files in
examples/are linted and executed bytests/test_docs.py.
The docs/examples.md page uses --8<-- includes, so the page itself is not used as the source
of those code examples. The included examples/*.py files are still tested directly.
Code Style¶
- Use Ruff for formatting and linting.
- Add type hints to public APIs and internal code where type inference is not obvious.
- Use Sphinx-style docstrings for public APIs (
:param:,:returns:,:raises:). - Keep
mypystrict mode passing. - Keep tests explicit about generated model behavior, validation errors, references, and formats.
Testing Requirements¶
- Add tests for every new feature or behavior change.
- Maintain 100% coverage.
- Prefer direct behavior assertions over implementation-detail assertions.
- Include validation failure cases when schema constraints should reject input.
- Add documentation examples when a behavior needs user-facing explanation.
Pull Request Process¶
-
Create a new branch:
-
Make your changes.
-
Run the full local gate:
-
Commit your changes:
-
Push your branch:
-
Open a pull request.
In the PR description, include what changed, why it changed, how it was tested, and any breaking behavior changes.
Commit Messages¶
Use one-line Conventional Commits messages:
Common types:
| Type | Use for |
|---|---|
feat |
New features |
fix |
Bug fixes |
docs |
Documentation changes |
chore |
Maintenance tasks |
refactor |
Code restructuring without behavior changes |
test |
Test additions or updates |
perf |
Performance improvements |
build |
Build system or packaging changes |
ci |
CI workflow changes |
Examples:
feat(converters): add custom format validatorsfix(converters): resolve nested schema referencesdocs(examples): add nested schema conversion examplechore(deps): update pydantic dependency
Documentation Guidelines¶
Documentation should show how to use a feature and why it matters.
When adding or changing behavior:
- Add examples showing realistic input and output.
- Keep examples concise and self-contained.
- Prefer code-first explanations.
- Start with common use cases before edge cases.
- Update API documentation when public functions, classes, or parameters change.
- Update user guides when observable behavior changes.
- Add or update
examples/*.pywhen a complete runnable scenario is useful.
Where to Add Documentation¶
| Change | Where to document it |
|---|---|
| Converter behavior | docs/converters.md |
| Format validators | docs/formats.md |
| Complete runnable scenarios | examples/*.py and docs/examples.md |
| Public API changes | API docs and public docstrings |
| Breaking changes | Relevant guide and migration notes |
Questions¶
If you need help, review the documentation and existing issues before opening a new issue.