Metadata-Version: 2.4
Name: pymockit
Version: 0.1.0
Summary: Instant mock APIs from a schema file — no server code required.
Project-URL: Homepage, https://github.com/gabrielleaosb/pymockit
Project-URL: Repository, https://github.com/gabrielleaosb/pymockit
Project-URL: Bug Tracker, https://github.com/gabrielleaosb/pymockit/issues
Author-email: Gabriel <gabriellsbagetti@gmail.com>
License: MIT
License-File: LICENSE
Keywords: api,cli,devtools,faker,fastapi,mock,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: faker>=24.0.0
Requires-Dist: fastapi>=0.111.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.12.0
Requires-Dist: uvicorn[standard]>=0.29.0
Requires-Dist: watchfiles>=0.21.0
Provides-Extra: dev
Requires-Dist: httpx>=0.27.0; extra == 'dev'
Requires-Dist: pytest-anyio>=0.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Description-Content-Type: text/markdown

# PyMockit

[![CI](https://github.com/gabrielleaosb/pymockit/actions/workflows/ci.yml/badge.svg)](https://github.com/gabrielleaosb/pymockit/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/pymockit)](https://pypi.org/project/pymockit/)
[![Python](https://img.shields.io/pypi/pyversions/pymockit)](https://pypi.org/project/pymockit/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

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

```bash
pymockit run schema.json
```

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

---

## Install

```bash
pip install pymockit
# or with uv
uv add pymockit
```

---

## Quick start

```bash
# 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

```json
{
  "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](https://faker.readthedocs.io/) 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
