将二维数组从 python 传递到 swagger

passing a 2D array from python to swagger

我很困惑为什么这不起作用。这是我的 swagger.yaml 部分,它定义了结果是什么。链接到这个 returns 数组数组的代码:

[[string,float],....]

当我将此数组切换为

[string,string,...]

一切正常。

results:
    type: "object"
    required:
    - "content"
    properties:
      content:
        type: "array"
        items:
          type: "array"
          items: {}

不确定二维数组发生了什么。招摇不断抱怨:

raise TypeError('Expected bytes') TypeError: Expected bytes

Swagger 2.0 之前不允许使用嵌套数组。

如果您使用的是 1.2 或更早版本,则不能直接嵌套数组。见1.2 spec的section 4.3.3,具体表示'A container MUST NOT be nested in another container.'

2.0 现在允许嵌套数组,但我的有限理解是数组元素必须全部是同一类型。这来自名为 'ITEMS OBJECT' 的部分,大约在 the 2.0 spec.

的三分之一处

除此之外我不能给你很多有用的建议。 github 问题页面非常有趣,因为许多与您的问题相关的问题都以 'why not do it this way instead' 类型的方式涵盖。 Issue 53 似乎与您的问题相关,例如,还描述了数组限制的嵌套数组(2.0 之前)并描述了解决它的方法。

希望对您有所帮助