OpenApiSpex upload array of files

I have the following OpenApiSpex schema which attempts to define a Message with some text and zero or more attachments:

  defmodule SendMessage do
    @max_message_size_bytes 100 * 1024
    @max_attachment_size_bytes 5 * 1024 * 1024

      title: "SendMessage",
      description: "A message to send",
      type: :object,
      required: [],
      properties: %{
        text: %Schema{
          type: :string,
          nullable: true,
          minLength: 1,
          maxLength: @max_message_size_bytes,
          description: "The text of the message"
        attachments: %Schema{
          type: :array,
          items: %Schema{
            type: :string,
            format: :binary,
            minLength: 1,
            maxLength: @max_attachment_size_bytes,
            description: "The attachment (e.g. an image)"

My controller function references this schema like this:

  @doc security: [%{"oauth" => []}],
       parameters: [
         id: [in: :path, schema: %OpenApiSpex.Schema{type: :string}, required: true]
       request_body: {"The message", "multipart/form-data", SendMessage, required: true},
       responses: [...],
       tags: [...]
  def send_message(conn, _) do

The generate OpenAPI spec and the SwaggerUI both look correct. For example, here’s the SwaggerUI:


Unfortunately, though, whenever I try to submit a request I get a 422 Unprocessable Entity Error:

  "errors": [
      "detail": "Invalid array. Got: object",
      "source": {
        "pointer": "/attachments"
      "title": "Invalid value"

I’m not sure what I’m doing wrong.