JSON API 1.0 (https://jsonapi.org) formatting with marshmallow
Project description
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Description: *******************
marshmallow-jsonapi
*******************
.. image:: https://badge.fury.io/py/marshmallow-jsonapi.svg
:target: http://badge.fury.io/py/marshmallow-jsonapi
:alt: Latest version
.. image:: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi.svg
:target: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi
:alt: Travis-CI
Homepage: http://marshmallow-jsonapi.readthedocs.io/
JSON API 1.0 (`https://jsonapi.org <http://jsonapi.org/>`_) formatting with `marshmallow <https://marshmallow.readthedocs.io>`_.
marshmallow-jsonapi provides a simple way to produce JSON API-compliant data in any Python web framework.
.. code-block:: python
from marshmallow_jsonapi import Schema, fields
class PostSchema(Schema):
id = fields.Str(dump_only=True)
title = fields.Str()
author = fields.Relationship(
'/authors/{author_id}',
related_url_kwargs={'author_id': '<author.id>'},
)
comments = fields.Relationship(
'/posts/{post_id}/comments',
related_url_kwargs={'post_id': '<id>'},
# Include resource linkage
many=True, include_resource_linkage=True,
type_='comments'
)
class Meta:
type_ = 'posts'
strict = True
post_schema = PostSchema()
post_schema.dump(post).data
# {
# "data": {
# "id": "1",
# "type": "posts"
# "attributes": {
# "title": "JSON API paints my bikeshed!"
# },
# "relationships": {
# "author": {
# "links": {
# "related": "/authors/9"
# }
# },
# "comments": {
# "links": {
# "related": "/posts/1/comments/"
# }
# "data": [
# {"id": 5, "type": "comments"},
# {"id": 12, "type": "comments"}
# ],
# }
# },
# }
# }
Installation
============
::
pip install marshmallow-jsonapi
Documentation
=============
Full documentation is available at https://marshmallow-jsonapi.readthedocs.io/.
Requirements
============
- Python >= 2.7 or >= 3.4
Project Links
=============
- Docs: http://marshmallow-jsonapi.readthedocs.io/
- Changelog: http://marshmallow-jsonapi.readthedocs.io/en/latest/changelog.html
- PyPI: https://pypi.python.org/pypi/marshmallow-jsonapi
- Issues: https://github.com/marshmallow-code/marshmallow-jsonapi/issues
License
=======
MIT licensed. See the bundled `LICENSE <https://github.com/marshmallow-code/marshmallow-jsonapi/blob/master/LICENSE>`_ file for more details.
Keywords: marshmallow-jsonapi marshmallow marshalling serialization jsonapi deserialization validation
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Description: *******************
marshmallow-jsonapi
*******************
.. image:: https://badge.fury.io/py/marshmallow-jsonapi.svg
:target: http://badge.fury.io/py/marshmallow-jsonapi
:alt: Latest version
.. image:: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi.svg
:target: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi
:alt: Travis-CI
Homepage: http://marshmallow-jsonapi.readthedocs.io/
JSON API 1.0 (`https://jsonapi.org <http://jsonapi.org/>`_) formatting with `marshmallow <https://marshmallow.readthedocs.io>`_.
marshmallow-jsonapi provides a simple way to produce JSON API-compliant data in any Python web framework.
.. code-block:: python
from marshmallow_jsonapi import Schema, fields
class PostSchema(Schema):
id = fields.Str(dump_only=True)
title = fields.Str()
author = fields.Relationship(
'/authors/{author_id}',
related_url_kwargs={'author_id': '<author.id>'},
)
comments = fields.Relationship(
'/posts/{post_id}/comments',
related_url_kwargs={'post_id': '<id>'},
# Include resource linkage
many=True, include_resource_linkage=True,
type_='comments'
)
class Meta:
type_ = 'posts'
strict = True
post_schema = PostSchema()
post_schema.dump(post).data
# {
# "data": {
# "id": "1",
# "type": "posts"
# "attributes": {
# "title": "JSON API paints my bikeshed!"
# },
# "relationships": {
# "author": {
# "links": {
# "related": "/authors/9"
# }
# },
# "comments": {
# "links": {
# "related": "/posts/1/comments/"
# }
# "data": [
# {"id": 5, "type": "comments"},
# {"id": 12, "type": "comments"}
# ],
# }
# },
# }
# }
Installation
============
::
pip install marshmallow-jsonapi
Documentation
=============
Full documentation is available at https://marshmallow-jsonapi.readthedocs.io/.
Requirements
============
- Python >= 2.7 or >= 3.4
Project Links
=============
- Docs: http://marshmallow-jsonapi.readthedocs.io/
- Changelog: http://marshmallow-jsonapi.readthedocs.io/en/latest/changelog.html
- PyPI: https://pypi.python.org/pypi/marshmallow-jsonapi
- Issues: https://github.com/marshmallow-code/marshmallow-jsonapi/issues
License
=======
MIT licensed. See the bundled `LICENSE <https://github.com/marshmallow-code/marshmallow-jsonapi/blob/master/LICENSE>`_ file for more details.
Keywords: marshmallow-jsonapi marshmallow marshalling serialization jsonapi deserialization validation
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
marshmallow-jsonapi-0.10.0.tar.gz
(27.2 kB
view hashes)
Built Distribution
Close
Hashes for marshmallow-jsonapi-0.10.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7558a647b21b63888313b1ef350569c970681fc02948655c48811c80e48df2fb |
|
MD5 | 61b63d126447a5312e7cde80be7d1a87 |
|
BLAKE2b-256 | 7522990d112a26e3cd66c91ba37f5cd2153660302279892850e2f29c9668e9a7 |
Close
Hashes for marshmallow_jsonapi-0.10.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56ee19907705592cc0a1ca3f22ed4373c07b2268aea4ae5d43b79ca75e512a83 |
|
MD5 | 8aefa6cf5585642abf45ca99c6e2e5e4 |
|
BLAKE2b-256 | 3f719bb2382b05943a5937297548b48c0bb9e37d19515077cd991286c951ca0f |