Skip to main content

Instant mock APIs from a schema file — no server code required.

Project description

PyMockit

CI PyPI Python License: MIT

Instant mock APIs from a schema file — no server code required.

pymockit run schema.json

In seconds you have a fully functional FastAPI mock server with Swagger UI, realistic fake data, and hot-reload.


Install

pip install pymockit
# or with uv
uv add pymockit

Quick start

# 1. Generate a starter schema
pymockit init

# 2. Start the mock server
pymockit run schema.json

# 3. With hot-reload and a custom port
pymockit run schema.json --port 8080 --reload

# 4. Validate without starting
pymockit validate schema.json

Schema format

{
  "routes": [
    {
      "path": "/users",
      "method": "GET",
      "_status": 200,
      "body": {
        "id": "@faker.uuid4",
        "name": "@faker.name",
        "email": "@faker.email",
        "age": "@faker.random_int",
        "company": "@faker.company"
      }
    },
    {
      "path": "/users/{id}",
      "method": "GET",
      "_status": 200,
      "body": { "id": "@faker.uuid4", "name": "@faker.name" }
    },
    {
      "path": "/products",
      "method": "POST",
      "_status": 201,
      "body": { "created": true, "product_id": "@faker.uuid4" }
    },
    {
      "path": "/broken",
      "method": "GET",
      "_status": 404,
      "body": { "error": "Resource not found" }
    }
  ]
}

Rules

Feature Description
@faker.<method> Any Faker method — resolved fresh per request
_status HTTP status code (default 200)
{param} Path parameters passed through to FastAPI
Literal values Strings, numbers, booleans, arrays — returned as-is

Commands

pymockit run <schema>

Start the mock server.

Option Default Description
--host 127.0.0.1 Bind address
--port 8000 TCP port
--reload off Restart on schema file change

pymockit init

Create a schema.json starter in the current directory.

pymockit validate <schema>

Check a schema for errors without starting the server. Exits 0 on success, 1 on error.


License

MIT

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

pymockit-0.1.0.tar.gz (66.3 kB view details)

Uploaded Source

Built Distribution

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

pymockit-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file pymockit-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pymockit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c1ac0bc8141ad3bb6afeda8720eee7ddad6c486eecca412e66d8acb201d0d76
MD5 272c48bf852858488bad69c654a6a2c7
BLAKE2b-256 30e7aa594c2313029ebdfd10f87193f4b88b5ac1110b0fc435a3deca4831bc85

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on gabrielleaosb/pymockit

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

File details

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

File metadata

  • Download URL: pymockit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymockit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6c03189841925fdafa4cd1c67bc66d712df7045d1943e2d128647bc46c7cc49
MD5 5ccc069bafcd4a0ceb156ad47968fb58
BLAKE2b-256 449c54e6a8e6bfd6b9788d620e057ecae83c6609d9071c0adf4fe6aec5a23f86

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on gabrielleaosb/pymockit

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