andrenth / ocaml-swagger

Swagger 2.0 code generator for OCaml
37 stars 10 forks source link

Trying to generate ocaml for jhipster rest #6

Open flefevre opened 6 years ago

flefevre commented 6 years ago

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.

andrenth commented 6 years ago

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.

flefevre commented 6 years ago

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

andrenth commented 6 years ago

Have you had a look at the kubecaml examples?

rdavison commented 6 years ago

@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.