Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 of 6 tasks
jorgeferdz opened this issue Dec 3, 2024 · 0 comments

Comments

@jorgeferdz
Copy link
Contributor

jorgeferdz commented Dec 3, 2024

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

@wing328 wing328 closed this as completed in 71ccc88 Dec 4, 2024
wing328 added a commit that referenced this issue Dec 5, 2024
wing328 added a commit that referenced this issue Dec 5, 2024
wing328 pushed a commit that referenced this issue Dec 9, 2024
…files (#20274)

* feat(issue-20231): Kotlin okhttp client handles correctly fields that are optional with multiple files.

* docs(issue-20231): add docstrings

* feat(issue-20231): Remove unnecessary test spec

* feat(issue-20231): Kotlin okhttp client handles correctly fields that are optional with multiple files.

* docs(issue-20231): add docstrings

* feat(issue-20231): Remove unnecessary test spec

* feat(issue-20231): Remove unnecessary if condition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant