0

我想做一个招摇的端点,即请求主体是一个具有 2 个整数字段的产品对象和一个具有另外 2 个字段的选项对象,我将rswag其用作 ruby​​ gem

在我的规范中

      parameter in: :body, schema: {
        type: :object,
        properties: {
            product_id: { type: :integer },
            quantity: { type: :integer },
            options: {
                properties: {
                  color: { type: :string },
                  size: { type: :string },
                }
            },
          }
      }

但是,在我的用户界面中,我没有颜色或大小字段,只有一个选项文本字段,我该如何解决这个问题?

4

1 回答 1

0

尝试这个 :

  parameter in: :body, schema: {
    type: :object,
    properties: {
        product_id: { type: :integer },
        quantity: { type: :integer },
        options: {
            type: :object,
            properties: {
              color: { type: :string },
              size: { type: :string },
            }
        },
      }
  }
于 2021-09-21T19:01:20.670 回答