-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OCaml] new client generator #3446
Conversation
…n sérialize les variants comme des tableaux JSON.
…sous forme d'un tableau JSON contenant une unique string.
… plusieurs énumérations partagent des valeurs communes ce que ne permettent pas les variants ordinaires au sein d'un même module.
…t prendre en compte les pathParams, les queryParams, les headersParams, les bodyParams et la réponse JSON. Manque le support du multipart, du form encoded et des mécanismes d'authentification.
…isation d'un fichier OAS plus gros et complexe que Petstore.
…exception Failure pour avoir des types plus simples et non dépendants de Pppx_deriving_yoson_runtime dans les APIs générées.
…ake-endpoints-models-for-testing.yaml generate properly.
…enerated identifiers to support all the corner cases present in modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml.
…/3_0/petstore-with-fake-endpoints-models-for-testing.yaml.
…he case of ArraySchema parameters. This allows correct processing of modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml.
…meters in the case of MapSchema parameters (if this type of parameter can is allowed).
@@ -0,0 +1,703 @@ | |||
/* | |||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | |||
* Copyright 2018 SmartBear Software |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally it was so easy to fix that I did it anyway ;) |
…those fields are missing at deserialization time, None is assumed.
@cgensoul 👍 so is it ready for review and merge into master? |
Are there some commands to make sure the OCaml Petstore sample compiles? An auto-generated README would be nice so that OCaml beginners will find it easy to use the OCaml library. |
…ly one accepted value so that those fields can be deserialized even if the value is absent of the json payload.
The command to compile the lib once all the tools (opam first then dune through opam is the easiest path) and dependencies (through opam as well) are installed is :
at the root of the generated code directory. I'll add a README pointing to installation instructions of the tools and dependencies next week. There is an example program using the library committed in the repository in the samples/client/petstore/ocaml-client/bin directory. It's called test.ml and has an accompanying dune build file. I'll clean it up and reference it in the README. Regarding merging to master, it can be merged without any risk since it's all new code and no existing classes have been modified by this PR but I think proper handling of response codes should be added before it's really useful to anyone. So maybe it's best to wait a bit to save some reviewing work ? |
I added handling of response codes ;) |
Tried running
Do I need to run other commands in order to install those libraries locally? |
Yes indeed. You need to install the dependencies.
opam install ppx_deriving_yojson cohttp ppx_deriving.std cohttp-lwt-unix
That should be enough. There is an opam search command in case you need to
find out the name of a package.
Le dim. 28 juil. 2019 à 05:25, William Cheng <[email protected]> a
écrit :
… Tried running dune build locally and I got:
➜ ocaml-client git:(cgensoul-ocaml-client) dune build
File "dune", line 6, characters 18-33:
6 | (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime)
^^^^^^^^^^^^^^^
Error: Library "cohttp-lwt-unix" not found.
Hint: try: dune external-lib-deps --missing @@default
File "dune", line 7, characters 20-39:
7 | (preprocess (pps ppx_deriving_yojson ppx_deriving.std))
^^^^^^^^^^^^^^^^^^^
Error: Library "ppx_deriving_yojson" not found.
Hint: try: dune external-lib-deps --missing @@default
Do I need to run other commands in order to install those libraries
locally?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3446?email_source=notifications&email_token=AMWCGNXAYM46KJOQXE5SYULQBUGT5A5CNFSM4IGSCA62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD26WSOA#issuecomment-515729720>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMWCGNSA322G5UNZ22XPNWDQBUGT5ANCNFSM4IGSCA6Q>
.
|
Thanks for the tips. It works for me after I run I would recommend including the opam install command in the readme as well. |
Ya that was my intention.
Le dim. 28 juil. 2019 à 15:40, William Cheng <[email protected]> a
écrit :
… Thanks for the tips. It works for me after I run opam install
ppx_deriving_yojson cohttp ppx_deriving cohttp-lwt-unix (wihtout .std)
I would recommend including the opam install command in the readme as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3446?email_source=notifications&email_token=AMWCGNQ5SUCPI2SSF5ZCBEDQBWOV5A5CNFSM4IGSCA62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2665BQ#issuecomment-515763846>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMWCGNTM7W5IT6NDGI2J4CDQBWOV5ANCNFSM4IGSCA6Q>
.
|
@cgensoul thanks for the new generator. Do you have a Twitter account so that I can tag you in my tweet to promote the new generator? |
Yes my tweeter account is @cgensoul.
Le dim. 28 juil. 2019 à 15:51, William Cheng <[email protected]> a
écrit :
… @cgensoul <https://github.com/cgensoul> thanks for the new generator. Do
you have a Twitter account so that I can tag you in my tweet to promote the
new generator?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3446?email_source=notifications&email_token=AMWCGNWNPN2TK43OQPHNPCLQBWP6DA5CNFSM4IGSCA62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD267DMA#issuecomment-515764656>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMWCGNQAIUN7GDZTMGJ7V6LQBWP6DANCNFSM4IGSCA6Q>
.
|
I've filed #3483 for various enhancements. |
NoteThis generator is still in beta and may subject to breaking changes (without fallbacks) in the future. |
@cgensoul thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553 |
#1159 Add OCaml client code generation support
This PR answers #1159 and adds OCaml Client code generation to openapi-generator. The generated OCaml project relies on the dune tool for the build process and uses :
It supports headers params, path params, query params, form params and body params. It currently has no support for authentication, nor file upload.
It generates one model file per OAS definition except for OAS enum definitions for which no model file is generated. Enums are treated globally and are all generated in a enums.ml file that contains one type per distinct enumeration present in the input file, even for enumerations that are not proper definitions but just local restrictions on a string parameter of an operation.
Note that generating one model file per OAS definition will work as long as there are no mutually recursive OAS definitions in the input file. Otherwise the generated OCaml code will not compile since it will generate mutually recursive compilation units which is not supported by the language.
For APIs files, both an implementation (.ml) and an interface (.mli) files are generated.