OpenAPITools / OpenAPITools/openapi-generator

[BUG][OCaml] Construction of multipart/form-data is incorrect

Open
#14,987 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Hi and many thanks to all maintainers and workers on the OpenAPI initiative! This is a great effort :)

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

The template for OCaml client generation does not construct multipart/form-data correctly. The incorect logic can be seen

https://github.com/OpenAPITools/openapi-generator/blob/c6a4947523dd079492d3604d45e451a31f5e94a7/modules/openapi-generator/src/main/resources/ocaml/support.mustache#L83-L97

It looks like it is instead producing x-www-form-urlencoded data, but this still ends up being supplied as the body for POST requests specified as taking form-data.

openapi-generator version

Visible on head.

OpenAPI declaration file content or url

Any spec with something like

      requestBody:
        required: true
        content:
          multipart/form-data:

should produce a broken client, but you can see the incorrect logic from the source code.

Related issues/PRs
Suggest a fix

I have hit too many bugs in the generated OCaml library for me to have time to report them all. Other errors included incorret deserialization logid for data including the object keyword and syntactically incorrect datatypes for endpoints taking no data.

I appologize for not having time to report all the details.

I recommend updating the tables on the OCaml client generation to mark it as unstable, and remove the claim to support multipart forms.

I am experimenting with a fix, but not thru the handlebars approach, which looks too brittle IMO. I'll update here if I produce anything that will be of general interest.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/openapi-generator/src/main/resources/ocaml/support.mustache at lines 83-97, where multipart/form-data request construction is defined. Compare the generated body with the OpenAPI declaration and verify the client uses multipart encoding rather than x-www-form-urlencoded; done means generated OCaml clients send valid multipart/form-data bodies.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.