OpenAPI request with array of objects body treated as single object without array

For an OpenAPI resource with an endpoint like the following (irrelevant parts omitted):

{
  "/x/{market}/y": {
    "post": {
      "requestBody": {
        "content": {
          "application/json": {
            "schema": {
              "type": "array",
              "items": { "$ref": "#/components/schemas/ProductsManualOverride" }
            }
          }
        }
      }
    }
  }
}

the interface in Retool shows the following:

There is no way to remove those request body parameters or somehow change them to an array.

When I fill out the form and send a preview request, the request body does in fact only show a single object instead of an array.

When viewed in Swagger, the array resource is correctly displayed.


Self-hosted Retool version 2.121.5 deployed with the retool-wf Helm chart.

Hi @jeengbe! Happy to take a look at this.

Quick question—does the request fail because of these additional required parameters?

Hi, thanks for your reply!

The issue is that Retool treats the array of objects as a singular object only. Only a single input is expected, and when the request is sent, the body is a single JSON object instead of an array. That in turn causes the request to fail since the API expects an array containing objects.

Hope that helps :slightly_smiling_face:

Ah, got it! This definitely seems like a bug on our end. I've filed an internal ticket for this and will keep you updated with any fixes :slight_smile:

Are you fully blocked here? To be transparent, we're likely not prioritizing this particularly soon, so I just wanted to check with you.

Thank you, I appreciate the transparency.
I haven't actually tried anything yet (low prio feature), but I'm sure I'll find a way around it for the time being :slightly_smiling_face:

1 Like

I have exactly the same bug:

Schema:

Formular:

Is there any workaround??

do you find something?

Yeah, sorry for not updating. You can work around this by adding the same resource as a plain REST API, and for the batch endpoints for which array fields don't work, you can construct the URL manually and use something like the following:

but where can i get the auth ( OAuth 2.0 token ) from the resource.
Our API is not public!

I would suggest that all OpenAPI resources also have an alternate RAW/JSON mode.
Like for example with the SQL resources.
image

This also affects us, and is an important use-case. Adding additional resources is a fine temporary workaround, but obviously isn't an acceptable long term solution. I'd love to better understand what areas of the openapi spec are and are not current supported, and where fixing this sits on the roadmap.

Thanks!

Definitely valid. We support arrays in the Open API resource, just not as a top level type for requestBody, but we have an internal request to support this! It's not currently on our roadmap (so we probably can't expect a fix in the next few months), but we're constantly adjusting our roadmap to accommodate for high-impact requests. You adding your context above is already very insightful!

This is an also for us, bumping!

Noted - thank you!

@Elliott @clarkmcc @kim I'm working on a change that would allow you to enter any request body you want when we don't support the request body schema with our UI. It is akin to the RAW mode that @kim suggested above. Please let me know if this sounds good to you:

2 Likes

@Elliott @clarkmcc @kim This is now rolled out! Please help me verify that it works for your use case

Hi Harry,

That change makes sense and looks like it would handle our use-case. What versions of Retool has this been added to? I'm specifically using self-hosted retool.

Thank you,
Elliott