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.
Installation
From PyPI:
pip install sample-generator
# importable module name remains `json_sample_generator`
Or with uv:
uv add 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 quality tools used by the project
- uv (astral.sh/uv) — virtualenv + task runner used in CI
- ruff — linting (CI runs
uvx ruff check .) - black — formatting (CI runs
uvx black --check .) - isort — import sorting (CI runs
uvx isort --check-only .) - pytest — test runner (CI runs
uv run pytest -q)
Automated-fix hints
- Run ruff's auto-fixer to apply quick lint fixes:
uvx ruff check . --fix - Reformat code with black:
uvx black . - Sort imports with isort:
uvx isort . - Run the full CI steps locally (create venv first):
uv venv uv sync --group dev uvx ruff check . uvx black --check . && uvx isort --check-only . uv run pytest -q
These commands mirror what GitHub Actions runs so you can reproduce and fix CI failures locally.
Build and publish reminders
The repository's publish workflow builds with uv build and uses the pypa/gh-action-pypi-publish action; for first-time releases you may need a PyPI API token (or configure OIDC/trusted publishing on PyPI).
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.2.0.tar.gz.
File metadata
- Download URL: sample_generator-0.2.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29663a92374a821340fab35fa2a0ed35c29a7247da27c312683606caa0bc845f
|
|
| MD5 |
5e9ab6f47f45157432c63215480bbc69
|
|
| BLAKE2b-256 |
fbf8abe8a4d11cc4a5ad73d303c0ae9f91a96f75e67ae7585603d207d6804e5c
|
Provenance
The following attestation bundles were made for sample_generator-0.2.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.2.0.tar.gz -
Subject digest:
29663a92374a821340fab35fa2a0ed35c29a7247da27c312683606caa0bc845f - Sigstore transparency entry: 1306089844
- Sigstore integration time:
-
Permalink:
bartoszm/sample_generator@0d3570bd8a6ce34465c3443d2013612274278230 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bartoszm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0d3570bd8a6ce34465c3443d2013612274278230 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sample_generator-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sample_generator-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
422b450fbaa8212d2bfc3523ebcde731b20c0d330001c71513e3cd29fc1fe0e4
|
|
| MD5 |
49ca6aaf965c332aa0eb9f9f44a9cf80
|
|
| BLAKE2b-256 |
913db656ec387bf6f6db1aee411d858cdde17ac4ce4798a1a87d480f12d36faa
|
Provenance
The following attestation bundles were made for sample_generator-0.2.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.2.0-py3-none-any.whl -
Subject digest:
422b450fbaa8212d2bfc3523ebcde731b20c0d330001c71513e3cd29fc1fe0e4 - Sigstore transparency entry: 1306089943
- Sigstore integration time:
-
Permalink:
bartoszm/sample_generator@0d3570bd8a6ce34465c3443d2013612274278230 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bartoszm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0d3570bd8a6ce34465c3443d2013612274278230 -
Trigger Event:
release
-
Statement type: