Skip to content

[BUG][Kotlin][OkHTTP] Client does not process correctly fields with a List<File> or optional File #20231

Description

@jorgeferdz

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Describing an endpoint as follows:

...
requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          attachments:
            type: array
            description: attached files
            items:
              type: string
              format: binary
...

it generates the endpoint correctly (using cURL works fine) but while using the Kotlin okhttp autogenerated client the files are never there.

After exploring the code and comparing it to the Java counterpart, I noticed that the client only considers the case where the field value is just a File but it doesn't work when the field is an optional field or the type List

openapi-generator version

7.11.0

OpenAPI declaration file content or url
requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          attachments:
            type: array
            description: attached files
            items:
              type: string
              format: binary
Generation Details

I am not sure what to write here. I tested it in my own project (by building it locally and adding it manually in my project). I am not sure how to test it within this project and some guidance would be very much appreciated.

Steps to reproduce

Just using the autogenerated client by not sending a File or sending multiple files will create reproduce the error.

Related issues/PRs
Suggest a fix

I did some changes and I will attach a PR as soon as I open it with the possible fix. EDIT: Here it is the PR

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions