Skip to main content

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__ in src/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sample_generator-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sample_generator-0.1.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

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

Hashes for sample_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d400943255def8338bc6e38e854ba9bfa11fc2b2d3546f2ba2a4b5443a0c3184
MD5 5ff4b5eedad45b0735195d129fcc426e
BLAKE2b-256 b158a81ada51a7f4379a22256f433673f7bd33f2241dd7e1bbab3edbdb65e68e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sample_generator-0.1.0.tar.gz:

Publisher: publish.yml on bartoszm/sample_generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sample_generator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sample_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b67f657e723b3617a84c7c1acd6913b4b870de6e376c515deafccf9d2809b058
MD5 b6e8f213c84d8a49277dfdfcbe19d348
BLAKE2b-256 eb72fd685e79f0daa289169c529913d8d255f7d4e125a5023ef0ed9121f312f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for sample_generator-0.1.0-py3-none-any.whl:

Publisher: publish.yml on bartoszm/sample_generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page