pydantic-jsonapi
an implementation of JSON:api using pydantic for validation
from pydantic_jsonapi import JsonApiModel
from pydantic import BaseModel
class Item(BaseModel):
name: str
quantity: int
price: float
ItemRequest, ItemResponse = JsonApiModel('item', Item)
# request validation
request = {
'data': {
'type': 'item',
'attributes': {
'name': 'apple',
'quantity': 10,
'price': 1.20,
},
}
}
ItemRequest(**request)
#response validation
response = {
'data': {
'id': 'abc123',
'type': 'item',
'attributes': {
'name': 'apple',
'quantity': 10,
'price': 1.20,
},
'relationships': {
'store': {
'links': {
'related': '/stores/123'
}
}
}
},
'links': {
'self': '/item/abc123'
}
}
ItemResponse(**response)
Metadata
Release files for pydantic-jsonapi 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydantic_jsonapi-0.11.0.tar.gz | 3.6 kB | Details |
Release files / pydantic_jsonapi-0.11.0.tar.gz
| Download URL | pydantic_jsonapi-0.11.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0c72d7543017121e49a41ee7e36224ba1cc3627be5efac048e3b81425e623a8
|
|
BLAKE2b-256 checksum How to use checksums |
0c08688ff0a722796c7671576cc6c1936f64302f5d20356631947dcd7b88b141
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.1
|