Fields specified as required even though they are set as Optional #249
-
Hello, Following on from the fix implemented in #220 (comment), I am trying to create a Country with no borders referenced, however I seem to be getting Validation issues when attempting to create a Country. This is even though I have the borders field set to Optional, and with a default value of None. I am not sure if I am doing this correctly, but any assistance would be greatly appreciated! Thanks in advance Model:
Country POST handling with crud helper function:
POST example:
Exception/Error raised:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
OK, so few points:
@router.post("/", response_model=Country, status_code=status.HTTP_201_CREATED)
async def create_country(country: Country): # if this is ormar
return await country.upsert() # it's already initialized as ormar model But saying all this there seems to be a bug with pydantic field definition, will check that. Thanks for reporting! |
Beta Was this translation helpful? Give feedback.
-
Fixed in 0.10.12 (via #251) |
Beta Was this translation helpful? Give feedback.
Fixed in 0.10.12 (via #251)