Metadata-Version: 2.1
Name: flask-api-factory
Version: 0.2.3
Summary: one small flask rest api factory
Home-page: https://github.com/rodrigopmatias/flask-api-factory/blob/main/README.md
Author: Rodrigo Pinheiro Matias
Author-email: rodrigopmatias@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Provides-Extra: mysql
Provides-Extra: postgres
Requires-Dist: flask (>=2.2.2,<3.0.0)
Requires-Dist: flask-migrate (>=4.0.4,<5.0.0)
Requires-Dist: flask-sqlalchemy (>=3.0.3,<4.0.0)
Requires-Dist: gunicorn (>=20.1.0,<21.0.0)
Requires-Dist: mysql (>=0.0.3,<0.0.4) ; extra == "mysql"
Requires-Dist: pika (>=1.3.1,<2.0.0)
Requires-Dist: prometheus-flask-exporter (>=0.21.0,<0.22.0)
Requires-Dist: psycopg2-binary (>=2.9.5,<3.0.0) ; extra == "postgres"
Requires-Dist: pydantic[dotenv] (>=1.10.4,<2.0.0)
Project-URL: Repository, https://github.com/rodrigopmatias/flask-api-factory
Description-Content-Type: text/markdown

The initial idea is to be a Rest API factory, with the aim of making it easy to create from models defined using the SQLAlchemy ORM.

We still use pydantic to serialize objects and payloads.

## Install

You can install using pip:

```shell
$ pip install flask-api-factory
```

You can install with the database driver you want to be supported by SQLAlchemy, but if you prefer, you can install the driver as an extra library, with the command:

```shell
$ pip install flask-api-factory[postgres]
```

This will install `psycopg2` together with our library.

You can still install using `poetry` with the command:

```shell
$ poetry add flask-api-factory
```

## A simple example

Having the `Pet` model already defined and the initialization of the `Flask` application already started, just use the following code:

```python
from flask import Flask, Blueprint
from flask_api_factory import factory_api

from .models import Pet
from .serializers import PetSerializer


blueprint = Blueprint("pets", __name__, url_prefix="/pets")


def init_app(app: Flask) -> None:
    app.register_blueprint(blueprint)

factory_api(blueprint, Pet, PetSerializer)
```

This way we will have a `/pets` endpoint capable of responding to all HTTP verbs. Consulting the documentation you can check other options for configurations and functionalities.

## Roadmap

 * [ ] Documentation;
 * [X] `openapi.json` generation mechanism;
 * [ ] A way to provide `Swagger` and/or `Redoc`;
 * [ ] Write unit tests.

