API serialization: Handle NULLable foreign keys correctly