fastapi-views


Namefastapi-views JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryFastAPI Class Views and utilities
upload_time2024-04-15 15:54:17
maintainerNone
docs_urlNone
authorRadzim Kowalow
requires_python<4.0,>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastapi-views

![CI](https://github.com/performancemedia/fastapi-views/workflows/CI/badge.svg)
![Build](https://github.com/performancemedia/fastapi-views/workflows/Publish/badge.svg)
![License](https://img.shields.io/github/license/performancemedia/fastapi-views)
![Python](https://img.shields.io/pypi/pyversions/fastapi-views)
![Format](https://img.shields.io/pypi/format/fastapi-views)
![PyPi](https://img.shields.io/pypi/v/fastapi-views)
![Mypy](https://img.shields.io/badge/mypy-checked-blue)
![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)

*FastAPI Class Views and utilities*

---
Version: 0.2.0 

Documentation: https://performancemedia.github.io/fastapi-views/

Repository: https://github.com/performancemedia/fastapi-views

---

## Installation

```shell
pip install fastapi-views
```

## Usage

```python
from typing import Optional
from uuid import UUID

from fastapi_views import Serializer, ViewRouter
from fastapi_views.views.viewsets import AsyncAPIViewSet


class ItemSchema(Serializer):
    id: UUID
    name: str
    price: int


items = {}


class MyViewSet(AsyncAPIViewSet):
    api_component_name = "Item"
    serializer = ItemSchema
    
    async def list(self):
        return list(items.values())

    async def create(self, item: ItemSchema) -> ItemSchema:
        items[item.id] = item
        return item

    async def retrieve(self, id: UUID) -> Optional[ItemSchema]:
        return items.get(id)

    async def update(self, item: ItemSchema):
        items[item.id] = item

    async def destroy(self, id: UUID) -> None:
        items.pop(id, None)

router = ViewRouter(prefix="/items")
router.register_view(MyViewSet)
# in app.py
# app.include_router(router)

```

## Features

- Class Based Views
  - APIViews
  - GenericViews
  - ViewSets
- Both async and sync function support
- No dependencies on ORM
- Openapi id simplification
- 'Smart' and fast serialization using orjson
- Http Problem Details implementation
- Automatic prometheus metrics exporter
- Pluggable healthcheck helper


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fastapi-views",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Radzim Kowalow",
    "author_email": "radzim.kowalow@performance-media.pl",
    "download_url": "https://files.pythonhosted.org/packages/2a/63/88ca8b529454f4107725b9da3a44aa426944630c66e55232a170ce8c0e1e/fastapi_views-0.2.0.tar.gz",
    "platform": null,
    "description": "# fastapi-views\n\n![CI](https://github.com/performancemedia/fastapi-views/workflows/CI/badge.svg)\n![Build](https://github.com/performancemedia/fastapi-views/workflows/Publish/badge.svg)\n![License](https://img.shields.io/github/license/performancemedia/fastapi-views)\n![Python](https://img.shields.io/pypi/pyversions/fastapi-views)\n![Format](https://img.shields.io/pypi/format/fastapi-views)\n![PyPi](https://img.shields.io/pypi/v/fastapi-views)\n![Mypy](https://img.shields.io/badge/mypy-checked-blue)\n![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n\n*FastAPI Class Views and utilities*\n\n---\nVersion: 0.2.0 \n\nDocumentation: https://performancemedia.github.io/fastapi-views/\n\nRepository: https://github.com/performancemedia/fastapi-views\n\n---\n\n## Installation\n\n```shell\npip install fastapi-views\n```\n\n## Usage\n\n```python\nfrom typing import Optional\nfrom uuid import UUID\n\nfrom fastapi_views import Serializer, ViewRouter\nfrom fastapi_views.views.viewsets import AsyncAPIViewSet\n\n\nclass ItemSchema(Serializer):\n    id: UUID\n    name: str\n    price: int\n\n\nitems = {}\n\n\nclass MyViewSet(AsyncAPIViewSet):\n    api_component_name = \"Item\"\n    serializer = ItemSchema\n    \n    async def list(self):\n        return list(items.values())\n\n    async def create(self, item: ItemSchema) -> ItemSchema:\n        items[item.id] = item\n        return item\n\n    async def retrieve(self, id: UUID) -> Optional[ItemSchema]:\n        return items.get(id)\n\n    async def update(self, item: ItemSchema):\n        items[item.id] = item\n\n    async def destroy(self, id: UUID) -> None:\n        items.pop(id, None)\n\nrouter = ViewRouter(prefix=\"/items\")\nrouter.register_view(MyViewSet)\n# in app.py\n# app.include_router(router)\n\n```\n\n## Features\n\n- Class Based Views\n  - APIViews\n  - GenericViews\n  - ViewSets\n- Both async and sync function support\n- No dependencies on ORM\n- Openapi id simplification\n- 'Smart' and fast serialization using orjson\n- Http Problem Details implementation\n- Automatic prometheus metrics exporter\n- Pluggable healthcheck helper\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "FastAPI Class Views and utilities",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a0b8ad83a02fa7b9af3a7e3736b483584af4ec4749924f0ec71e3d4a92f5af2",
                "md5": "49e109329e25bdefe98c915bdd081ac1",
                "sha256": "ec79d52708ec1f3824f9e632641dfd11f55685bc488db5b68cedccac2f5d6d13"
            },
            "downloads": -1,
            "filename": "fastapi_views-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "49e109329e25bdefe98c915bdd081ac1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 25008,
            "upload_time": "2024-04-15T15:54:16",
            "upload_time_iso_8601": "2024-04-15T15:54:16.131048Z",
            "url": "https://files.pythonhosted.org/packages/8a/0b/8ad83a02fa7b9af3a7e3736b483584af4ec4749924f0ec71e3d4a92f5af2/fastapi_views-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a6388ca8b529454f4107725b9da3a44aa426944630c66e55232a170ce8c0e1e",
                "md5": "6dddb91df3c449739622f3ec6da6a240",
                "sha256": "88a52abcc241bb82d3523d72613c8d010745d52c151a4ee8006a729d2d3fbc59"
            },
            "downloads": -1,
            "filename": "fastapi_views-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6dddb91df3c449739622f3ec6da6a240",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 19339,
            "upload_time": "2024-04-15T15:54:17",
            "upload_time_iso_8601": "2024-04-15T15:54:17.183162Z",
            "url": "https://files.pythonhosted.org/packages/2a/63/88ca8b529454f4107725b9da3a44aa426944630c66e55232a170ce8c0e1e/fastapi_views-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 15:54:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "fastapi-views"
}
        
Elapsed time: 0.35479s