pydantic-jsonapi
pydantic-jsonapi copied to clipboard
Optional Attributes are omitted on response
class Item(BaseModel):
name: str
quantity: int
price: float
description: [Optional] str = "Not included"
In the database, description is stored as None for 1 object.
In the response, we expect
...
"attributes": {
"name": "Orange",
"quantity": "5",
"price": "1.00",
"description": "Not included"
}
...
Instead, description is omitted and not returned in the response. How can we include Optional attributes when they are None in the database?