JSON API 1.0 (https://jsonapi.org) formatting with marshmallow
Project description
⚠️ I still need this package in some of my projects. This for is minimal work required to keep it working with newer Pythons and tooling (uv). For the time being, I have no resources to invest into any major work on this. Therefore, it will not be upgraded to marshmallow 4 in foreseeable future.
⚠️ To allow integrating it in my projects, it is published on PyPI as marshmallow-jsonapi-minfork.
Homepage: http://marshmallow-jsonapi.readthedocs.io/
JSON API 1.0 (https://jsonapi.org) formatting with marshmallow.
marshmallow-jsonapi provides a simple way to produce JSON API-compliant data in any Python web framework.
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"
post_schema = PostSchema()
post_schema.dump(post)
# {
# "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 >= 3.6
Project Links
License
MIT licensed. See the bundled LICENSE file for more details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file marshmallow_jsonapi_minfork-0.25.0.tar.gz.
File metadata
- Download URL: marshmallow_jsonapi_minfork-0.25.0.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb9b526971b289c7f6da76071c56bc9c5efaf224f5b4aafe7c798c91b9205bc6
|
|
| MD5 |
397f7bde51749e51941180643d0be832
|
|
| BLAKE2b-256 |
67d1c95449d51aee04c18b180c2025ceafaeaf8ec14df3fb7d235d5386c3f59c
|
Provenance
The following attestation bundles were made for marshmallow_jsonapi_minfork-0.25.0.tar.gz:
Publisher:
pypi-publish.yaml on tadams42/marshmallow-jsonapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marshmallow_jsonapi_minfork-0.25.0.tar.gz -
Subject digest:
cb9b526971b289c7f6da76071c56bc9c5efaf224f5b4aafe7c798c91b9205bc6 - Sigstore transparency entry: 230608297
- Sigstore integration time:
-
Permalink:
tadams42/marshmallow-jsonapi@348e041917a3ca9fe04b61fd8f77167ed1bcf8d0 -
Branch / Tag:
refs/tags/0.25.0 - Owner: https://github.com/tadams42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@348e041917a3ca9fe04b61fd8f77167ed1bcf8d0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file marshmallow_jsonapi_minfork-0.25.0-py3-none-any.whl.
File metadata
- Download URL: marshmallow_jsonapi_minfork-0.25.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0cfd18429f2f77cae0122873de5645a8f635eb2408a5e72c250057821682863
|
|
| MD5 |
a39783e520ea7c22801424a4335a0135
|
|
| BLAKE2b-256 |
d7e382e28cb9c28512123369166a65684a08b6f94f75c34b8fdd1505a365bcd8
|
Provenance
The following attestation bundles were made for marshmallow_jsonapi_minfork-0.25.0-py3-none-any.whl:
Publisher:
pypi-publish.yaml on tadams42/marshmallow-jsonapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marshmallow_jsonapi_minfork-0.25.0-py3-none-any.whl -
Subject digest:
e0cfd18429f2f77cae0122873de5645a8f635eb2408a5e72c250057821682863 - Sigstore transparency entry: 230608302
- Sigstore integration time:
-
Permalink:
tadams42/marshmallow-jsonapi@348e041917a3ca9fe04b61fd8f77167ed1bcf8d0 -
Branch / Tag:
refs/tags/0.25.0 - Owner: https://github.com/tadams42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@348e041917a3ca9fe04b61fd8f77167ed1bcf8d0 -
Trigger Event:
release
-
Statement type: