Skip to main content

JSON API driven by aiohttp

Project description

=======================================
`JSON API`_ implementation for aiohttp_
=======================================


.. image:: https://img.shields.io/pypi/v/aiohttp_json_api.svg
:target: https://pypi.python.org/pypi/aiohttp_json_api

.. image:: https://img.shields.io/travis/vovanbo/aiohttp_json_api.svg
:target: https://travis-ci.org/vovanbo/aiohttp_json_api

.. image:: https://readthedocs.org/projects/aiohttp-json-api/badge/?version=latest
:target: https://aiohttp-json-api.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://pyup.io/repos/github/vovanbo/aiohttp_json_api/shield.svg
:target: https://pyup.io/repos/github/vovanbo/aiohttp_json_api/
:alt: Updates


Introduction
------------

This project heavily inspired by py-jsonapi_ (author is `Benedikt Schmitt`_).
Some parts of this project is improved and refactored dev-schema_ branch
of **py-jsonapi**. At beginning of aiohttp-json-api_ this branch
was a great, but not finished implementation of JSON API with
*schema controllers*. Also, py-jsonapi_ is not asynchronous and use inside
self-implemented Request/Response classes.

Some of base entities of **py-jsonapi** was replaced with **aiohttp**
server's objects, some of it was divided into new separate entities
(e.g. :class:`.context.RequestContext` or :class:`.registry.Registry`).

* Free software: MIT license
* Documentation: https://aiohttp-json-api.readthedocs.io


Requirements
------------

* **Python 3.5** or newer
* aiohttp_
* inflection_
* jsonpointer_
* dateutil_
* trafaret_


Todo
----

* Documentation
* Tests
* Example application
* Features description
* Customizable payload keys inflection (default is `dasherize` <-> `underscore`)
* Support for JSON API extensions (bulk creation etc.)


Credits
-------

This package was created with Cookiecutter_ and the
`cookiecutter-pypackage`_ project template.


.. _aiohttp-json-api: https://github.com/vovanbo/aiohttp_json_api
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _cookiecutter-pypackage: https://github.com/audreyr/cookiecutter-pypackage
.. _JSON API: http://jsonapi.org
.. _aiohttp: http://aiohttp.readthedocs.io/en/stable/
.. _py-jsonapi: https://github.com/benediktschmitt/py-jsonapi
.. _dev-schema: https://github.com/benediktschmitt/py-jsonapi/tree/dev-schema
.. _`Benedikt Schmitt`: https://github.com/benediktschmitt
.. _inflection: https://inflection.readthedocs.io/en/latest/
.. _jsonpointer: https://python-json-pointer.readthedocs.io/en/latest/index.html
.. _dateutil: https://dateutil.readthedocs.io/en/stable/
.. _trafaret: http://trafaret.readthedocs.io/en/latest/


=======
History
=======

0.15.0 (2017-07-18)
-------------------

* Pagination is initialized from request by default. Remove separate class method of BasePagination to initialize pagination instance
* Improve value validation error for absent fields
* Improve validation error of string field with choices


0.14.0 (2017-07-13)
-------------------

* Customisable JSON API handlers support
* DRY in handlers
* Move context builder from middleware to jsonapi_handler decorator
* Request context receive optional resource_type now


0.13.0 (2017-07-12)
-------------------

* Revert back to asynchronous setters, because it's used in update relationships and it might want to query DB, for example


0.12.0 (2017-07-12)
-------------------

* Base Registry class from UserDict, so Registry is a dict with ensure_identifier method.
* More strict typing checks on setup.


0.11.1 (2017-07-11)
-------------------

* Fix bug with mutation not cloned resource in method for delete relationship
* Require JSON API content type on delete relationships


0.11.0 (2017-07-11)
-------------------

* Method for update return original and updated resource as result. Updated resource is created via deepcopy. It will be useful to determine returned HTTP status
* Fix bug with enumeration (choices) in String field
* Fix bug with context event setup for OPTIONS, HEAD and another request methods not used in JSON API


0.10.0 (2017-07-10)
-------------------

* Mass refactoring of schema, fields, validation and decorators
* Generic approach to setup Schema decorators is used (inspired by Marshmallow)
* Fields are used only for encode/decode now (with pre/post validation). Additional validators for fields must be created on schema level
* Custom JSON encoder with support JSONPointer serialization
* Remove boltons from requirements
* No more remap input data dictionary with key names to underscores conversion.
* Add helpers "first" and "make_sentinel" (cherry-picked from boltons)
* Fix enumeration (choices) support in String field


