OpenAPITools / OpenAPITools/openapi-generator
[BUG][OCaml] Generated Docker API build fails with missing argument
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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