ocaml-swagger icon indicating copy to clipboard operation
ocaml-swagger copied to clipboard

Trying to generate ocaml for jhipster rest

Open flefevre opened this issue 5 years ago • 4 comments

I have tried your excellent ocaml generator for swagger with a Jhipster application 1, which is commonly used for java developer. My goal was to be able to make a bridge between java rest service and ocaml. Nevertheless, I didn't succeed, they were problems of generation. The REST api is fully functional but no way to generate the code. And as a newbie in ocaml, no way also to understand how to create a snipped of code to query for instance the "/api/web3jv/get-admin-web-3-j-version" rest service.

swagger.full.txt

I have tried to remove the

"produces": [ "*/*" ],

by

"produces": [ "application/json" ],

and also suppress the

"type": "object",

but I am not sure how to do it? I would appreciate your help.

flefevre avatar Oct 11 '18 09:10 flefevre

It seems to be dying initially on the empty contact and license objects in the info object (I'm not sure if that's legal), and it looks like there's a bug in the handling of objects, where the properties field is ignored and the additionalProperties field is considered required, but shouldn't be (?).

I haven't been using OCaml for work recently, so I'll have to be honest and say I don't know when I'll have time to try to fix this, but I'll gladly merge a PR if you want to try your hand at it.

andrenth avatar Oct 11 '18 18:10 andrenth

Hello, I have tried again with your advices. it works a little. I have removed the unfilled properties, and make the small changes i have proposed befored. Nevertheless as i am a newbie in ocaml, I do not know how to write a minimal ocaml code to query the rest api through the generated code.

will you be able to tell how to write the minimal ocaml code to query

` module Web3jv : sig

  module Get_web_3_j_version : sig

    val request_path_template : unit -> string

    val get : Uri.t -> (string, string) result Lwt.t
  end

end

`

swagger.json.txt

kubecaml.ml.txt

ocamlswagger.zip

flefevre avatar Oct 15 '18 14:10 flefevre

Have you had a look at the kubecaml examples?

andrenth avatar Oct 16 '18 12:10 andrenth

@flefevre : Perhaps you can try using utop to help you navigate the generated code. In your project directory, you can run dune utop, or perhaps dune utop -p kubecaml (replace with the name of the package that you are developing). Then you can interactively browse the generated code.

rdavison avatar Nov 06 '18 17:11 rdavison