pydantic-jsonapi icon indicating copy to clipboard operation
pydantic-jsonapi copied to clipboard

Optional Attributes are omitted on response

Open cickes opened this issue 5 years ago • 0 comments

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?

cickes avatar Oct 30 '20 17:10 cickes