FastAPI mock middleware
FastAPI middleware for mocking response data of non-implemented endpoints.
Mock data is generated in accordance with endpoint return type or provided response_model using polifactory.
For more information on how to use fastapi-mock-middleware, please refer to the official documentation.
Installation
pip install fastapi-mock-middleware
Usage example
Add MockAPIMiddleware middleware to app and raise APINotImplementedError in
your endpoint stubs.
import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
from fastapi_mock_middleware import MockAPIMiddleware, APINotImplementedError
app = FastAPI()
app.add_middleware(MockAPIMiddleware)
class Item(BaseModel):
id: int
name: str
@app.get('/')
async def list_items() -> list[Item]:
raise APINotImplementedError()
if __name__ == '__main__':
uvicorn.run('example:app', reload=True)
Check the response using curl.
curl http://127.0.0.1:8000/
Called API must return mocked data:
[
{
"id": 5392,
"name": "gVzyVVUmGGevXlQvXGBW"
}
]
Metadata
Release files for fastapi-mock-middleware 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_mock_middleware-0.1.1.tar.gz | 11.6 kB | Without provenance | Details for fastapi_mock_middleware-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_mock_middleware-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for fastapi_mock_middleware-0.1.1-py3-none-any.whl |
Total release size: 17.9 kB
Release files / fastapi_mock_middleware-0.1.1.tar.gz
| Download URL | fastapi_mock_middleware-0.1.1.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2a6ccc07a5a8c89891be3bb2542f57de62fb7312da8bf6093bac634ac7a521d
|
|
BLAKE2b-256 checksum How to use checksums |
b6c69beaabff0c87aa69639039e57b89be80f15fbdd98e560f136319b8039c3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / fastapi_mock_middleware-0.1.1-py3-none-any.whl
| Download URL | fastapi_mock_middleware-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49534fd91a7f3cc24a0a8352bb09ea505e7465b6227dfdd499dcd77e3c4cadd6
|
|
BLAKE2b-256 checksum How to use checksums |
64a21ab423724066e13fb5048762c56125adf5adc8d9f90b8d5635aaec8237c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for fastapi-mock-middleware 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.