{"id":23113724,"url":"https://github.com/niyaznz/fastapi-mock-middleware","last_synced_at":"2026-05-11T15:39:10.267Z","repository":{"id":228644903,"uuid":"774526196","full_name":"NiyazNz/fastapi-mock-middleware","owner":"NiyazNz","description":"FastAPI middleware for mocking response data of non-implemented endpoints","archived":false,"fork":false,"pushed_at":"2024-07-09T19:42:13.000Z","size":598,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-19T10:48:37.089Z","etag":null,"topics":["api-first","fastapi","mock","mock-api","mock-fastapi","mock-response"],"latest_commit_sha":null,"homepage":"https://niyaznz.github.io/fastapi-mock-middleware/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NiyazNz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-19T17:45:27.000Z","updated_at":"2024-07-09T19:35:46.000Z","dependencies_parsed_at":"2024-03-26T17:48:43.101Z","dependency_job_id":null,"html_url":"https://github.com/NiyazNz/fastapi-mock-middleware","commit_stats":null,"previous_names":["niyaznz/fastapi-mock-middleware"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiyazNz%2Ffastapi-mock-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiyazNz%2Ffastapi-mock-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiyazNz%2Ffastapi-mock-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiyazNz%2Ffastapi-mock-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NiyazNz","download_url":"https://codeload.github.com/NiyazNz/fastapi-mock-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241696624,"owners_count":20004855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-first","fastapi","mock","mock-api","mock-fastapi","mock-response"],"created_at":"2024-12-17T03:13:30.825Z","updated_at":"2026-05-11T15:39:08.441Z","avatar_url":"https://github.com/NiyazNz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI mock middleware\n\n[![license](https://img.shields.io/badge/License-MIT-dark)](https://github.com/NiyazNz/fastapi-mock-middleware/blob/main/LICENSE.txt)\n[![pypi](https://img.shields.io/pypi/v/fastapi-mock-middleware?color=00FF00)](https://pypi.org/project/fastapi-mock-middleware/)\n[![test](https://github.com/NiyazNz/fastapi-mock-middleware/workflows/Test/badge.svg)](https://github.com/NiyazNz/fastapi-mock-middleware/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/NiyazNz/fastapi-mock-middleware/graph/badge.svg?token=GX8A8HD0KL)](https://codecov.io/gh/NiyazNz/fastapi-mock-middleware)\n\nFastAPI middleware for mocking response data of non-implemented endpoints.\n\nMock data is generated in accordance with endpoint return type or provided\nresponse_model using [polifactory](https://github.com/litestar-org/polyfactory).\n\n---\n\nFor more information on how to use fastapi-mock-middleware, please refer to the\n[official documentation](https://niyaznz.github.io/fastapi-mock-middleware/).\n\n## Installation\n\n```shell\npip install fastapi-mock-middleware\n```\n\n## Usage example\n\nAdd `MockAPIMiddleware` middleware to app and raise `APINotImplementedError` in\nyour endpoint stubs.\n\n```Python hl_lines=\"8 18\"\nimport uvicorn\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\nfrom fastapi_mock_middleware import MockAPIMiddleware, APINotImplementedError\n\napp = FastAPI()\napp.add_middleware(MockAPIMiddleware)\n\n\nclass Item(BaseModel):\n    id: int\n    name: str\n\n\n@app.get('/')\nasync def list_items() -\u003e list[Item]:\n    raise APINotImplementedError()\n\n\nif __name__ == '__main__':\n    uvicorn.run('example:app', reload=True)\n```\n\nCheck the response using `curl`.\n\n```shell\ncurl http://127.0.0.1:8000/\n```\n\nCalled API must return mocked data:\n\n```json\n[\n  {\n    \"id\": 5392,\n    \"name\": \"gVzyVVUmGGevXlQvXGBW\"\n  }\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniyaznz%2Ffastapi-mock-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniyaznz%2Ffastapi-mock-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniyaznz%2Ffastapi-mock-middleware/lists"}