如何在 python 前夕为嵌入式词典列表的模式建模

How to model schema for list of embedded dictionaires in python eve

我有一个文档,其中用户有 2 个地址,如下所示。我如何在 python-eve 中为此创建架构?

此外,我将如何创建一个 API 请求以允许用户仅更新邮政编码。他们必须重新发布整个文档吗?

{
   _id: "joe",
   name: "Joe Bookreader",
   addresses: [
                {
                  street: "123 Fake Street",
                  city: "Faketon",
                  state: "MA",
                  zip: "12345"
                },
                {
                  street: "1 Some Other Street",
                  city: "Boston",
                  state: "MA",
                  zip: "12345"
                }
              ]
 }

就架构而言,这应该可以解决问题 (docs):

'addresses': {
    'type': 'list',
    'schema' {
        'type': 'dict',
        'schema': {
            'street': {'type': 'string'},
            'city': {'type': 'string'},
            'state': {'type': 'string'},
            'zip': {'type': 'string'}
         }
     }
 }

PATCH(更新)请求支持点符号,但不支持文档列表。它们更棘手,并且很难以 RESTful 的方式完成。目前有一个 open ticket,但恐怕还不是直接的解决方案。