Generate sample data from JSON schema or OAS models
Project description
json_sample_generator
Generate sample data from JSON Schema or OpenAPI (OAS) schemas. Create realistic samples for tests, examples, and fixtures.
Badges (optional):
- CI: GitHub Actions status
- PyPI: version, downloads
- License: MIT
Installation
From PyPI:
pip install json_sample_generator
Or with uv:
uv add json_sample_generator
Quickstart
Prerequisites:
- Python 3.12+
- uv installed
Install uv (Linux/macOS):
curl -LsSf https://astral.sh/uv/install.sh | sh
Set up the project:
# Clone the repo
git clone https://github.com/<your-username>/json_sample_generator.git
cd json_sample_generator
# (Optional) create a virtualenv managed by uv
uv venv # creates .venv/
# Install runtime deps
uv sync
# For development (tests, tools, etc.)
uv sync --group dev
Run tests:
uv run pytest -q
Run examples:
uv run python examples/simple_value_example.py
Developer guide
Code style:
- PEP 8; line length 79
- Type hints everywhere
Common tasks:
# Lint
uvx ruff check .
# Format
uvx black .
uvx isort .
# Type-check
uvx mypy .
# Test
uv run pytest -q
Build and publish:
# Build sdist + wheel
uv build
# Dry-run publish (uses ~/.pypirc or env vars)
uv publish --dry-run
Release to PyPI:
- Bump
__version__insrc/json_sample_generator/__init__.py - Create a GitHub release (tag must match version)
- The publish workflow will build and upload to PyPI via trusted publishing
Pre-commit (recommended):
uvx pre-commit install
uvx pre-commit run --all-files
User guide: Scenarios
Scenarios let you override generated values per field path with simple values or callables, and optionally with pattern-based rules. They accept a Context so overrides can depend on other fields.
See the full guide (including default_data) in docs/SCENARIOS.md.
Contributing
See CONTRIBUTING.md.
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sample_generator-0.1.0.tar.gz.
File metadata
- Download URL: sample_generator-0.1.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d400943255def8338bc6e38e854ba9bfa11fc2b2d3546f2ba2a4b5443a0c3184
|
|
| MD5 |
5ff4b5eedad45b0735195d129fcc426e
|
|
| BLAKE2b-256 |
b158a81ada51a7f4379a22256f433673f7bd33f2241dd7e1bbab3edbdb65e68e
|
Provenance
The following attestation bundles were made for sample_generator-0.1.0.tar.gz:
Publisher:
publish.yml on bartoszm/sample_generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sample_generator-0.1.0.tar.gz -
Subject digest:
d400943255def8338bc6e38e854ba9bfa11fc2b2d3546f2ba2a4b5443a0c3184 - Sigstore transparency entry: 575427127
- Sigstore integration time:
-
Permalink:
bartoszm/sample_generator@559ca07339540919ad29619897133aac6ce8ee66 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bartoszm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@559ca07339540919ad29619897133aac6ce8ee66 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sample_generator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sample_generator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b67f657e723b3617a84c7c1acd6913b4b870de6e376c515deafccf9d2809b058
|
|
| MD5 |
b6e8f213c84d8a49277dfdfcbe19d348
|
|
| BLAKE2b-256 |
eb72fd685e79f0daa289169c529913d8d255f7d4e125a5023ef0ed9121f312f9
|
Provenance
The following attestation bundles were made for sample_generator-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on bartoszm/sample_generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sample_generator-0.1.0-py3-none-any.whl -
Subject digest:
b67f657e723b3617a84c7c1acd6913b4b870de6e376c515deafccf9d2809b058 - Sigstore transparency entry: 575427182
- Sigstore integration time:
-
Permalink:
bartoszm/sample_generator@559ca07339540919ad29619897133aac6ce8ee66 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bartoszm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@559ca07339540919ad29619897133aac6ce8ee66 -
Trigger Event:
workflow_dispatch
-
Statement type: