Skip to main content

Build Status codecov Documentation Status

Flask-Hintful

Flask-Hintful helps you write Restful APIs using Flask by taking advantage of Python's type hints.

Includes support for serializing/deserializing parameters according to type hints and automatically generating OpenApi documentation for your registered routes.

Requirements

  • Python 3.7+
  • Flask
  • Marshmallow < 3

Installation

Install using pip

pip install flask-hintful

Quick Start

Construct a FlaskHintful object by passing the Flask application as a parameter, then use the FlaskHintful object @route and .register_blueprint to register routes.

Create your view functions with type hints and FlaskHintful will serialize pass path args, query args and even the request body for you.

from dataclasses import dataclass
from datetime import date, datetime

from flask import Flask

from flask_hintful import FlaskHintful

app = Flask('My API')
api = FlaskHintful(app)


@dataclass
class NestedModel():
    str_field: str


@dataclass
class DataclassModel():
    str_field: str
    int_field: int
    float_field: float
    boolean_field: bool
    list_field: list
    date_field: date
    datetime_field: datetime
    nested_field: NestedModel


@api.route('/<id>/dataclass_test', methods=['POST'])
def dataclass_route(id: str, query_arg: int, model: DataclassModel) -> DataclassModel:
    '''my dataclass route'''
    return model


app.run()

You will be able to access the generated OpenApi on /swagger.

Preview1

Documentation

https://flask-hintful.readthedocs.io/

License

This project is licensed under the MIT License - see the LICENSE file for details

Metadata

Release files for flask-hintful 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-hintful 0.0.7
File Size Uploaded Provenance Actions
flask-hintful-0.0.7.tar.gz 9.5 kB Without provenance Details for flask-hintful-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-hintful 0.0.7
File Interpreter ABI Platform Actions
flask_hintful-0.0.7-py3-none-any.whl Python 3 none any Details for flask_hintful-0.0.7-py3-none-any.whl

Total release size: 21.1 kB

Release files / flask-hintful-0.0.7.tar.gz

Download URL flask-hintful-0.0.7.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8954d448f488343db0e6882962e47b5639bfdb616b9d7b2b74524b9d58e218f7
BLAKE2b-256 checksum
How to use checksums
69a7e77075d865b063acf209c580649dd8b7c32401c975348c310c4801ba7afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / flask_hintful-0.0.7-py3-none-any.whl

Download URL flask_hintful-0.0.7-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32edd98a005e38055d41805273720bbe3d7e6a9cbf301418968526d4bb346c13
BLAKE2b-256 checksum
How to use checksums
0aac6214f3d931d5b9c3344d1fd6afd02b340d1d0a95671711e8c7286109e8f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Security for flask-hintful 0.0.7

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page