Skip to content

Commit

Permalink
Merge pull request #15 from AdCombo/rename-to-flask-combo-jsonapi
Browse files Browse the repository at this point in the history
Rename to Flask-COMBO-JSONAPI
  • Loading branch information
mahenzon authored Apr 22, 2020
2 parents 8ee0c52 + b8bf4a9 commit ed99ea4
Show file tree
Hide file tree
Showing 47 changed files with 266 additions and 254 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
- pip install pytest --upgrade
script:
- python setup.py install
- coverage run --source flask_rest_jsonapi -m pytest -v
- coverage run --source flask_combo_jsonapi -m pytest -v
after_success:
- coveralls

Expand Down
48 changes: 27 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
.. image:: https://travis-ci.org/AdCombo/flask-rest-jsonapi.svg
:target: https://travis-ci.org/AdCombo/flask-rest-jsonapi
.. image:: https://coveralls.io/repos/github/AdCombo/flask-rest-jsonapi/badge.svg
:target: https://coveralls.io/github/AdCombo/flask-rest-jsonapi
.. image:: https://travis-ci.org/AdCombo/flask-combo-jsonapi.svg
:target: https://travis-ci.org/AdCombo/flask-combo-jsonapi
.. image:: https://coveralls.io/repos/github/AdCombo/flask-combo-jsonapi/badge.svg
:target: https://coveralls.io/github/AdCombo/flask-combo-jsonapi


Flask-REST-JSONAPI
##################
Flask-COMBO-JSONAPI
###################

Flask-COMBO-JSONAPI is a flask extension for building REST APIs. It combines the power of `Flask-Restless <https://flask-restless.readthedocs.io/>`_ and the flexibility of `Flask-RESTful <https://flask-restful.readthedocs.io/>`_ around a strong specification `JSONAPI 1.0 <http://jsonapi.org/>`_. This framework is designed to quickly build REST APIs and fit the complexity of real life projects with legacy data and multiple data storages.

The main goal is to make it flexible using `plugin system <https://github.com/AdCombo/combojsonapi/blob/develop/docs/en/create_plugins.rst>`_

Flask-REST-JSONAPI is a flask extension for building REST APIs. It combines the power of `Flask-Restless <https://flask-restless.readthedocs.io/>`_ and the flexibility of `Flask-RESTful <https://flask-restful.readthedocs.io/>`_ around a strong specification `JSONAPI 1.0 <http://jsonapi.org/>`_. This framework is designed to quickly build REST APIs and fit the complexity of real life projects with legacy data and multiple data storages.

Install
=======

pip install Flask-REST-JSONAPI
pip install Flask-COMBO-JSONAPI

Installation from pypi is not ready yet. Refer to the `installation manual <https://github.com/AdCombo/flask-combo-jsonapi/blob/develop/docs/installation.rst/>`_


A minimal API
=============

.. code-block:: python
from flask import Flask
from flask_rest_jsonapi import Api, ResourceDetail, ResourceList
from flask_combo_jsonapi import Api, ResourceDetail, ResourceList
from flask_sqlalchemy import SQLAlchemy
from marshmallow_jsonapi.flask import Schema
from marshmallow_jsonapi import fields
Expand Down Expand Up @@ -82,28 +88,28 @@ URL method endpoint Usage
/persons/<int:person_id> DELETE person_detail Delete a person
======================== ====== ============= ===========================

Flask-REST-JSONAPI vs `Flask-RESTful <http://flask-restful-cn.readthedocs.io/en/0.3.5/a>`_
Flask-COMBO-JSONAPI vs `Flask-RESTful <http://flask-restful-cn.readthedocs.io/en/0.3.5/a>`_
==========================================================================================

