jsonapi-pydantic
JSON:API implementation with Pydantic.
Description
jsonapi-pydantic provides a suite of Pydantic models matching the JSON:API specification.
Install
$ pip install jsonapi-pydantic
Or use your python package manager.
Usage
Object with primary data:
from jsonapi_pydantic.v1_0 import TopLevel
external_data = {
"data": [
{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON:API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z",
},
"relationships": {"author": {"data": {"id": "42", "type": "people"}}},
}
],
"included": [
{"type": "people", "id": "42", "attributes": {"name": "John", "age": 80, "gender": "male"}}
],
}
top_level = TopLevel(**external_data)
print(top_level.model_dump(exclude_unset=True))
"""
{
"data": [
{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON:API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z",
},
"relationships": {"author": {"data": {"id": "42", "type": "people"}}},
}
],
"included": [
{"type": "people", "id": "42", "attributes": {"name": "John", "age": 80, "gender": "male"}}
],
}
"""
print(top_level.data)
"""
[
Resource(
type="articles",
id="1",
attributes={
"title": "JSON:API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z",
},
relationships={
"author": Relationship(
links=None, data=ResourceIdentifier(id="42", type="people", meta=None), meta=None
)
},
links=None,
meta=None,
)
]
"""
Examples
More examples can be found here.
License
See license.md.
Metadata
Release files for jsonapi-pydantic 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsonapi_pydantic-0.2.5.tar.gz | 4.9 kB | Without provenance | Details for jsonapi_pydantic-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonapi_pydantic-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for jsonapi_pydantic-0.2.5-py3-none-any.whl |
Total release size: 14.2 kB
Release files / jsonapi_pydantic-0.2.5.tar.gz
| Download URL | jsonapi_pydantic-0.2.5.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54310cabd3f65fa6bcfaaa003d173ed71aed2022e863922c66b57d93b751f4c4
|
|
BLAKE2b-256 checksum How to use checksums |
71c85ac5af58a7b181c701cdbed9bca5d8845ea6e72e6dad0d3a74b422071a78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.3 Linux/6.6.32_1
|
Release files / jsonapi_pydantic-0.2.5-py3-none-any.whl
| Download URL | jsonapi_pydantic-0.2.5-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15100aa616b190edbb6d1a7dca2437d6023d45887c34f3f08ff40b6d0b092cea
|
|
BLAKE2b-256 checksum How to use checksums |
4da9e894b27f7d07bf01518f1282060f860a90b6801d922f62cb0a053fb20656
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.3 Linux/6.6.32_1
|
Security for jsonapi-pydantic 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.