Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbw/flask-journey
Blueprint management and straightforward (de)serialization + validation in Flask
https://github.com/rbw/flask-journey
blueprint deserialization flask marshmallow registration routing serialization validation
Last synced: 3 months ago
JSON representation
Blueprint management and straightforward (de)serialization + validation in Flask
- Host: GitHub
- URL: https://github.com/rbw/flask-journey
- Owner: rbw
- License: mit
- Archived: true
- Created: 2018-03-09T02:21:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-10T12:31:34.000Z (about 6 years ago)
- Last Synced: 2024-04-13T21:53:21.823Z (9 months ago)
- Topics: blueprint, deserialization, flask, marshmallow, registration, routing, serialization, validation
- Language: Python
- Homepage:
- Size: 102 KB
- Stars: 13
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. image:: https://travis-ci.org/rbw/flask-journey.svg?branch=master
:target: https://travis-ci.org/rbw/flask-journey
.. image:: https://coveralls.io/repos/github/rbw0/flask-journey/badge.svg?branch=master
:target: https://coveralls.io/github/rbw0/flask-journey?branch=master
.. image:: https://badge.fury.io/py/flask-journey.svg
:target: https://pypi.python.org/pypi/flask-journey
.. image:: https://img.shields.io/badge/License-MIT-green.svg
:target: https://opensource.org/licenses/MITDescription
-----------Extension for Flask focusing on three important areas for REST APIs:
* validation
* (de)serialization
* blueprint/route managementFlask-journey makes the process of validating and (de)serializing data to/from python objects simple and elegant with the **Journey.route** decorator - a drop-in replacement for Flask's Blueprint.route, assisted by the fantastic **Marshmallow** library.
The extension's other component, **BlueprintBundle**, helps segregate, group and register blueprints with ease while also providing methods for listing routes, either in basic form or detailed JSON.
Installing
----------.. code-block::
pip install flask-journey
Documentation
-------------
The documentation can be found `here `_Quick taste
-----------Some examples of ``@route`` and ``BlueprintBundle`` + ``Journey``
@route
^^^^^^.. code-block:: python
# file: api/users/controllers.py
from flask import Blueprint
from flask_journey import routefrom .services import create_user, get_user, update_user
from .schemas import user, users, querybp = Blueprint('users', __name__)
@route(bp, '/', methods=['GET'], _query=query, marshal_with=users)
def get_many(_query):
return get_users(_query.data)@route(bp, '/', methods=['POST'], _body=user, marshal_with=user)
def create(_body):
return create_user(_body.data)@route(bp, '/', methods=['PUT'], _body=user, marshal_with=user)
def update(user_id, _body):
return update_user(user_id, _body.data)BlueprintBundle
^^^^^^^^^^^^^^^.. code-block:: python
# file: api/bundles.py
from flask_journey import BlueprintBundle
from .users.controllers import bp as users
from .groups.controllers import bp as groupsv1 = BlueprintBundle(path='/api/v1')
v1.attach_bp(users, description='Users API')
v1.attach_bp(groups, description='Groups API')Journey
^^^^^^^.. code-block:: python
# file: api/__init__.py
from flask import Flask
from flask_journey import Journeyfrom .bundles import v1
def create_app():
app = Flask(__name__)
journey = Journey()
journey.attach_bundle(v1)
journey.init_app(app)print(journey.routes_simple)
return app
Full examples
-------------
Working examples can be found `here `_*Will add more shortly*
Compatibility
-------------
- Python >= 2.7 or >= 3.4
- Flask > 0.7Author
------
Created by Robert Wikman in 2018JetBrains
---------
Thank you `Jetbrains `_ for creating pycharm and providing me with free licenses