* In contrast to Flask-RESTful, Flask-REST-JSONAPI provides a default implementation of get, post, patch and delete methods around a strong specification JSONAPI 1.0. Thanks to this you can build REST API very quickly.
* Flask-REST-JSONAPI is as flexible as Flask-RESTful. You can rewrite every default method implementation to make custom work like distributing object creation.
* In contrast to Flask-RESTful, Flask-COMBO-JSONAPI provides a default implementation of get, post, patch and delete methods around a strong specification JSONAPI 1.0. Thanks to this you can build REST API very quickly.
* Flask-COMBO-JSONAPI is as flexible as Flask-RESTful. You can rewrite every default method implementation to make custom work like distributing object creation.

Flask-REST-JSONAPI vs `Flask-Restless <https://flask-restless.readthedocs.io/en/stable/>`_
Flask-COMBO-JSONAPI vs `Flask-Restless <https://flask-restless.readthedocs.io/en/stable/>`_
==========================================================================================

* Flask-REST-JSONAPI is a real implementation of JSONAPI 1.0 specification. So in contrast to Flask-Restless, Flask-REST-JSONAPI forces you to create a real logical abstration over your data models with `Marshmallow <https://marshmallow.readthedocs.io/en/latest/>`_. So you can create complex resource over your data.
* In contrast to Flask-Restless, Flask-REST-JSONAPI can use any ORM or data storage through the data layer concept, not only `SQLAlchemy <http://www.sqlalchemy.org/>`_. A data layer is a CRUD interface between your resource and one or more data storage so you can fetch data from any data storage of your choice or create resource that use multiple data storages.
* Like I said previously, Flask-REST-JSONAPI is a real implementation of JSONAPI 1.0 specification. So in contrast to Flask-Restless you can manage relationships via REST. You can create dedicated URL to create a CRUD API to manage relationships.
* Plus Flask-REST-JSONAPI helps you to design your application with strong separation between resource definition (schemas), resource management (resource class) and route definition to get a great organization of your source code.
* In contrast to Flask-Restless, Flask-REST-JSONAPI is highly customizable. For example you can entirely customize your URLs, define multiple URLs for the same resource manager, control serialization parameters of each method and lots of very useful parameters.
* Finally in contrast to Flask-Restless, Flask-REST-JSONAPI provides a great error handling system according to JSONAPI 1.0. Plus the exception handling system really helps the API developer to quickly find missing resources requirements.
* Flask-COMBO-JSONAPI is a real implementation of JSONAPI 1.0 specification. So in contrast to Flask-Restless, Flask-COMBO-JSONAPI forces you to create a real logical abstration over your data models with `Marshmallow <https://marshmallow.readthedocs.io/en/latest/>`_. So you can create complex resource over your data.
* In contrast to Flask-Restless, Flask-COMBO-JSONAPI can use any ORM or data storage through the data layer concept, not only `SQLAlchemy <http://www.sqlalchemy.org/>`_. A data layer is a CRUD interface between your resource and one or more data storage so you can fetch data from any data storage of your choice or create resource that use multiple data storages.
* Like I said previously, Flask-COMBO-JSONAPI is a real implementation of JSONAPI 1.0 specification. So in contrast to Flask-Restless you can manage relationships via REST. You can create dedicated URL to create a CRUD API to manage relationships.
* Plus Flask-COMBO-JSONAPI helps you to design your application with strong separation between resource definition (schemas), resource management (resource class) and route definition to get a great organization of your source code.
* In contrast to Flask-Restless, Flask-COMBO-JSONAPI is highly customizable. For example you can entirely customize your URLs, define multiple URLs for the same resource manager, control serialization parameters of each method and lots of very useful parameters.
* Finally in contrast to Flask-Restless, Flask-COMBO-JSONAPI provides a great error handling system according to JSONAPI 1.0. Plus the exception handling system really helps the API developer to quickly find missing resources requirements.

Documentation
=============

Documentation available here: http://flask-rest-jsonapi.readthedocs.io/en/latest/
Documentation available here: http://Flask-COMBO-JSONAPI.readthedocs.io/en/latest/

Thanks
======