0.9.3 (2017-07-06)
------------------

* Setup content-type validation on mutation API methods (application/vnd.api+json is required)
* Properly get and encode relationships fields
* Update docs and typing for ensure_identifier Registry's method


0.9.2 (2017-07-06)
------------------

* Fix bugs related to Python 3.5
* Generation of documentation on RTD is fixed


0.9.1 (2017-07-06)
------------------

* Python 3.5 compatibility changes


0.9.0 (2017-07-06)
------------------

* Handle aiohttp-json-api exceptions and errors in middleware. If exceptions is not related to JSON API errors, then exception is reraised
* Huge refactoring of RequestContext
* No more use of boltons cachedproperties, instead use parsing static methods related to each request context' entity
* Update docs for RequestContext methods
* Add typings to RequestContext


0.8.2 (2017-07-05)
------------------

* Properly handle error with wrong relation name (raise HTTP 400)


0.8.1 (2017-07-05)
------------------

* Fix bdist_wheel python tag to support Python 3.5


0.8.0 (2017-07-05)
------------------

* Python 3.5 support (avoid usage of Python 3.6 format strings)
* Registry is plain object now
* Custom Registry support (`registry_class` parameter in ``aiohttp_json_api.setup_jsonapi`` method)
* Log debugging information at start about registered resources, methods and routes
* Use OrderedDict inside SchemaMeta


0.7.2 (2017-07-04)
------------------

* Fix bug with JSONPointer when part passed via __truediv__ is integer
* Validate relationship object before adding relationship in ToMany field


0.7.1 (2017-07-04)
------------------

* Fix bugs with validation of resource identifier in relationships fields
* Add typings for base fields


0.7.0 (2017-07-03)
------------------

* Setup of JSON API must be imported from package directly
* Fix bugs with decode fields and allow None values


0.6.2 (2017-06-29)
------------------

* Update HISTORY


0.6.1 (2017-06-29)
------------------

* Fix bug with Enum choices of String field


0.6.0 (2017-06-29)
------------------

* Return resource in update method of Schema class. This will be helpful in inherit classes of Schemas.


0.5.5 (2017-06-15)
------------------

* Setup auto-deploy to PyPI in Travis CI

0.5.4 (2017-06-15)
------------------

* Initial release on PyPI

0.5.3 (2017-06-14)
------------------

* Improve documentation

0.5.0 (2017-06-14)
------------------

* Don't use attrs_ package anymore
* Refactor requirements (move it into `setup.py`)

0.4.0 (2017-06-13)
------------------

* Schema imports refactoring (e.g. don't use ``aiohttp_json_api.schema.schema.Schema`` anymore)

0.3.0 (2017-06-13)
------------------

* Upgrade requirements

0.2.0 (2017-05-26)
------------------

* Fix setup.py
* Add test for Decimal trafaret field

0.1.1 (2017-05-26)
------------------

* Dirty initial version


.. _attrs: http://www.attrs.org/en/stable/


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

aiohttp_json_api-0.15.0.tar.gz (49.0 kB view details)

Uploaded Source

Built Distribution

aiohttp_json_api-0.15.0-py35.py36-none-any.whl (48.0 kB view details)

Uploaded Python 3.5 Python 3.6

File details

Details for the file aiohttp_json_api-0.15.0.tar.gz.

File metadata

File hashes

Hashes for aiohttp_json_api-0.15.0.tar.gz
Algorithm Hash digest
SHA256 51a71965143bac2adcaef780995a71ab90752c72fc48b29ef464f03cbcd46dff
MD5 5decb87dbea63690c149276a2852069e
BLAKE2b-256 5d5f54b93addf5e647f26b3267b069b65715b9b269ec5ad1c4ceb72c3c8fb0cd

See more details on using hashes here.

File details

Details for the file aiohttp_json_api-0.15.0-py35.py36-none-any.whl.

File metadata

File hashes

Hashes for aiohttp_json_api-0.15.0-py35.py36-none-any.whl
Algorithm Hash digest
SHA256 8789a73f433f9491b6b2c7df453cc70e1470076149930d2992adf1175f95b7ce
MD5 3895c1cdbbbe56b4662da47bb42e159e
BLAKE2b-256 298622de6383bc5d67e0947e75769bea59532acc08afa7c4e821f3bdec36e8f2

See more details on using hashes here.

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