Skip to main content

Extenção flask para aumento de agilidade de criação de formulario para o flask-restx no processo de criação de projeto.

Project description

FlaskDantic

união de duas lib, flask-restx e pydantic, para facilitar a criação de apis rest com python

from flask import Flask
from flask_dantic import FDantic
from flask_restx import Resource
from pydantic import BaseModel, validator

class Usuario(BaseModel):
    id: int
    username: str
    password: str

app = Flask(__name__)
api = FDantic(app)

np = api.namespace("grupo")
user = np.model_pydantic(Usuario)


class UsuarioResource(Resource):
    @user.validate(np)
    def post(self):
        data: Usuario = self.payload
        return data.dict()


np.add_resource(UsuarioResource, "/")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fdantic-0.1.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

fdantic-0.1.0-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page