Flask, marshmallow, marshmallow_jsonapi, sqlalchemy, Flask-RESTful and Flask-Restless are awesome projects. These libraries gave me inspiration to create Flask-REST-JSONAPI, so huge thanks to authors and contributors.
Flask, marshmallow, marshmallow_jsonapi, sqlalchemy, Flask-RESTful and Flask-Restless are awesome projects. These libraries gave me inspiration to create Flask-COMBO-JSONAPI, so huge thanks to authors and contributors.
4 changes: 2 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Api
===

.. currentmodule:: flask_rest_jsonapi
.. currentmodule:: flask_combo_jsonapi

You can provide global decorators as tuple to the Api.

Example:

.. code-block:: python
from flask_rest_jsonapi import Api
from flask_combo_jsonapi import Api
from your_project.security import login_required
api = Api(decorators=(login_required,))
97 changes: 49 additions & 48 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# flask-rest-jsonapi documentation build configuration file, created by
# flask-combo-jsonapi documentation build configuration file, created by
# sphinx-quickstart on Fri Oct 21 14:33:15 2016.
#
# This file is execfile()d with the current directory set to its
Expand All @@ -18,7 +18,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ------------------------------------------------

Expand All @@ -30,38 +31,39 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
#
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'flask-rest-jsonapi'
copyright = '2016, miLibris'
author = 'miLibris'
project = "flask-combo-jsonapi"
copyright = "2020, AdCombo"
author = "AdCombo"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
version = "0.1"
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = "0.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -82,7 +84,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -104,7 +106,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -121,21 +123,21 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'github_user': 'miLibris',
'github_repo': 'flask-rest-jsonapi',
'github_banner': True,
'travis_button': True,
'show_related': True,
'page_width': '1080px',
'fixed_sidebar': True,
'code_font_size': '0.8em'
"github_user": "AdCombo",
"github_repo": "flask-combo-jsonapi",
"github_banner": True,
"travis_button": True,
"show_related": True,
"page_width": "1080px",
"fixed_sidebar": True,
"code_font_size": "0.8em",
}

# Add any paths that contain custom themes here, relative to this directory.
Expand Down Expand Up @@ -164,7 +166,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -244,34 +246,30 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'flask-rest-jsonapidoc'
htmlhelp_basename = "flask-combo-jsonapidoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'flask-rest-jsonapi.tex', 'flask-rest-jsonapi Documentation',
'miLibris', 'manual'),
(master_doc, "flask-combo-jsonapi.tex", "flask-combo-jsonapi Documentation", "AdCombo", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -311,10 +309,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'flask-rest-jsonapi', 'flask-rest-jsonapi Documentation',
[author], 1)
]
man_pages = [(master_doc, "flask-combo-jsonapi", "flask-combo-jsonapi Documentation", [author], 1)]

# If true, show URL addresses after external links.
#
Expand All @@ -327,9 +322,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'flask-rest-jsonapi', 'flask-rest-jsonapi Documentation',
author, 'flask-rest-jsonapi', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"flask-combo-jsonapi",
"flask-combo-jsonapi Documentation",
author,
"flask-combo-jsonapi",
"One line description of project.",
"Miscellaneous",
),
]

# Documents to append as an appendix to all manuals.
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ You have access to 5 configration keys:
* MAX_PAGE_SIZE: the maximum page size. If you specify a page size greater than this value you will receive 400 Bad Request response.
* MAX_INCLUDE_DEPTH: the maximum length of an include through schema relationships
* ALLOW_DISABLE_PAGINATION: if you want to disallow to disable pagination you can set this configuration key to False
* CATCH_EXCEPTIONS: if you want flask_rest_jsonapi to catch all exceptions and return as JsonApiException (default is True)
* CATCH_EXCEPTIONS: if you want flask_combo_jsonapi to catch all exceptions and return as JsonApiException (default is True)
20 changes: 10 additions & 10 deletions docs/data_layer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Data layer
==========

