Swagger nested parameter object

627 Views Asked by At

I'd like to make a swagger endpoint thats request body is a product object with 2 integar fields and an options object with 2 more fields, I'm using rswag as a ruby gem

In my spec

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

However, in my ui I have no fields for color or size, just a text field for options, how can i fix this?

1

There are 1 best solutions below

0
On

Try this :

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