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.

CI PyPI version PyPI downloads/month License Python versions

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


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.3.0.tar.gz (18.0 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.3.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file sample_generator-0.3.0.tar.gz.

File metadata

  • Download URL: sample_generator-0.3.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sample_generator-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b707fd7e09887656b7aa07a4f93814b9bfa6dfd6a84b5051c02aa6dc59034343
MD5 e22b50fad325c13ba5e7d53698fb61af
BLAKE2b-256 cfc1c45d0c247c83e6bd4b3085dce2e05ace73e863711ff6a00382c97029f06b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sample_generator-0.3.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.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sample_generator-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4ae8cde9402917ce7acc47ad4e604bd02fc4191d4c4001a996a01412550000d
MD5 f2e36a629c42987d38114ad8b45bcc18
BLAKE2b-256 5ca2676fc9a3621a8649f906016969cf36c94fac33d2da04da1ba2665b28c82c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sample_generator-0.3.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