OpenAPITools / OpenAPITools/openapi-generator

[BUG][OCaml] Generated Docker API build fails with missing argument

Open
#12,767 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

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?
Description

The generated OCaml bindings to Docker Engine API cannot be build due to a missing argument. This is a re-open of the last error reported in #9787 for visibility.

File "src/apis/plugin_api.ml", line 22, characters 52-56:
22 |     Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
                                                         ^^^^
Error: This expression has type 'a -> Cohttp_lwt.Body.t
       but an expression was expected of type Cohttp_lwt.Body.t

comes from here:

{{#bodyParams}}
    let body = Request.{{#isFreeFormObject}}write_json_body{{/isFreeFormObject}}{{#isByteArray}}write_string_body{{/isByteArray}}{{^isFreeFormObject}}{{^isByteArray}}write_as_json_body{{/isByteArray}}{{/isFreeFormObject}} {{> to_json}} {{{paramName}}} in
{{/bodyParams}}
openapi-generator version
openapi-generator-cli 6.1.0-SNAPSHOT
  commit : 97daba5
  built  : 2022-07-04T07:33:51Z
OpenAPI declaration file content or url

https://docs.docker.com/engine/api/v1.41.yaml

Steps to reproduce
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
    -i https://docs.docker.com/engine/api/v1.41.yaml \
    -g ocaml \
    -o /local
sudo chown -R "$(whoami):$(whoami)" .
opam exec -- dune build @all
Related issues/PRs
Suggest a fix

The generated code is missing one argument, the converter to Yojson.Safe.t, which is probably the identity function in this case (fun x -> x).

let body = Request.write_as_json_body  input_stream in
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->

cc @wing328

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

Inspect modules/openapi-generator/src/main/resources/ocaml/api-impl.mustache, especially the body parameter rendering shown in the issue. Reproduce generation from the Docker Engine API v1.41.yaml and run opam exec -- dune build @all; done means the generated OCaml client builds without the missing-argument error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.