.. currentmodule:: flask_rest_jsonapi
.. currentmodule:: flask_combo_jsonapi

| The data layer is a CRUD interface between resource manager and data. It is a very flexible system to use any ORM or data storage. You can even create a data layer that use multiple ORMs and data storage to manage your own objects. The data layer implements a CRUD interface for objects and relationships. It also manage pagination, filtering and sorting.
|
| Flask-REST-JSONAPI has a full featured data layer that use the popular ORM `SQLAlchemy <https://www.sqlalchemy.org/>`_.
| Flask-COMBO-JSONAPI has a full featured data layer that use the popular ORM `SQLAlchemy <https://www.sqlalchemy.org/>`_.
.. note::

Expand All @@ -19,7 +19,7 @@ Example:

.. code-block:: python
from flask_rest_jsonapi import ResourceList
from flask_combo_jsonapi import ResourceList
from your_project.schemas import PersonSchema
from your_project.models import Person
Expand All @@ -32,15 +32,15 @@ You can also plug additional methods to your data layer in the resource manager.

* query: the "query" additional method takes view_kwargs as parameter and return an alternative query to retrieve the collection of objects in the GET method of the ResourceList manager.

* pre / post process methods: all CRUD and relationship(s) operations have a pre / post process methods. Thanks to it you can make additional work before and after each operations of the data layer. Parameters of each pre / post process methods are available in the `flask_rest_jsonapi.data_layers.base.Base <https://github.com/miLibris/flask-rest-jsonapi/blob/master/flask_rest_jsonapi/data_layers/base.py>`_ base class.
* pre / post process methods: all CRUD and relationship(s) operations have a pre / post process methods. Thanks to it you can make additional work before and after each operations of the data layer. Parameters of each pre / post process methods are available in the `flask_combo_jsonapi.data_layers.base.Base <https://github.com/AdCombo/flask-combo-jsonapi/blob/master/flask_combo_jsonapi/data_layers/base.py>`_ base class.

Example:

.. code-block:: python
from sqlalchemy.orm.exc import NoResultFound
from flask_rest_jsonapi import ResourceList
from flask_rest_jsonapi.exceptions import ObjectNotFound
from flask_combo_jsonapi import ResourceList
from flask_combo_jsonapi.exceptions import ObjectNotFound
from your_project.models import Computer, Person
class ComputerList(ResourceList):
Expand Down Expand Up @@ -75,8 +75,8 @@ Example:
.. code-block:: python
from sqlalchemy.orm.exc import NoResultFound
from flask_rest_jsonapi import ResourceList
from flask_rest_jsonapi.exceptions import ObjectNotFound
from flask_combo_jsonapi import ResourceList
from flask_combo_jsonapi.exceptions import ObjectNotFound
from your_project.models import Computer, Person
from your_project.additional_methods.computer import before_create_object
Expand Down Expand Up @@ -105,13 +105,13 @@ By default SQLAlchemy eagerload related data specified in include querystring pa
Custom data layer
-----------------

Like I said previously you can create and use your own data layer. A custom data layer must inherit from `flask_rest_jsonapi.data_layers.base.Base <https://github.com/miLibris/flask-rest-jsonapi/blob/master/flask_rest_jsonapi/data_layers/base.py>`_. You can see the full scope of possibilities of a data layer in this base class.
Like I said previously you can create and use your own data layer. A custom data layer must inherit from `flask_combo_jsonapi.data_layers.base.Base <https://github.com/AdCombo/flask-combo-jsonapi/blob/master/flask_combo_jsonapi/data_layers/base.py>`_. You can see the full scope of possibilities of a data layer in this base class.

Usage example:

.. code-block:: python
from flask_rest_jsonapi import ResourceList
from flask_combo_jsonapi import ResourceList
from your_project.schemas import PersonSchema
from your_project.data_layers import MyCustomDataLayer
Expand Down
Loading

0 comments on commit ed99ea4

Please sign in to comment.