From 20c86dcaf65b7870f1f8caa658f9e926f412f96f Mon Sep 17 00:00:00 2001 From: Julien Debon Date: Mon, 25 Aug 2025 14:47:55 +0200 Subject: [PATCH 1/4] [OCaml] Generate .ocamlformat file Fixes https://github.com/OpenAPITools/openapi-generator/issues/21806 --- .github/workflows/samples-ocaml.yaml | 3 +++ .../openapitools/codegen/languages/OCamlClientCodegen.java | 1 + .../src/main/resources/ocaml/dune-project.mustache | 4 ++-- .../openapi-generator/src/main/resources/ocaml/lib.mustache | 1 + .../src/main/resources/ocaml/ocamlformat.mustache | 2 ++ samples/client/petstore/ocaml-fake-petstore/.ocamlformat | 2 ++ .../petstore/ocaml-fake-petstore/.openapi-generator/FILES | 1 + samples/client/petstore/ocaml-fake-petstore/dune-project | 4 ++-- .../client/petstore/ocaml-fake-petstore/petstore_client.opam | 1 + samples/client/petstore/ocaml-oneOf/.ocamlformat | 2 ++ samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES | 1 + samples/client/petstore/ocaml-oneOf/dune-project | 4 ++-- samples/client/petstore/ocaml-oneOf/petstore_client.opam | 1 + samples/client/petstore/ocaml/.ocamlformat | 2 ++ samples/client/petstore/ocaml/.openapi-generator/FILES | 1 + samples/client/petstore/ocaml/dune-project | 4 ++-- samples/client/petstore/ocaml/petstore_client.opam | 1 + 17 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/ocaml/ocamlformat.mustache create mode 100644 samples/client/petstore/ocaml-fake-petstore/.ocamlformat create mode 100644 samples/client/petstore/ocaml-oneOf/.ocamlformat create mode 100644 samples/client/petstore/ocaml/.ocamlformat diff --git a/.github/workflows/samples-ocaml.yaml b/.github/workflows/samples-ocaml.yaml index 9206c578d893..718acf39d95e 100644 --- a/.github/workflows/samples-ocaml.yaml +++ b/.github/workflows/samples-ocaml.yaml @@ -35,3 +35,6 @@ jobs: - name: Build run: opam exec -- dune build working-directory: ${{ matrix.sample }} + - name: Check formatting + run: opam exec -- dune fmt + working-directory: ${{ matrix.sample }} diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java index b3942140dd53..1f7d6548e508 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java @@ -134,6 +134,7 @@ public OCamlClientCodegen() { supportingFiles.add(new SupportingFile("dune.mustache", "", "dune")); supportingFiles.add(new SupportingFile("dune-project.mustache", "", "dune-project")); supportingFiles.add(new SupportingFile("readme.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("ocamlformat.mustache", "", ".ocamlformat")); defaultIncludes = new HashSet<>( Arrays.asList( diff --git a/modules/openapi-generator/src/main/resources/ocaml/dune-project.mustache b/modules/openapi-generator/src/main/resources/ocaml/dune-project.mustache index 8e48d839f686..a90e8a118ef8 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/dune-project.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/dune-project.mustache @@ -1,2 +1,2 @@ -(lang dune 1.10) -(name {{{packageName}}}) \ No newline at end of file +(lang dune 2.0) +(name {{{packageName}}}) diff --git a/modules/openapi-generator/src/main/resources/ocaml/lib.mustache b/modules/openapi-generator/src/main/resources/ocaml/lib.mustache index 017bf839c431..8a52b64c4cdf 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/lib.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/lib.mustache @@ -14,6 +14,7 @@ dev-repo: "" depends: [ "ocaml" "ocamlfind" + "ocamlformat" {= "0.27.0"} "dune" "ppx_deriving_yojson" "conf-libev" diff --git a/modules/openapi-generator/src/main/resources/ocaml/ocamlformat.mustache b/modules/openapi-generator/src/main/resources/ocaml/ocamlformat.mustache new file mode 100644 index 000000000000..402c7252e5f9 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/ocaml/ocamlformat.mustache @@ -0,0 +1,2 @@ +version=0.27.0 +ocaml-version=4.14.0 diff --git a/samples/client/petstore/ocaml-fake-petstore/.ocamlformat b/samples/client/petstore/ocaml-fake-petstore/.ocamlformat new file mode 100644 index 000000000000..402c7252e5f9 --- /dev/null +++ b/samples/client/petstore/ocaml-fake-petstore/.ocamlformat @@ -0,0 +1,2 @@ +version=0.27.0 +ocaml-version=4.14.0 diff --git a/samples/client/petstore/ocaml-fake-petstore/.openapi-generator/FILES b/samples/client/petstore/ocaml-fake-petstore/.openapi-generator/FILES index d4a1e97f7ede..2e12d2aabc0d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/.openapi-generator/FILES +++ b/samples/client/petstore/ocaml-fake-petstore/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.ocamlformat README.md dune dune-project diff --git a/samples/client/petstore/ocaml-fake-petstore/dune-project b/samples/client/petstore/ocaml-fake-petstore/dune-project index 79d86e3c901a..60a6d76962b7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/dune-project +++ b/samples/client/petstore/ocaml-fake-petstore/dune-project @@ -1,2 +1,2 @@ -(lang dune 1.10) -(name petstore_client) \ No newline at end of file +(lang dune 2.0) +(name petstore_client) diff --git a/samples/client/petstore/ocaml-fake-petstore/petstore_client.opam b/samples/client/petstore/ocaml-fake-petstore/petstore_client.opam index 7ca31fc5af4f..d7c41adb6a11 100644 --- a/samples/client/petstore/ocaml-fake-petstore/petstore_client.opam +++ b/samples/client/petstore/ocaml-fake-petstore/petstore_client.opam @@ -14,6 +14,7 @@ dev-repo: "" depends: [ "ocaml" "ocamlfind" + "ocamlformat" {= "0.27.0"} "dune" "ppx_deriving_yojson" "conf-libev" diff --git a/samples/client/petstore/ocaml-oneOf/.ocamlformat b/samples/client/petstore/ocaml-oneOf/.ocamlformat new file mode 100644 index 000000000000..402c7252e5f9 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf/.ocamlformat @@ -0,0 +1,2 @@ +version=0.27.0 +ocaml-version=4.14.0 diff --git a/samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES b/samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES index 0623f326da70..d128ebea197a 100644 --- a/samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES +++ b/samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.ocamlformat README.md dune dune-project diff --git a/samples/client/petstore/ocaml-oneOf/dune-project b/samples/client/petstore/ocaml-oneOf/dune-project index 79d86e3c901a..60a6d76962b7 100644 --- a/samples/client/petstore/ocaml-oneOf/dune-project +++ b/samples/client/petstore/ocaml-oneOf/dune-project @@ -1,2 +1,2 @@ -(lang dune 1.10) -(name petstore_client) \ No newline at end of file +(lang dune 2.0) +(name petstore_client) diff --git a/samples/client/petstore/ocaml-oneOf/petstore_client.opam b/samples/client/petstore/ocaml-oneOf/petstore_client.opam index 7ca31fc5af4f..d7c41adb6a11 100644 --- a/samples/client/petstore/ocaml-oneOf/petstore_client.opam +++ b/samples/client/petstore/ocaml-oneOf/petstore_client.opam @@ -14,6 +14,7 @@ dev-repo: "" depends: [ "ocaml" "ocamlfind" + "ocamlformat" {= "0.27.0"} "dune" "ppx_deriving_yojson" "conf-libev" diff --git a/samples/client/petstore/ocaml/.ocamlformat b/samples/client/petstore/ocaml/.ocamlformat new file mode 100644 index 000000000000..402c7252e5f9 --- /dev/null +++ b/samples/client/petstore/ocaml/.ocamlformat @@ -0,0 +1,2 @@ +version=0.27.0 +ocaml-version=4.14.0 diff --git a/samples/client/petstore/ocaml/.openapi-generator/FILES b/samples/client/petstore/ocaml/.openapi-generator/FILES index 8d7df53d9a09..57c9951ea626 100644 --- a/samples/client/petstore/ocaml/.openapi-generator/FILES +++ b/samples/client/petstore/ocaml/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.ocamlformat README.md dune dune-project diff --git a/samples/client/petstore/ocaml/dune-project b/samples/client/petstore/ocaml/dune-project index 79d86e3c901a..60a6d76962b7 100644 --- a/samples/client/petstore/ocaml/dune-project +++ b/samples/client/petstore/ocaml/dune-project @@ -1,2 +1,2 @@ -(lang dune 1.10) -(name petstore_client) \ No newline at end of file +(lang dune 2.0) +(name petstore_client) diff --git a/samples/client/petstore/ocaml/petstore_client.opam b/samples/client/petstore/ocaml/petstore_client.opam index 7ca31fc5af4f..d7c41adb6a11 100644 --- a/samples/client/petstore/ocaml/petstore_client.opam +++ b/samples/client/petstore/ocaml/petstore_client.opam @@ -14,6 +14,7 @@ dev-repo: "" depends: [ "ocaml" "ocamlfind" + "ocamlformat" {= "0.27.0"} "dune" "ppx_deriving_yojson" "conf-libev" From f0d82dc30f6858b26d4d380dd739043fafe00a81 Mon Sep 17 00:00:00 2001 From: Julien Debon Date: Mon, 25 Aug 2025 15:05:36 +0200 Subject: [PATCH 2/4] [OCaml] Run `dune fmt` on all OCaml folders --- .../client/petstore/ocaml-fake-petstore/dune | 16 +- .../src/apis/another_fake_api.ml | 27 +- .../src/apis/default_api.ml | 13 +- .../ocaml-fake-petstore/src/apis/fake_api.ml | 1285 +++++------------ .../ocaml-fake-petstore/src/apis/fake_api.mli | 96 +- .../src/apis/fake_classname_tags123_api.ml | 29 +- .../ocaml-fake-petstore/src/apis/pet_api.ml | 396 ++--- .../ocaml-fake-petstore/src/apis/pet_api.mli | 20 +- .../ocaml-fake-petstore/src/apis/store_api.ml | 93 +- .../ocaml-fake-petstore/src/apis/user_api.ml | 231 +-- .../src/models/additional_properties_class.ml | 33 +- .../src/models/all_of_with_single_ref.ml | 32 +- .../ocaml-fake-petstore/src/models/animal.ml | 29 +- .../src/models/api_response.ml | 39 +- .../models/array_of_array_of_number_only.ml | 19 +- .../src/models/array_of_number_only.ml | 17 +- .../src/models/array_test.ml | 38 +- .../src/models/capitalization.ml | 72 +- .../ocaml-fake-petstore/src/models/cat.ml | 38 +- .../src/models/category.ml | 29 +- .../src/models/child_with_nullable.ml | 39 +- .../src/models/class_model.ml | 21 +- .../ocaml-fake-petstore/src/models/client.ml | 19 +- .../src/models/deprecated_object.ml | 19 +- .../ocaml-fake-petstore/src/models/dog.ml | 38 +- .../src/models/enum_arrays.ml | 25 +- .../src/models/enum_test.ml | 88 +- .../fake_big_decimal_map_200_response.ml | 31 +- .../ocaml-fake-petstore/src/models/file.ml | 25 +- .../src/models/file_schema_test_class.ml | 27 +- .../ocaml-fake-petstore/src/models/foo.ml | 19 +- .../src/models/format_test.ml | 166 +-- .../src/models/has_only_read_only.ml | 29 +- .../src/models/health_check_result.ml | 24 +- .../ocaml-fake-petstore/src/models/list.ml | 19 +- .../src/models/map_test.ml | 54 +- ...perties_and_additional_properties_class.ml | 39 +- .../src/models/model_200_response.ml | 31 +- .../models/model__foo_get_default_response.ml | 19 +- .../src/models/model__special_model_name_.ml | 22 +- .../ocaml-fake-petstore/src/models/name.ml | 48 +- .../src/models/nullable_class.ml | 126 +- .../src/models/number_only.ml | 19 +- .../models/object_with_deprecated_fields.ml | 44 +- .../ocaml-fake-petstore/src/models/order.ml | 71 +- .../src/models/outer_composite.ml | 39 +- .../models/outer_object_with_enum_property.ml | 19 +- .../src/models/parent_with_nullable.ml | 32 +- .../ocaml-fake-petstore/src/models/pet.ml | 59 +- .../src/models/read_only_first.ml | 29 +- .../ocaml-fake-petstore/src/models/return.ml | 21 +- .../ocaml-fake-petstore/src/models/tag.ml | 29 +- ..._freeform_additional_properties_request.ml | 19 +- .../ocaml-fake-petstore/src/models/user.ml | 89 +- .../ocaml-fake-petstore/src/support/enums.ml | 287 ++-- .../src/support/jsonSupport.ml | 65 +- .../src/support/request.ml | 53 +- samples/client/petstore/ocaml-oneOf/dune | 16 +- .../ocaml-oneOf/src/apis/default_api.ml | 11 +- .../petstore/ocaml-oneOf/src/models/child.ml | 19 +- .../ocaml-oneOf/src/models/example.ml | 58 +- .../ocaml-oneOf/src/support/jsonSupport.ml | 65 +- .../ocaml-oneOf/src/support/request.ml | 53 +- samples/client/petstore/ocaml/dune | 16 +- .../client/petstore/ocaml/src/apis/pet_api.ml | 321 +--- .../petstore/ocaml/src/apis/pet_api.mli | 12 +- .../petstore/ocaml/src/apis/store_api.ml | 91 +- .../petstore/ocaml/src/apis/user_api.ml | 243 +--- .../petstore/ocaml/src/models/api_response.ml | 39 +- .../petstore/ocaml/src/models/category.ml | 31 +- .../ocaml/src/models/inline_object.ml | 15 +- .../ocaml/src/models/inline_object_1.ml | 15 +- .../client/petstore/ocaml/src/models/order.ml | 73 +- .../client/petstore/ocaml/src/models/pet.ml | 61 +- .../client/petstore/ocaml/src/models/tag.ml | 31 +- .../client/petstore/ocaml/src/models/user.ml | 91 +- .../petstore/ocaml/src/support/enums.ml | 46 +- .../petstore/ocaml/src/support/jsonSupport.ml | 65 +- .../petstore/ocaml/src/support/request.ml | 53 +- 79 files changed, 1765 insertions(+), 4015 deletions(-) diff --git a/samples/client/petstore/ocaml-fake-petstore/dune b/samples/client/petstore/ocaml-fake-petstore/dune index ed1c4d90e3df..d10b1d1a5075 100644 --- a/samples/client/petstore/ocaml-fake-petstore/dune +++ b/samples/client/petstore/ocaml-fake-petstore/dune @@ -1,9 +1,11 @@ (include_subdirs unqualified) + (library - (name petstore_client) - (public_name petstore_client) - (flags (:standard -w -27)) - (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) - (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) - (wrapped true) -) \ No newline at end of file + (name petstore_client) + (public_name petstore_client) + (flags + (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess + (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true)) diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml index 8e40a663d9be..f421d17f609a 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml @@ -6,24 +6,9 @@ *) let call_123_test_special_tags ~client_t = - let open Lwt.Infix in - let uri = Request.build_uri "/another-fake/dummy" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Client.to_yojson - - - - client_t - in - Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/another-fake/dummy" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Client.to_yojson client_t in + Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml index 0184891735dd..65b79273bfba 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml @@ -6,9 +6,10 @@ *) let foo_get () = - let open Lwt.Infix in - let uri = Request.build_uri "/foo" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Model__foo_get_default_response.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/foo" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Model__foo_get_default_response.of_yojson) + resp body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml index 7dd18fe3ceb2..fac126b8a8b6 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml @@ -6,997 +6,368 @@ *) let fake_big_decimal_map () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/BigDecimalMap" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Fake_big_decimal_map_200_response.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/BigDecimalMap" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Fake_big_decimal_map_200_response.of_yojson) + resp body let fake_health_get () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/health" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Health_check_result.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/health" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Health_check_result.of_yojson) + resp body let fake_http_signature_test ~pet_t ?query_1 ?header_1 () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/http-signature-test" in - let headers = Request.default_headers in - let headers = Request.maybe_add_header headers "header_1" - - - - - - - - - (fun x -> x) - - - - - header_1 in - let uri = Request.maybe_add_query_param uri "query_1" - - - - - - - - - (fun x -> x) - - - - - query_1 in - let body = Request. - - write_as_json_body - - - - - - - Pet.to_yojson - - - - pet_t - in - Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/http-signature-test" in + let headers = Request.default_headers in + let headers = + Request.maybe_add_header headers "header_1" (fun x -> x) header_1 + in + let uri = Request.maybe_add_query_param uri "query_1" (fun x -> x) query_1 in + let body = Request.write_as_json_body Pet.to_yojson pet_t in + Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let fake_outer_boolean_serialize ~body () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/boolean" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - JsonSupport.of_bool - - - - body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.to_bool) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/boolean" in + let headers = Request.default_headers in + let body = Request.write_as_json_body JsonSupport.of_bool body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as JsonSupport.to_bool resp body let fake_outer_composite_serialize ~outer_composite_t () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/composite" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Outer_composite.to_yojson - - - - outer_composite_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Outer_composite.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/composite" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body Outer_composite.to_yojson outer_composite_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Outer_composite.of_yojson) + resp body let fake_outer_number_serialize ~body () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/number" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - JsonSupport.of_float - - - - - - body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.to_float) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/number" in + let headers = Request.default_headers in + let body = Request.write_as_json_body JsonSupport.of_float body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as JsonSupport.to_float resp body let fake_outer_string_serialize ~body () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/string" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body JsonSupport.of_string - - - - - - - - - - body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.to_string) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/string" in + let headers = Request.default_headers in + let body = Request.write_as_json_body JsonSupport.of_string body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as JsonSupport.to_string resp body let fake_property_enum_integer_serialize ~outer_object_with_enum_property_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/property/enum-int" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Outer_object_with_enum_property.to_yojson - - - - outer_object_with_enum_property_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Outer_object_with_enum_property.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/property/enum-int" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body Outer_object_with_enum_property.to_yojson + outer_object_with_enum_property_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Outer_object_with_enum_property.of_yojson) + resp body let test_additional_properties_reference ~request_body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/additionalProperties-reference" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body (JsonSupport.of_map_of - - - - - - - - (fun x -> x) - -) - request_body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/additionalProperties-reference" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body (JsonSupport.of_map_of (fun x -> x)) request_body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_body_with_binary ~body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/body-with-binary" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - JsonSupport.of_string - - - body - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/body-with-binary" in + let headers = Request.default_headers in + let body = Request.write_as_json_body JsonSupport.of_string body in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_body_with_file_schema ~file_schema_test_class_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/body-with-file-schema" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - File_schema_test_class.to_yojson - - - - file_schema_test_class_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/body-with-file-schema" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body File_schema_test_class.to_yojson + file_schema_test_class_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_body_with_query_params ~query ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/body-with-query-params" in - let headers = Request.default_headers in - let uri = Request.add_query_param uri "query" - - - - - - - - - (fun x -> x) - - - - - query in - let body = Request. - - write_as_json_body - - - - - - - User.to_yojson - - - - user_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/body-with-query-params" in + let headers = Request.default_headers in + let uri = Request.add_query_param uri "query" (fun x -> x) query in + let body = Request.write_as_json_body User.to_yojson user_t in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_client_model ~client_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Client.to_yojson - - - - client_t - in - Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Client.to_yojson client_t in + Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body -let test_endpoint_parameters ~number ~double ~pattern_without_delimiter ~byte ?integer ?int32 ?int64 ?float ?string ?binary ?date ?date_time ?password ?callback () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let body = Request.init_form_encoded_body () in - let body = Request.maybe_add_form_encoded_body_param body "integer" - Int32.to_string - - - - - - - - - - - - - integer in - let body = Request.maybe_add_form_encoded_body_param body "int32" - Int32.to_string - - - - - - - - - - - - - int32 in - let body = Request.maybe_add_form_encoded_body_param body "int64" Int64.to_string - - - - - - - - - - - - - - int64 in - let body = Request.add_form_encoded_body_param body "number" - - - string_of_float - - - - - - - - - - - number in - let body = Request.maybe_add_form_encoded_body_param body "float" - - string_of_float - - - - - - - - - - - - float in - let body = Request.add_form_encoded_body_param body "double" - - - - string_of_float - - - - - - - - - - double in - let body = Request.maybe_add_form_encoded_body_param body "string" - - - - - - - - - (fun x -> x) - - - - - string in - let body = Request.add_form_encoded_body_param body "pattern_without_delimiter" - - - - - - - - - (fun x -> x) - - - - - pattern_without_delimiter in - let body = Request.add_form_encoded_body_param body "byte" - - - - - - - - - - (fun x -> x) - - - - byte in - let body = Request.maybe_add_form_encoded_body_param body "binary" - - - - - - (fun x -> x) - - - - - - - - binary in - let body = Request.maybe_add_form_encoded_body_param body "date" - - - - - - - (fun x -> x) - - - - - - - date in - let body = Request.maybe_add_form_encoded_body_param body "date_time" - - - - - - - - (fun x -> x) - - - - - - date_time in - let body = Request.maybe_add_form_encoded_body_param body "password" - - - - - - - - - (fun x -> x) - - - - - password in - let body = Request.maybe_add_form_encoded_body_param body "callback" - - - - - - - - - (fun x -> x) - - - - - callback in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_endpoint_parameters ~number ~double ~pattern_without_delimiter ~byte + ?integer ?int32 ?int64 ?float ?string ?binary ?date ?date_time ?password + ?callback () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let body = Request.init_form_encoded_body () in + let body = + Request.maybe_add_form_encoded_body_param body "integer" Int32.to_string + integer + in + let body = + Request.maybe_add_form_encoded_body_param body "int32" Int32.to_string int32 + in + let body = + Request.maybe_add_form_encoded_body_param body "int64" Int64.to_string int64 + in + let body = + Request.add_form_encoded_body_param body "number" string_of_float number + in + let body = + Request.maybe_add_form_encoded_body_param body "float" string_of_float float + in + let body = + Request.add_form_encoded_body_param body "double" string_of_float double + in + let body = + Request.maybe_add_form_encoded_body_param body "string" (fun x -> x) string + in + let body = + Request.add_form_encoded_body_param body "pattern_without_delimiter" + (fun x -> x) + pattern_without_delimiter + in + let body = + Request.add_form_encoded_body_param body "byte" (fun x -> x) byte + in + let body = + Request.maybe_add_form_encoded_body_param body "binary" (fun x -> x) binary + in + let body = + Request.maybe_add_form_encoded_body_param body "date" (fun x -> x) date + in + let body = + Request.maybe_add_form_encoded_body_param body "date_time" + (fun x -> x) + date_time + in + let body = + Request.maybe_add_form_encoded_body_param body "password" + (fun x -> x) + password + in + let body = + Request.maybe_add_form_encoded_body_param body "callback" + (fun x -> x) + callback + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_enum_parameters ?(enum_header_string_array = []) ?(enum_header_string = `Minusefg) ?(enum_query_string_array = []) ?(enum_query_string = `Minusefg) ?enum_query_integer ?enum_query_double ?(enum_query_model_array = []) ?(enum_form_string_array = [`Dollar]) ?(enum_form_string = `Minusefg) () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let headers = Request.add_header_multi headers "enum_header_string_array" (Stdlib.List.map Enums.show_enum_form_string_array - -) - enum_header_string_array in - let headers = Request.add_header headers "enum_header_string" Enums.show_enumclass - - enum_header_string in - let uri = Request.add_query_param_list uri "enum_query_string_array" (Stdlib.List.map Enums.show_enum_form_string_array - -) - enum_query_string_array in - let uri = Request.add_query_param uri "enum_query_string" Enums.show_enumclass - - enum_query_string in - let uri = Request.maybe_add_query_param uri "enum_query_integer" Enums.show_enum_query_integer - - enum_query_integer in - let uri = Request.maybe_add_query_param uri "enum_query_double" Enums.show_enum_number - - enum_query_double in - let uri = Request.add_query_param_list uri "enum_query_model_array" (Stdlib.List.map - - - - - - - - - - - - - (failwith "Unsupported: enum reference") -) - - - - - - - - - - - - - enum_query_model_array in - let body = Request.init_form_encoded_body () in - let body = Request.add_form_encoded_body_param_list body "enum_form_string_array" (Stdlib.List.map Enums.show_enum_form_string_array - -) - enum_form_string_array in - let body = Request.add_form_encoded_body_param body "enum_form_string" Enums.show_enumclass - - enum_form_string in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_enum_parameters ?(enum_header_string_array = []) + ?(enum_header_string = `Minusefg) ?(enum_query_string_array = []) + ?(enum_query_string = `Minusefg) ?enum_query_integer ?enum_query_double + ?(enum_query_model_array = []) ?(enum_form_string_array = [ `Dollar ]) + ?(enum_form_string = `Minusefg) () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let headers = + Request.add_header_multi headers "enum_header_string_array" + (Stdlib.List.map Enums.show_enum_form_string_array) + enum_header_string_array + in + let headers = + Request.add_header headers "enum_header_string" Enums.show_enumclass + enum_header_string + in + let uri = + Request.add_query_param_list uri "enum_query_string_array" + (Stdlib.List.map Enums.show_enum_form_string_array) + enum_query_string_array + in + let uri = + Request.add_query_param uri "enum_query_string" Enums.show_enumclass + enum_query_string + in + let uri = + Request.maybe_add_query_param uri "enum_query_integer" + Enums.show_enum_query_integer enum_query_integer + in + let uri = + Request.maybe_add_query_param uri "enum_query_double" Enums.show_enum_number + enum_query_double + in + let uri = + Request.add_query_param_list uri "enum_query_model_array" + (Stdlib.List.map (failwith "Unsupported: enum reference")) + enum_query_model_array + in + let body = Request.init_form_encoded_body () in + let body = + Request.add_form_encoded_body_param_list body "enum_form_string_array" + (Stdlib.List.map Enums.show_enum_form_string_array) + enum_form_string_array + in + let body = + Request.add_form_encoded_body_param body "enum_form_string" + Enums.show_enumclass enum_form_string + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_group_parameters ~required_string_group ~required_boolean_group ~required_int64_group ?string_group ?boolean_group ?int64_group () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let headers = Request.add_header headers "required_boolean_group" - - - - - string_of_bool - - - - - - - - - required_boolean_group in - let headers = Request.maybe_add_header headers "boolean_group" - - - - - string_of_bool - - - - - - - - - boolean_group in - let uri = Request.add_query_param uri "required_string_group" - Int32.to_string - - - - - - - - - - - - - required_string_group in - let uri = Request.add_query_param uri "required_int64_group" Int64.to_string - - - - - - - - - - - - - - required_int64_group in - let uri = Request.maybe_add_query_param uri "string_group" - Int32.to_string - - - - - - - - - - - - - string_group in - let uri = Request.maybe_add_query_param uri "int64_group" Int64.to_string - - - - - - - - - - - - - - int64_group in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_group_parameters ~required_string_group ~required_boolean_group + ~required_int64_group ?string_group ?boolean_group ?int64_group () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let headers = + Request.add_header headers "required_boolean_group" string_of_bool + required_boolean_group + in + let headers = + Request.maybe_add_header headers "boolean_group" string_of_bool + boolean_group + in + let uri = + Request.add_query_param uri "required_string_group" Int32.to_string + required_string_group + in + let uri = + Request.add_query_param uri "required_int64_group" Int64.to_string + required_int64_group + in + let uri = + Request.maybe_add_query_param uri "string_group" Int32.to_string + string_group + in + let uri = + Request.maybe_add_query_param uri "int64_group" Int64.to_string int64_group + in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let test_inline_additional_properties ~request_body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/inline-additionalProperties" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body (JsonSupport.of_map_of JsonSupport.of_string - - - - - - - - - -) - request_body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/inline-additionalProperties" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body + (JsonSupport.of_map_of JsonSupport.of_string) + request_body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_inline_freeform_additional_properties ~test_inline_freeform_additional_properties_request_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/inline-freeform-additionalProperties" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Test_inline_freeform_additional_properties_request.to_yojson - - - - test_inline_freeform_additional_properties_request_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_inline_freeform_additional_properties + ~test_inline_freeform_additional_properties_request_t = + let open Lwt.Infix in + let uri = Request.build_uri "/fake/inline-freeform-additionalProperties" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body + Test_inline_freeform_additional_properties_request.to_yojson + test_inline_freeform_additional_properties_request_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_json_form_data ~param ~param2 = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/jsonFormData" in - let headers = Request.default_headers in - let body = Request.init_form_encoded_body () in - let body = Request.add_form_encoded_body_param body "param" - - - - - - - - - (fun x -> x) - - - - - param in - let body = Request.add_form_encoded_body_param body "param2" - - - - - - - - - (fun x -> x) - - - - - param2 in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/jsonFormData" in + let headers = Request.default_headers in + let body = Request.init_form_encoded_body () in + let body = + Request.add_form_encoded_body_param body "param" (fun x -> x) param + in + let body = + Request.add_form_encoded_body_param body "param2" (fun x -> x) param2 + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_nullable ~child_with_nullable_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/nullable" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Child_with_nullable.to_yojson - - - - child_with_nullable_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/nullable" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body Child_with_nullable.to_yojson + child_with_nullable_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_query_parameter_collection_format ~pipe ~ioutil ~http ~url ~context ~allow_empty ?(language = []) () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/test-query-parameters" in - let headers = Request.default_headers in - let uri = Request.add_query_param_list uri "pipe" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - pipe in - let uri = Request.add_query_param_list uri "ioutil" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - ioutil in - let uri = Request.add_query_param_list uri "http" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - http in - let uri = Request.add_query_param_list uri "url" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - url in - let uri = Request.add_query_param_list uri "context" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - context in - let uri = Request.add_query_param_exploded_form_object uri "language" - - - - - - - - - - (fun x -> x) - - - - - - - - - - - - - - - - - - language in - let uri = Request.add_query_param uri "allowEmpty" - - - - - - - - - (fun x -> x) - - - - - allow_empty in - Cohttp_lwt_unix.Client.call `PUT uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_query_parameter_collection_format ~pipe ~ioutil ~http ~url ~context + ~allow_empty ?(language = []) () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake/test-query-parameters" in + let headers = Request.default_headers in + let uri = + Request.add_query_param_list uri "pipe" (Stdlib.List.map (fun x -> x)) pipe + in + let uri = + Request.add_query_param_list uri "ioutil" + (Stdlib.List.map (fun x -> x)) + ioutil + in + let uri = + Request.add_query_param_list uri "http" (Stdlib.List.map (fun x -> x)) http + in + let uri = + Request.add_query_param_list uri "url" (Stdlib.List.map (fun x -> x)) url + in + let uri = + Request.add_query_param_list uri "context" + (Stdlib.List.map (fun x -> x)) + context + in + let uri = + Request.add_query_param_exploded_form_object uri "language" + (fun x -> x) + language + in + let uri = Request.add_query_param uri "allowEmpty" (fun x -> x) allow_empty in + Cohttp_lwt_unix.Client.call `PUT uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let test_string_map_reference ~request_body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/stringMap-reference" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body (JsonSupport.of_map_of JsonSupport.of_string - - - - - - - - - -) - request_body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp - + let open Lwt.Infix in + let uri = Request.build_uri "/fake/stringMap-reference" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body + (JsonSupport.of_map_of JsonSupport.of_string) + request_body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli index 259a66dd29e0..b8d835f83f66 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli @@ -7,23 +7,95 @@ val fake_big_decimal_map : unit -> Fake_big_decimal_map_200_response.t Lwt.t val fake_health_get : unit -> Health_check_result.t Lwt.t -val fake_http_signature_test : pet_t:Pet.t -> ?query_1:string -> ?header_1:string -> unit -> unit Lwt.t + +val fake_http_signature_test : + pet_t:Pet.t -> ?query_1:string -> ?header_1:string -> unit -> unit Lwt.t + val fake_outer_boolean_serialize : body:bool -> unit -> bool Lwt.t -val fake_outer_composite_serialize : outer_composite_t:Outer_composite.t -> unit -> Outer_composite.t Lwt.t + +val fake_outer_composite_serialize : + outer_composite_t:Outer_composite.t -> unit -> Outer_composite.t Lwt.t + val fake_outer_number_serialize : body:float -> unit -> float Lwt.t val fake_outer_string_serialize : body:string -> unit -> string Lwt.t -val fake_property_enum_integer_serialize : outer_object_with_enum_property_t:Outer_object_with_enum_property.t -> Outer_object_with_enum_property.t Lwt.t -val test_additional_properties_reference : request_body:(string * Yojson.Safe.t) list -> unit Lwt.t + +val fake_property_enum_integer_serialize : + outer_object_with_enum_property_t:Outer_object_with_enum_property.t -> + Outer_object_with_enum_property.t Lwt.t + +val test_additional_properties_reference : + request_body:(string * Yojson.Safe.t) list -> unit Lwt.t + val test_body_with_binary : body:string -> unit Lwt.t -val test_body_with_file_schema : file_schema_test_class_t:File_schema_test_class.t -> unit Lwt.t + +val test_body_with_file_schema : + file_schema_test_class_t:File_schema_test_class.t -> unit Lwt.t + val test_body_with_query_params : query:string -> user_t:User.t -> unit Lwt.t val test_client_model : client_t:Client.t -> Client.t Lwt.t -val test_endpoint_parameters : number:float -> double:float -> pattern_without_delimiter:string -> byte:string -> ?integer:int32 -> ?int32:int32 -> ?int64:int64 -> ?float:float -> ?string:string -> ?binary:string -> ?date:string -> ?date_time:string -> ?password:string -> ?callback:string -> unit -> unit Lwt.t -val test_enum_parameters : ?enum_header_string_array:Enums.enum_form_string_array list -> ?enum_header_string:Enums.enumclass -> ?enum_query_string_array:Enums.enum_form_string_array list -> ?enum_query_string:Enums.enumclass -> ?enum_query_integer:Enums.enum_query_integer -> ?enum_query_double:Enums.enum_number -> ?enum_query_model_array:Enums.enumclass list -> ?enum_form_string_array:Enums.enum_form_string_array list -> ?enum_form_string:Enums.enumclass -> unit -> unit Lwt.t -val test_group_parameters : required_string_group:int32 -> required_boolean_group:bool -> required_int64_group:int64 -> ?string_group:int32 -> ?boolean_group:bool -> ?int64_group:int64 -> unit -> unit Lwt.t -val test_inline_additional_properties : request_body:(string * string) list -> unit Lwt.t -val test_inline_freeform_additional_properties : test_inline_freeform_additional_properties_request_t:Test_inline_freeform_additional_properties_request.t -> unit Lwt.t + +val test_endpoint_parameters : + number:float -> + double:float -> + pattern_without_delimiter:string -> + byte:string -> + ?integer:int32 -> + ?int32:int32 -> + ?int64:int64 -> + ?float:float -> + ?string:string -> + ?binary:string -> + ?date:string -> + ?date_time:string -> + ?password:string -> + ?callback:string -> + unit -> + unit Lwt.t + +val test_enum_parameters : + ?enum_header_string_array:Enums.enum_form_string_array list -> + ?enum_header_string:Enums.enumclass -> + ?enum_query_string_array:Enums.enum_form_string_array list -> + ?enum_query_string:Enums.enumclass -> + ?enum_query_integer:Enums.enum_query_integer -> + ?enum_query_double:Enums.enum_number -> + ?enum_query_model_array:Enums.enumclass list -> + ?enum_form_string_array:Enums.enum_form_string_array list -> + ?enum_form_string:Enums.enumclass -> + unit -> + unit Lwt.t + +val test_group_parameters : + required_string_group:int32 -> + required_boolean_group:bool -> + required_int64_group:int64 -> + ?string_group:int32 -> + ?boolean_group:bool -> + ?int64_group:int64 -> + unit -> + unit Lwt.t + +val test_inline_additional_properties : + request_body:(string * string) list -> unit Lwt.t + +val test_inline_freeform_additional_properties : + test_inline_freeform_additional_properties_request_t: + Test_inline_freeform_additional_properties_request.t -> + unit Lwt.t + val test_json_form_data : param:string -> param2:string -> unit Lwt.t val test_nullable : child_with_nullable_t:Child_with_nullable.t -> unit Lwt.t -val test_query_parameter_collection_format : pipe:string list -> ioutil:string list -> http:string list -> url:string list -> context:string list -> allow_empty:string -> ?language:(string * string) list -> unit -> unit Lwt.t -val test_string_map_reference : request_body:(string * string) list -> unit Lwt.t + +val test_query_parameter_collection_format : + pipe:string list -> + ioutil:string list -> + http:string list -> + url:string list -> + context:string list -> + allow_empty:string -> + ?language:(string * string) list -> + unit -> + unit Lwt.t + +val test_string_map_reference : + request_body:(string * string) list -> unit Lwt.t diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml index 5eb1391914f8..14bbcdda6505 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml @@ -6,25 +6,10 @@ *) let test_classname ~client_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake_classname_test" in - let headers = Request.default_headers in - let uri = Uri.add_query_param' uri ("api_key_query", Request.api_key) in - let body = Request. - - write_as_json_body - - - - - - - Client.to_yojson - - - - client_t - in - Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/fake_classname_test" in + let headers = Request.default_headers in + let uri = Uri.add_query_param' uri ("api_key_query", Request.api_key) in + let body = Request.write_as_json_body Client.to_yojson client_t in + Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml index 95637700510d..6cbf1c1fae3f 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml @@ -6,314 +6,118 @@ *) let add_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Pet.to_yojson - - - - pet_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Pet.to_yojson pet_t in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let delete_pet ~pet_id ?api_key () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = Request.maybe_add_header headers "api_key" - - - - - - - - - (fun x -> x) - - - - - api_key in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = + Request.maybe_add_header headers "api_key" (fun x -> x) api_key + in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let find_pets_by_status ~status = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByStatus" in - let headers = Request.default_headers in - let uri = Request.add_query_param_list uri "status" (Stdlib.List.map Enums.show_status - -) - status in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByStatus" in + let headers = Request.default_headers in + let uri = + Request.add_query_param_list uri "status" + (Stdlib.List.map Enums.show_status) + status + in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let find_pets_by_tags ~tags = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByTags" in - let headers = Request.default_headers in - let uri = Request.add_query_param_list uri "tags" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - tags in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByTags" in + let headers = Request.default_headers in + let uri = + Request.add_query_param_list uri "tags" (Stdlib.List.map (fun x -> x)) tags + in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let get_pet_by_id ~pet_id = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let update_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Pet.to_yojson - - - - pet_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Pet.to_yojson pet_t in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let update_pet_with_form ~pet_id ?name ?status () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - let body = Request.init_form_encoded_body () in - let body = Request.maybe_add_form_encoded_body_param body "name" - - - - - - - - - (fun x -> x) - - - - - name in - let body = Request.maybe_add_form_encoded_body_param body "status" - - - - - - - - - (fun x -> x) - - - - - status in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + let body = Request.init_form_encoded_body () in + let body = + Request.maybe_add_form_encoded_body_param body "name" (fun x -> x) name + in + let body = + Request.maybe_add_form_encoded_body_param body "status" (fun x -> x) status + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let upload_file ~pet_id ?additional_metadata ?file () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}/uploadImage" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - let body = Request.init_form_encoded_body () in - let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" - - - - - - - - - (fun x -> x) - - - - - additional_metadata in - let body = Request.maybe_add_form_encoded_body_param body "file" - - - - - - (fun x -> x) - - - - - - - - file in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body - -let upload_file_with_required_file ~pet_id ~required_file ?additional_metadata () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/{petId}/uploadImageWithRequiredFile" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - let body = Request.init_form_encoded_body () in - let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" - - - - - - - - - (fun x -> x) - - - - - additional_metadata in - let body = Request.add_form_encoded_body_param body "required_file" - - - - - - (fun x -> x) - - - - - - - - required_file in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}/uploadImage" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + let body = Request.init_form_encoded_body () in + let body = + Request.maybe_add_form_encoded_body_param body "additional_metadata" + (fun x -> x) + additional_metadata + in + let body = + Request.maybe_add_form_encoded_body_param body "file" (fun x -> x) file + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Api_response.of_yojson) + resp body +let upload_file_with_required_file ~pet_id ~required_file ?additional_metadata + () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake/{petId}/uploadImageWithRequiredFile" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + let body = Request.init_form_encoded_body () in + let body = + Request.maybe_add_form_encoded_body_param body "additional_metadata" + (fun x -> x) + additional_metadata + in + let body = + Request.add_form_encoded_body_param body "required_file" + (fun x -> x) + required_file + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Api_response.of_yojson) + resp body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli index f0aa4208b358..786d33e787f3 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli @@ -11,6 +11,20 @@ val find_pets_by_status : status:Enums.status list -> Pet.t list Lwt.t val find_pets_by_tags : tags:string list -> Pet.t list Lwt.t val get_pet_by_id : pet_id:int64 -> Pet.t Lwt.t val update_pet : pet_t:Pet.t -> unit Lwt.t -val update_pet_with_form : pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t -val upload_file : pet_id:int64 -> ?additional_metadata:string -> ?file:string -> unit -> Api_response.t Lwt.t -val upload_file_with_required_file : pet_id:int64 -> required_file:string -> ?additional_metadata:string -> unit -> Api_response.t Lwt.t + +val update_pet_with_form : + pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t + +val upload_file : + pet_id:int64 -> + ?additional_metadata:string -> + ?file:string -> + unit -> + Api_response.t Lwt.t + +val upload_file_with_required_file : + pet_id:int64 -> + required_file:string -> + ?additional_metadata:string -> + unit -> + Api_response.t Lwt.t diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml index 96c52f9b9ed7..459578fe49d2 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml @@ -6,76 +6,35 @@ *) let delete_order ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{order_id}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "order_id" - - - - - - - - - (fun x -> x) - - - - - order_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{order_id}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "order_id" (fun x -> x) order_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_inventory () = - let open Lwt.Infix in - let uri = Request.build_uri "/store/inventory" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_map_of (JsonSupport.to_int32) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/inventory" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_map_of JsonSupport.to_int32 resp body let get_order_by_id ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{order_id}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "order_id" Int64.to_string - - - - - - - - - - - - - - order_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{order_id}" in + let headers = Request.default_headers in + let uri = + Request.replace_path_param uri "order_id" Int64.to_string order_id + in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body let place_order ~order_t = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Order.to_yojson - - - - order_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/store/order" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Order.to_yojson order_t in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml index c5f913e57a30..6e8f74f19024 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml @@ -6,195 +6,70 @@ *) let create_user ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - User.to_yojson - - - - user_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user" in + let headers = Request.default_headers in + let body = Request.write_as_json_body User.to_yojson user_t in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_array_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithArray" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body (JsonSupport.of_list_of - - - - - - - User.to_yojson - - - -) - user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithArray" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_list_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithList" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body (JsonSupport.of_list_of - - - - - - - User.to_yojson - - - -) - user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithList" in + let headers = Request.default_headers in + let body = + Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let delete_user ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" (fun x -> x) username in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_user_by_name ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" (fun x -> x) username in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body let login_user ~username ~password = - let open Lwt.Infix in - let uri = Request.build_uri "/user/login" in - let headers = Request.default_headers in - let uri = Request.add_query_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - let uri = Request.add_query_param uri "password" - - - - - - - - - (fun x -> x) - - - - - password in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.to_string) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/login" in + let headers = Request.default_headers in + let uri = Request.add_query_param uri "username" (fun x -> x) username in + let uri = Request.add_query_param uri "password" (fun x -> x) password in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as JsonSupport.to_string resp body let logout_user () = - let open Lwt.Infix in - let uri = Request.build_uri "/user/logout" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/logout" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let update_user ~username ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - let body = Request. - - write_as_json_body - - - - - - - User.to_yojson - - - - user_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp - + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" (fun x -> x) username in + let body = Request.write_as_json_body User.to_yojson user_t in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml index 1070136f5dec..9548cf7f824d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml @@ -5,23 +5,18 @@ * *) +type t = { + map_property : (string * string) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] + [@key "map_property"] + map_of_map_property : (string * (string * string) list) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] + [@key "map_of_map_property"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - map_property: (string * string) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] - ; [@key "map_property"] - map_of_map_property: (string * (string * string) list) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] - ; [@key "map_of_map_property"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - map_property = []; - map_of_map_property = []; - } - - +let create () : t = { map_property = []; map_of_map_property = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml index 8824bf45851d..fe5a1957ad61 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml @@ -5,27 +5,11 @@ * *) - - - - type t = { - username: string - - option [@default None] - - - ; [@key "username"] - single_ref_type: Enums.singlereftype - - option [@default None] - - - ; [@key "SingleRefType"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - username = None; - single_ref_type = None; - } - - +type t = { + username : string option; [@default None] [@key "username"] + single_ref_type : Enums.singlereftype option; + [@default None] [@key "SingleRefType"] +} +[@@deriving yojson { strict = false }, show, eq] + +let create () : t = { username = None; single_ref_type = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml index bb9694548e1e..235d96870ad7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml @@ -5,27 +5,10 @@ * *) +type t = { + class_name : string; [@key "className"] + color : string option; [@default None] [@key "color"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - class_name: string - - - - - ; [@key "className"] - color: string - - option [@default None] - - - ; [@key "color"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (class_name : string) : t = { - class_name = class_name; - color = None; - } - - +let create (class_name : string) : t = { class_name; color = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml index 38c83657c392..461249d759b4 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml @@ -5,34 +5,11 @@ * *) - - - - type t = { - code: int32 - - option [@default None] - - - ; [@key "code"] - _type: string - - option [@default None] - - - ; [@key "type"] - message: string - - option [@default None] - - - ; [@key "message"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - code = None; - _type = None; - message = None; - } - - +type t = { + code : int32 option; [@default None] [@key "code"] + _type : string option; [@default None] [@key "type"] + message : string option; [@default None] [@key "message"] +} +[@@deriving yojson { strict = false }, show, eq] + +let create () : t = { code = None; _type = None; message = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml index 17d2b550a3dc..c45ec72c3160 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml @@ -5,18 +5,9 @@ * *) +type t = { + array_array_number : float list list; [@default []] [@key "ArrayArrayNumber"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - array_array_number: float list list - [@default []] - - ; [@key "ArrayArrayNumber"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - array_array_number = []; - } - - +let create () : t = { array_array_number = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml index e4ea0cc597d1..9dd6ebd5b828 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml @@ -5,18 +5,7 @@ * *) +type t = { array_number : float list [@default []] [@key "ArrayNumber"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - array_number: float list - [@default []] - - ; [@key "ArrayNumber"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - array_number = []; - } - - +let create () : t = { array_number = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml index 850e8d6d7197..70d4d2fccfc8 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml @@ -5,28 +5,18 @@ * *) +type t = { + array_of_string : string list; [@default []] [@key "array_of_string"] + array_array_of_integer : int64 list list; + [@default []] [@key "array_array_of_integer"] + array_array_of_model : Read_only_first.t list list; + [@default []] [@key "array_array_of_model"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - array_of_string: string list - [@default []] - - ; [@key "array_of_string"] - array_array_of_integer: int64 list list - [@default []] - - ; [@key "array_array_of_integer"] - array_array_of_model: Read_only_first.t list list - [@default []] - - ; [@key "array_array_of_model"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - array_of_string = []; - array_array_of_integer = []; - array_array_of_model = []; - } - - +let create () : t = + { + array_of_string = []; + array_array_of_integer = []; + array_array_of_model = []; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml index 2725a870b917..0fbe5becf357 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml @@ -5,56 +5,24 @@ * *) +type t = { + small_camel : string option; [@default None] [@key "smallCamel"] + capital_camel : string option; [@default None] [@key "CapitalCamel"] + small_snake : string option; [@default None] [@key "small_Snake"] + capital_snake : string option; [@default None] [@key "Capital_Snake"] + sca_eth_flow_points : string option; + [@default None] [@key "SCA_ETH_Flow_Points"] + (* Name of the pet *) + att_name : string option; [@default None] [@key "ATT_NAME"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - small_camel: string - - option [@default None] - - - ; [@key "smallCamel"] - capital_camel: string - - option [@default None] - - - ; [@key "CapitalCamel"] - small_snake: string - - option [@default None] - - - ; [@key "small_Snake"] - capital_snake: string - - option [@default None] - - - ; [@key "Capital_Snake"] - sca_eth_flow_points: string - - option [@default None] - - - ; [@key "SCA_ETH_Flow_Points"] - (* Name of the pet *) - att_name: string - - option [@default None] - - - ; [@key "ATT_NAME"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - small_camel = None; - capital_camel = None; - small_snake = None; - capital_snake = None; - sca_eth_flow_points = None; - att_name = None; - } - - +let create () : t = + { + small_camel = None; + capital_camel = None; + small_snake = None; + capital_snake = None; + sca_eth_flow_points = None; + att_name = None; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml index d9dcd55ac0af..63fe5e4ea66f 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml @@ -5,34 +5,12 @@ * *) +type t = { + class_name : string; [@key "className"] + color : string option; [@default None] [@key "color"] + declawed : bool option; [@default None] [@key "declawed"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - class_name: string - - - - - ; [@key "className"] - color: string - - option [@default None] - - - ; [@key "color"] - declawed: bool - - option [@default None] - - - ; [@key "declawed"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (class_name : string) : t = { - class_name = class_name; - color = None; - declawed = None; - } - - +let create (class_name : string) : t = + { class_name; color = None; declawed = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml index 95e0b50ee994..fb57d9078918 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml @@ -5,27 +5,10 @@ * *) +type t = { + id : int64 option; [@default None] [@key "id"] + name : string; [@key "name"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - name: string - - - - - ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (name : string) : t = { - id = None; - name = name; - } - - +let create (name : string) : t = { id = None; name } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml index 61eba92d86ce..d791fa513c0b 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml @@ -5,34 +5,13 @@ * *) +type t = { + _type : Enums.parentwithnullable_type option; + [@default Some `ChildWithNullable] [@key "type"] + nullable_property : string option; [@default None] [@key "nullableProperty"] + other_property : string option; [@default None] [@key "otherProperty"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - _type: Enums.parentwithnullable_type - option [@default - Some(`ChildWithNullable) - - ] - ; [@key "type"] - nullable_property: string - - option [@default None] - - - ; [@key "nullableProperty"] - other_property: string - - option [@default None] - - - ; [@key "otherProperty"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - _type = None; - nullable_property = None; - other_property = None; - } - - +let create () : t = + { _type = None; nullable_property = None; other_property = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml index f63be054b150..979fe4f45ca7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml @@ -6,21 +6,8 @@ * Schema Class_model.t : Model for testing model with \''_class\'' property *) +type t = { _class : string option [@default None] [@key "_class"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - _class: string - - option [@default None] - - - ; [@key "_class"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Model for testing model with \''_class\'' property *) - let create () : t = { - _class = None; - } - - +(** Model for testing model with \''_class\'' property *) +let create () : t = { _class = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml index d3b578e2509f..66e50db036a1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml @@ -5,20 +5,7 @@ * *) +type t = { client : string option [@default None] [@key "client"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - client: string - - option [@default None] - - - ; [@key "client"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - client = None; - } - - +let create () : t = { client = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml index ff9a12f2eb4d..a33f47aed2e9 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml @@ -5,20 +5,7 @@ * *) +type t = { name : string option [@default None] [@key "name"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - name: string - - option [@default None] - - - ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - name = None; - } - - +let create () : t = { name = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml index 004e9bb56406..0621e75c12dc 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml @@ -5,34 +5,12 @@ * *) +type t = { + class_name : string; [@key "className"] + color : string option; [@default None] [@key "color"] + breed : string option; [@default None] [@key "breed"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - class_name: string - - - - - ; [@key "className"] - color: string - - option [@default None] - - - ; [@key "color"] - breed: string - - option [@default None] - - - ; [@key "breed"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (class_name : string) : t = { - class_name = class_name; - color = None; - breed = None; - } - - +let create (class_name : string) : t = + { class_name; color = None; breed = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml index 612cdf25beba..6bd89813af6a 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml @@ -5,23 +5,10 @@ * *) +type t = { + just_symbol : Enums.just_symbol option; [@default None] [@key "just_symbol"] + array_enum : Enums.array_enum list; [@key "array_enum"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - just_symbol: Enums.just_symbol - option [@default - - None - ] - ; [@key "just_symbol"] - array_enum: Enums.array_enum list -; [@key "array_enum"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - just_symbol = None; - array_enum = []; - } - - +let create () : t = { just_symbol = None; array_enum = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml index e9df9f2fec4e..d390d986175e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml @@ -5,66 +5,30 @@ * *) +type t = { + enum_string : Enums.enum_string option; [@default None] [@key "enum_string"] + enum_string_required : Enums.enum_string; [@key "enum_string_required"] + enum_integer : Enums.enum_integer option; + [@default None] [@key "enum_integer"] + enum_number : Enums.enum_number option; [@default None] [@key "enum_number"] + outer_enum : Enums.order_status option; [@default None] [@key "outerEnum"] + outer_enum_integer : Enums.outerenuminteger option; + [@default None] [@key "outerEnumInteger"] + outer_enum_default_value : Enums.order_status option; + [@default None] [@key "outerEnumDefaultValue"] + outer_enum_integer_default_value : Enums.outerenuminteger option; + [@default None] [@key "outerEnumIntegerDefaultValue"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - enum_string: Enums.enum_string - option [@default - - None - ] - ; [@key "enum_string"] - enum_string_required: Enums.enum_string - - ; [@key "enum_string_required"] - enum_integer: Enums.enum_integer - option [@default - - None - ] - ; [@key "enum_integer"] - enum_number: Enums.enum_number - option [@default - - None - ] - ; [@key "enum_number"] - outer_enum: Enums.order_status - - option [@default None] - - - ; [@key "outerEnum"] - outer_enum_integer: Enums.outerenuminteger - - option [@default None] - - - ; [@key "outerEnumInteger"] - outer_enum_default_value: Enums.order_status - - option [@default None] - - - ; [@key "outerEnumDefaultValue"] - outer_enum_integer_default_value: Enums.outerenuminteger - - option [@default None] - - - ; [@key "outerEnumIntegerDefaultValue"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (enum_string_required : Enums.enum_string) : t = { - enum_string = None; - enum_string_required = enum_string_required; - enum_integer = None; - enum_number = None; - outer_enum = None; - outer_enum_integer = None; - outer_enum_default_value = None; - outer_enum_integer_default_value = None; - } - - +let create (enum_string_required : Enums.enum_string) : t = + { + enum_string = None; + enum_string_required; + enum_integer = None; + enum_number = None; + outer_enum = None; + outer_enum_integer = None; + outer_enum_default_value = None; + outer_enum_integer_default_value = None; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml index 6abba727a131..e4b59b0d1540 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml @@ -5,25 +5,14 @@ * *) +type t = { + some_id : float option; [@default None] [@key "someId"] + some_map : (string * float) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: float]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: float]] + [@key "someMap"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - some_id: float - - option [@default None] - - - ; [@key "someId"] - some_map: (string * float) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: float]] [@of_yojson JsonSupport.to_map_of [%of_yojson: float]] - ; [@key "someMap"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - some_id = None; - some_map = []; - } - - +let create () : t = { some_id = None; some_map = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml index e02dec2b6bde..56659a378665 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml @@ -6,22 +6,11 @@ * Schema File.t : Must be named `File` for test. *) +type t = { + (* Test capitalization *) + source_uri : string option; [@default None] [@key "sourceURI"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - (* Test capitalization *) - source_uri: string - - option [@default None] - - - ; [@key "sourceURI"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Must be named `File` for test. *) - let create () : t = { - source_uri = None; - } - - +(** Must be named `File` for test. *) +let create () : t = { source_uri = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml index e9bb0b52c6b6..be5000e9a080 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml @@ -5,25 +5,10 @@ * *) +type t = { + file : File.t option; [@default None] [@key "file"] + files : File.t list; [@default []] [@key "files"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - file: File.t - - option [@default None] - - - ; [@key "file"] - files: File.t list - [@default []] - - ; [@key "files"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - file = None; - files = []; - } - - +let create () : t = { file = None; files = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml index a3f48385e0d7..2914c782f1b6 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml @@ -5,20 +5,7 @@ * *) +type t = { bar : string option [@default None] [@key "bar"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - bar: string - - option [@default None] - - - ; [@key "bar"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - bar = None; - } - - +let create () : t = { bar = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml index 03631a54e643..9602d17da10b 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml @@ -5,127 +5,47 @@ * *) +type t = { + integer : int32 option; [@default None] [@key "integer"] + int32 : int32 option; [@default None] [@key "int32"] + int64 : int64 option; [@default None] [@key "int64"] + number : float; [@key "number"] + float : float option; [@default None] [@key "float"] + double : float option; [@default None] [@key "double"] + decimal : string option; [@default None] [@key "decimal"] + string : string option; [@default None] [@key "string"] + byte : string; [@key "byte"] + binary : string option; [@default None] [@key "binary"] + date : string; [@key "date"] + date_time : string option; [@default None] [@key "dateTime"] + uuid : string option; [@default None] [@key "uuid"] + password : string; [@key "password"] + (* A string that is a 10 digit number. Can have leading zeros. *) + pattern_with_digits : string option; + [@default None] [@key "pattern_with_digits"] + (* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. *) + pattern_with_digits_and_delimiter : string option; + [@default None] [@key "pattern_with_digits_and_delimiter"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - integer: int32 - - option [@default None] - - - ; [@key "integer"] - int32: int32 - - option [@default None] - - - ; [@key "int32"] - int64: int64 - - option [@default None] - - - ; [@key "int64"] - number: float - - - - - ; [@key "number"] - float: float - - option [@default None] - - - ; [@key "float"] - double: float - - option [@default None] - - - ; [@key "double"] - decimal: string - - option [@default None] - - - ; [@key "decimal"] - string: string - - option [@default None] - - - ; [@key "string"] - byte: string - - - - - ; [@key "byte"] - binary: string - - option [@default None] - - - ; [@key "binary"] - date: string - - - - - ; [@key "date"] - date_time: string - - option [@default None] - - - ; [@key "dateTime"] - uuid: string - - option [@default None] - - - ; [@key "uuid"] - password: string - - - - - ; [@key "password"] - (* A string that is a 10 digit number. Can have leading zeros. *) - pattern_with_digits: string - - option [@default None] - - - ; [@key "pattern_with_digits"] - (* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. *) - pattern_with_digits_and_delimiter: string - - option [@default None] - - - ; [@key "pattern_with_digits_and_delimiter"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (number : float) (byte : string) (date : string) (password : string) : t = { - integer = None; - int32 = None; - int64 = None; - number = number; - float = None; - double = None; - decimal = None; - string = None; - byte = byte; - binary = None; - date = date; - date_time = None; - uuid = None; - password = password; - pattern_with_digits = None; - pattern_with_digits_and_delimiter = None; - } - - +let create (number : float) (byte : string) (date : string) (password : string) + : t = + { + integer = None; + int32 = None; + int64 = None; + number; + float = None; + double = None; + decimal = None; + string = None; + byte; + binary = None; + date; + date_time = None; + uuid = None; + password; + pattern_with_digits = None; + pattern_with_digits_and_delimiter = None; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml index cebf14ba37f9..ba67253836d1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml @@ -5,27 +5,10 @@ * *) +type t = { + bar : string option; [@default None] [@key "bar"] + foo : string option; [@default None] [@key "foo"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - bar: string - - option [@default None] - - - ; [@key "bar"] - foo: string - - option [@default None] - - - ; [@key "foo"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - bar = None; - foo = None; - } - - +let create () : t = { bar = None; foo = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml index b58d7cd6cfeb..73c38dc2e21a 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml @@ -6,21 +6,11 @@ * Schema Health_check_result.t : Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. *) +type t = { + nullable_message : string option; [@default None] [@key "NullableMessage"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - nullable_message: string - - option [@default None] - - - ; [@key "NullableMessage"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. *) - let create () : t = { - nullable_message = None; - } - - +(** Just a string to inform instance is up and running. Make it nullable in hope + to get it as pointer in generated model. *) +let create () : t = { nullable_message = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml index 13e71de7e641..efa83eac1340 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml @@ -5,20 +5,7 @@ * *) +type t = { var_123_list : string option [@default None] [@key "123-list"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - var_123_list: string - - option [@default None] - - - ; [@key "123-list"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - var_123_list = None; - } - - +let create () : t = { var_123_list = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml index 22a05cd8e6d1..a52060401c35 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml @@ -5,31 +5,31 @@ * *) +type t = { + map_map_of_string : (string * (string * string) list) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] + [@key "map_map_of_string"] + map_of_enum_string : (string * Enums.map_of_enum_string) list; + [@key "map_of_enum_string"] + direct_map : (string * bool) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] + [@key "direct_map"] + indirect_map : (string * bool) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] + [@key "indirect_map"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - map_map_of_string: (string * (string * string) list) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] - ; [@key "map_map_of_string"] - map_of_enum_string: (string * Enums.map_of_enum_string) list -; [@key "map_of_enum_string"] - direct_map: (string * bool) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] - ; [@key "direct_map"] - indirect_map: (string * bool) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] - ; [@key "indirect_map"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - map_map_of_string = []; - map_of_enum_string = []; - direct_map = []; - indirect_map = []; - } - - +let create () : t = + { + map_map_of_string = []; + map_of_enum_string = []; + direct_map = []; + indirect_map = []; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml index b3c6cedecc23..4e410c224ee7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml @@ -5,32 +5,15 @@ * *) +type t = { + uuid : string option; [@default None] [@key "uuid"] + date_time : string option; [@default None] [@key "dateTime"] + map : (string * Animal.t) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: Animal.t]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: Animal.t]] + [@key "map"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - uuid: string - - option [@default None] - - - ; [@key "uuid"] - date_time: string - - option [@default None] - - - ; [@key "dateTime"] - map: (string * Animal.t) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Animal.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Animal.t]] - ; [@key "map"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - uuid = None; - date_time = None; - map = []; - } - - +let create () : t = { uuid = None; date_time = None; map = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml index 06031bb76b08..6ed73fd52846 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml @@ -6,28 +6,11 @@ * Schema Model_200_response.t : Model for testing model name starting with number *) +type t = { + name : int32 option; [@default None] [@key "name"] + _class : string option; [@default None] [@key "class"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - name: int32 - - option [@default None] - - - ; [@key "name"] - _class: string - - option [@default None] - - - ; [@key "class"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Model for testing model name starting with number *) - let create () : t = { - name = None; - _class = None; - } - - +(** Model for testing model name starting with number *) +let create () : t = { name = None; _class = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml index 3231ca32596c..fe553a89fb78 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml @@ -5,20 +5,7 @@ * *) +type t = { string : Foo.t option [@default None] [@key "string"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - string: Foo.t - - option [@default None] - - - ; [@key "string"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - string = None; - } - - +let create () : t = { string = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml index ae3b926c52b1..92857fe3b57e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml @@ -5,20 +5,10 @@ * *) +type t = { + special_property_name : int64 option; + [@default None] [@key "$special[property.name]"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - special_property_name: int64 - - option [@default None] - - - ; [@key "$special[property.name]"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - special_property_name = None; - } - - +let create () : t = { special_property_name = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml index 4b1861ea51ad..8a99873c31ef 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml @@ -6,42 +6,14 @@ * Schema Name.t : Model for testing model name same as property name *) +type t = { + name : int32; [@key "name"] + snake_case : int32 option; [@default None] [@key "snake_case"] + property : string option; [@default None] [@key "property"] + var_123_number : int32 option; [@default None] [@key "123Number"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - name: int32 - - - - - ; [@key "name"] - snake_case: int32 - - option [@default None] - - - ; [@key "snake_case"] - property: string - - option [@default None] - - - ; [@key "property"] - var_123_number: int32 - - option [@default None] - - - ; [@key "123Number"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Model for testing model name same as property name *) - let create (name : int32) : t = { - name = name; - snake_case = None; - property = None; - var_123_number = None; - } - - +(** Model for testing model name same as property name *) +let create (name : int32) : t = + { name; snake_case = None; property = None; var_123_number = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml index 690eb51db5e7..d00f8f718fe3 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml @@ -5,85 +5,49 @@ * *) +type t = { + integer_prop : int32 option; [@default None] [@key "integer_prop"] + number_prop : float option; [@default None] [@key "number_prop"] + boolean_prop : bool option; [@default None] [@key "boolean_prop"] + string_prop : string option; [@default None] [@key "string_prop"] + date_prop : string option; [@default None] [@key "date_prop"] + datetime_prop : string option; [@default None] [@key "datetime_prop"] + array_nullable_prop : Yojson.Safe.t list; + [@default []] [@key "array_nullable_prop"] + array_and_items_nullable_prop : Yojson.Safe.t list; + [@default []] [@key "array_and_items_nullable_prop"] + array_items_nullable : Yojson.Safe.t list; + [@default []] [@key "array_items_nullable"] + object_nullable_prop : (string * Yojson.Safe.t) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + [@key "object_nullable_prop"] + object_and_items_nullable_prop : (string * Yojson.Safe.t) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + [@key "object_and_items_nullable_prop"] + object_items_nullable : (string * Yojson.Safe.t) list; + [@default []] + [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] + [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + [@key "object_items_nullable"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - integer_prop: int32 - - option [@default None] - - - ; [@key "integer_prop"] - number_prop: float - - option [@default None] - - - ; [@key "number_prop"] - boolean_prop: bool - - option [@default None] - - - ; [@key "boolean_prop"] - string_prop: string - - option [@default None] - - - ; [@key "string_prop"] - date_prop: string - - option [@default None] - - - ; [@key "date_prop"] - datetime_prop: string - - option [@default None] - - - ; [@key "datetime_prop"] - array_nullable_prop: Yojson.Safe.t list - [@default []] - - ; [@key "array_nullable_prop"] - array_and_items_nullable_prop: Yojson.Safe.t list - [@default []] - - ; [@key "array_and_items_nullable_prop"] - array_items_nullable: Yojson.Safe.t list - [@default []] - - ; [@key "array_items_nullable"] - object_nullable_prop: (string * Yojson.Safe.t) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] - ; [@key "object_nullable_prop"] - object_and_items_nullable_prop: (string * Yojson.Safe.t) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] - ; [@key "object_and_items_nullable_prop"] - object_items_nullable: (string * Yojson.Safe.t) list - - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] - ; [@key "object_items_nullable"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - integer_prop = None; - number_prop = None; - boolean_prop = None; - string_prop = None; - date_prop = None; - datetime_prop = None; - array_nullable_prop = []; - array_and_items_nullable_prop = []; - array_items_nullable = []; - object_nullable_prop = []; - object_and_items_nullable_prop = []; - object_items_nullable = []; - } - - +let create () : t = + { + integer_prop = None; + number_prop = None; + boolean_prop = None; + string_prop = None; + date_prop = None; + datetime_prop = None; + array_nullable_prop = []; + array_and_items_nullable_prop = []; + array_items_nullable = []; + object_nullable_prop = []; + object_and_items_nullable_prop = []; + object_items_nullable = []; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml index 2ca1bb224c58..297e4f68afcd 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml @@ -5,20 +5,7 @@ * *) +type t = { just_number : float option [@default None] [@key "JustNumber"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - just_number: float - - option [@default None] - - - ; [@key "JustNumber"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - just_number = None; - } - - +let create () : t = { just_number = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml index 93bb27889b10..49ce5b2ee2dd 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml @@ -5,39 +5,13 @@ * *) +type t = { + uuid : string option; [@default None] [@key "uuid"] + id : float option; [@default None] [@key "id"] + deprecated_ref : Deprecated_object.t option; + [@default None] [@key "deprecatedRef"] + bars : string list; [@default []] [@key "bars"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - uuid: string - - option [@default None] - - - ; [@key "uuid"] - id: float - - option [@default None] - - - ; [@key "id"] - deprecated_ref: Deprecated_object.t - - option [@default None] - - - ; [@key "deprecatedRef"] - bars: string list - [@default []] - - ; [@key "bars"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - uuid = None; - id = None; - deprecated_ref = None; - bars = []; - } - - +let create () : t = { uuid = None; id = None; deprecated_ref = None; bars = [] } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml index edeb14daf189..bb28c2a8bf26 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml @@ -5,56 +5,23 @@ * *) +type t = { + id : int64 option; [@default None] [@key "id"] + pet_id : int64 option; [@default None] [@key "petId"] + quantity : int32 option; [@default None] [@key "quantity"] + ship_date : string option; [@default None] [@key "shipDate"] + (* Order Status *) + status : Enums.order_status option; [@default None] [@key "status"] + complete : bool option; [@default None] [@key "complete"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - pet_id: int64 - - option [@default None] - - - ; [@key "petId"] - quantity: int32 - - option [@default None] - - - ; [@key "quantity"] - ship_date: string - - option [@default None] - - - ; [@key "shipDate"] - (* Order Status *) - status: Enums.order_status - option [@default - - None - ] - ; [@key "status"] - complete: bool - - option [@default None] - - - ; [@key "complete"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - id = None; - pet_id = None; - quantity = None; - ship_date = None; - status = None; - complete = None; - } - - +let create () : t = + { + id = None; + pet_id = None; + quantity = None; + ship_date = None; + status = None; + complete = None; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml index 5ab6dc894cfc..cc7ccb2c6304 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml @@ -5,34 +5,11 @@ * *) - - - - type t = { - my_number: float - - option [@default None] - - - ; [@key "my_number"] - my_string: string - - option [@default None] - - - ; [@key "my_string"] - my_boolean: bool - - option [@default None] - - - ; [@key "my_boolean"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - my_number = None; - my_string = None; - my_boolean = None; - } - - +type t = { + my_number : float option; [@default None] [@key "my_number"] + my_string : string option; [@default None] [@key "my_string"] + my_boolean : bool option; [@default None] [@key "my_boolean"] +} +[@@deriving yojson { strict = false }, show, eq] + +let create () : t = { my_number = None; my_string = None; my_boolean = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml index defddabc9421..59e02911a776 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml @@ -5,20 +5,7 @@ * *) +type t = { value : Enums.outerenuminteger [@key "value"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - value: Enums.outerenuminteger - - - - - ; [@key "value"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (value : Enums.outerenuminteger) : t = { - value = value; - } - - +let create (value : Enums.outerenuminteger) : t = { value } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml index 0a82027599dc..e62c2584e79b 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml @@ -5,27 +5,11 @@ * *) - - - - type t = { - _type: Enums.parentwithnullable_type - option [@default - Some(`ChildWithNullable) - - ] - ; [@key "type"] - nullable_property: string - - option [@default None] - - - ; [@key "nullableProperty"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - _type = None; - nullable_property = None; - } - - +type t = { + _type : Enums.parentwithnullable_type option; + [@default Some `ChildWithNullable] [@key "type"] + nullable_property : string option; [@default None] [@key "nullableProperty"] +} +[@@deriving yojson { strict = false }, show, eq] + +let create () : t = { _type = None; nullable_property = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml index bf5b6f289e3c..a2311c5dc720 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml @@ -5,52 +5,15 @@ * *) +type t = { + id : int64 option; [@default None] [@key "id"] + category : Category.t option; [@default None] [@key "category"] + name : string; [@key "name"] + photo_urls : string list; [@key "photoUrls"] + tags : Tag.t list; [@default []] [@key "tags"] (* pet status in the store *) + status : Enums.status option; [@default None] [@key "status"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - category: Category.t - - option [@default None] - - - ; [@key "category"] - name: string - - - - - ; [@key "name"] - photo_urls: string list - - - ; [@key "photoUrls"] - tags: Tag.t list - [@default []] - - ; [@key "tags"] - (* pet status in the store *) - status: Enums.status - option [@default - - None - ] - ; [@key "status"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create (name : string) (photo_urls : string list) : t = { - id = None; - category = None; - name = name; - photo_urls = photo_urls; - tags = []; - status = None; - } - - +let create (name : string) (photo_urls : string list) : t = + { id = None; category = None; name; photo_urls; tags = []; status = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml index 42764810c586..52837ce4c713 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml @@ -5,27 +5,10 @@ * *) +type t = { + bar : string option; [@default None] [@key "bar"] + baz : string option; [@default None] [@key "baz"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - bar: string - - option [@default None] - - - ; [@key "bar"] - baz: string - - option [@default None] - - - ; [@key "baz"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - bar = None; - baz = None; - } - - +let create () : t = { bar = None; baz = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml index 1b27a9c0c5b5..ed4f30407168 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml @@ -6,21 +6,8 @@ * Schema Return.t : Model for testing reserved words *) +type t = { return : int32 option [@default None] [@key "return"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - return: int32 - - option [@default None] - - - ; [@key "return"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Model for testing reserved words *) - let create () : t = { - return = None; - } - - +(** Model for testing reserved words *) +let create () : t = { return = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml index 01467b5e0745..335112074190 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml @@ -5,27 +5,10 @@ * *) +type t = { + id : int64 option; [@default None] [@key "id"] + name : string option; [@default None] [@key "name"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - name: string - - option [@default None] - - - ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - id = None; - name = None; - } - - +let create () : t = { id = None; name = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml index 9aa631abe7bc..be86989e9f1b 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml @@ -5,20 +5,7 @@ * *) +type t = { some_property : string option [@default None] [@key "someProperty"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - some_property: string - - option [@default None] - - - ; [@key "someProperty"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - some_property = None; - } - - +let create () : t = { some_property = None } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml index 4582d3115276..32f410b2e563 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml @@ -5,70 +5,27 @@ * *) +type t = { + id : int64 option; [@default None] [@key "id"] + username : string option; [@default None] [@key "username"] + first_name : string option; [@default None] [@key "firstName"] + last_name : string option; [@default None] [@key "lastName"] + email : string option; [@default None] [@key "email"] + password : string option; [@default None] [@key "password"] + phone : string option; [@default None] [@key "phone"] + (* User Status *) + user_status : int32 option; [@default None] [@key "userStatus"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - username: string - - option [@default None] - - - ; [@key "username"] - first_name: string - - option [@default None] - - - ; [@key "firstName"] - last_name: string - - option [@default None] - - - ; [@key "lastName"] - email: string - - option [@default None] - - - ; [@key "email"] - password: string - - option [@default None] - - - ; [@key "password"] - phone: string - - option [@default None] - - - ; [@key "phone"] - (* User Status *) - user_status: int32 - - option [@default None] - - - ; [@key "userStatus"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - id = None; - username = None; - first_name = None; - last_name = None; - email = None; - password = None; - phone = None; - user_status = None; - } - - +let create () : t = + { + id = None; + username = None; + first_name = None; + last_name = None; + email = None; + password = None; + phone = None; + user_status = None; + } diff --git a/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml b/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml index 38b8eb297499..e17deb86aaef 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml @@ -5,159 +5,208 @@ * *) -type outerenuminteger = [ -| `_0 [@printer fun fmt _ -> Format.pp_print_string fmt "0"] [@name "0"] -| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] -| `_2 [@printer fun fmt _ -> Format.pp_print_string fmt "2"] [@name "2"] -] [@@deriving yojson, show { with_path = false }, eq];; +type outerenuminteger = + [ `_0 [@printer fun fmt _ -> Format.pp_print_string fmt "0"] [@name "0"] + | `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] + | `_2 [@printer fun fmt _ -> Format.pp_print_string fmt "2"] [@name "2"] ] +[@@deriving yojson, show { with_path = false }, eq] -let outerenuminteger_of_yojson json = outerenuminteger_of_yojson (`List [json]) -let outerenuminteger_to_yojson e = - match outerenuminteger_to_yojson e with - | `List [json] -> json - | json -> json +let outerenuminteger_of_yojson json = + outerenuminteger_of_yojson (`List [ json ]) -type map_of_enum_string = [ -| `UPPER [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] [@name "UPPER"] -| `Lower [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] [@name "lower"] -] [@@deriving yojson, show { with_path = false }, eq];; +let outerenuminteger_to_yojson e = + match outerenuminteger_to_yojson e with + | `List [ json ] -> json + | json -> json + +type map_of_enum_string = + [ `UPPER + [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] + [@name "UPPER"] + | `Lower + [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] + [@name "lower"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let map_of_enum_string_of_yojson json = + map_of_enum_string_of_yojson (`List [ json ]) -let map_of_enum_string_of_yojson json = map_of_enum_string_of_yojson (`List [json]) let map_of_enum_string_to_yojson e = - match map_of_enum_string_to_yojson e with - | `List [json] -> json - | json -> json + match map_of_enum_string_to_yojson e with + | `List [ json ] -> json + | json -> json -type enum_integer = [ -| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] -| `Minus1 [@printer fun fmt _ -> Format.pp_print_string fmt "-1"] [@name "-1"] -] [@@deriving yojson, show { with_path = false }, eq];; +type enum_integer = + [ `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] + | `Minus1 [@printer fun fmt _ -> Format.pp_print_string fmt "-1"] [@name "-1"] + ] +[@@deriving yojson, show { with_path = false }, eq] + +let enum_integer_of_yojson json = enum_integer_of_yojson (`List [ json ]) -let enum_integer_of_yojson json = enum_integer_of_yojson (`List [json]) let enum_integer_to_yojson e = - match enum_integer_to_yojson e with - | `List [json] -> json - | json -> json + match enum_integer_to_yojson e with `List [ json ] -> json | json -> json -type just_symbol = [ -| `Greater_ThanEqual [@printer fun fmt _ -> Format.pp_print_string fmt ">="] [@name ">="] -| `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] -] [@@deriving yojson, show { with_path = false }, eq];; +type just_symbol = + [ `Greater_ThanEqual + [@printer fun fmt _ -> Format.pp_print_string fmt ">="] + [@name ">="] + | `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] + ] +[@@deriving yojson, show { with_path = false }, eq] -let just_symbol_of_yojson json = just_symbol_of_yojson (`List [json]) -let just_symbol_to_yojson e = - match just_symbol_to_yojson e with - | `List [json] -> json - | json -> json +let just_symbol_of_yojson json = just_symbol_of_yojson (`List [ json ]) -type enumclass = [ -| `_abc [@printer fun fmt _ -> Format.pp_print_string fmt "_abc"] [@name "_abc"] -| `Minusefg [@printer fun fmt _ -> Format.pp_print_string fmt "-efg"] [@name "-efg"] -| `Left_ParenthesisxyzRight_Parenthesis [@printer fun fmt _ -> Format.pp_print_string fmt "(xyz)"] [@name "(xyz)"] -] [@@deriving yojson, show { with_path = false }, eq];; +let just_symbol_to_yojson e = + match just_symbol_to_yojson e with `List [ json ] -> json | json -> json + +type enumclass = + [ `_abc + [@printer fun fmt _ -> Format.pp_print_string fmt "_abc"] + [@name "_abc"] + | `Minusefg + [@printer fun fmt _ -> Format.pp_print_string fmt "-efg"] + [@name "-efg"] + | `Left_ParenthesisxyzRight_Parenthesis + [@printer fun fmt _ -> Format.pp_print_string fmt "(xyz)"] + [@name "(xyz)"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let enumclass_of_yojson json = enumclass_of_yojson (`List [ json ]) -let enumclass_of_yojson json = enumclass_of_yojson (`List [json]) let enumclass_to_yojson e = - match enumclass_to_yojson e with - | `List [json] -> json - | json -> json - -type status = [ -| `Available [@printer fun fmt _ -> Format.pp_print_string fmt "available"] [@name "available"] -| `Pending [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] [@name "pending"] -| `Sold [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] [@name "sold"] -] [@@deriving yojson, show { with_path = false }, eq];; + match enumclass_to_yojson e with `List [ json ] -> json | json -> json + +type status = + [ `Available + [@printer fun fmt _ -> Format.pp_print_string fmt "available"] + [@name "available"] + | `Pending + [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] + [@name "pending"] + | `Sold + [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] + [@name "sold"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let status_of_yojson json = status_of_yojson (`List [ json ]) -let status_of_yojson json = status_of_yojson (`List [json]) let status_to_yojson e = - match status_to_yojson e with - | `List [json] -> json - | json -> json - -type order_status = [ -| `Placed [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] [@name "placed"] -| `Approved [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] [@name "approved"] -| `Delivered [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] [@name "delivered"] -] [@@deriving yojson, show { with_path = false }, eq];; + match status_to_yojson e with `List [ json ] -> json | json -> json + +type order_status = + [ `Placed + [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] + [@name "placed"] + | `Approved + [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] + [@name "approved"] + | `Delivered + [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] + [@name "delivered"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let order_status_of_yojson json = order_status_of_yojson (`List [ json ]) -let order_status_of_yojson json = order_status_of_yojson (`List [json]) let order_status_to_yojson e = - match order_status_to_yojson e with - | `List [json] -> json - | json -> json + match order_status_to_yojson e with `List [ json ] -> json | json -> json -type enum_query_integer = [ -| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] -| `Minus2 [@printer fun fmt _ -> Format.pp_print_string fmt "-2"] [@name "-2"] -] [@@deriving yojson, show { with_path = false }, eq];; +type enum_query_integer = + [ `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] + | `Minus2 [@printer fun fmt _ -> Format.pp_print_string fmt "-2"] [@name "-2"] + ] +[@@deriving yojson, show { with_path = false }, eq] + +let enum_query_integer_of_yojson json = + enum_query_integer_of_yojson (`List [ json ]) -let enum_query_integer_of_yojson json = enum_query_integer_of_yojson (`List [json]) let enum_query_integer_to_yojson e = - match enum_query_integer_to_yojson e with - | `List [json] -> json - | json -> json + match enum_query_integer_to_yojson e with + | `List [ json ] -> json + | json -> json + +type enum_form_string_array = + [ `Greater_Than + [@printer fun fmt _ -> Format.pp_print_string fmt ">"] + [@name ">"] + | `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] + ] +[@@deriving yojson, show { with_path = false }, eq] -type enum_form_string_array = [ -| `Greater_Than [@printer fun fmt _ -> Format.pp_print_string fmt ">"] [@name ">"] -| `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] -] [@@deriving yojson, show { with_path = false }, eq];; +let enum_form_string_array_of_yojson json = + enum_form_string_array_of_yojson (`List [ json ]) -let enum_form_string_array_of_yojson json = enum_form_string_array_of_yojson (`List [json]) let enum_form_string_array_to_yojson e = - match enum_form_string_array_to_yojson e with - | `List [json] -> json - | json -> json + match enum_form_string_array_to_yojson e with + | `List [ json ] -> json + | json -> json -type parentwithnullable_type = [ -| `ChildWithNullable [@printer fun fmt _ -> Format.pp_print_string fmt "ChildWithNullable"] [@name "ChildWithNullable"] -] [@@deriving yojson, show { with_path = false }, eq];; +type parentwithnullable_type = + [ `ChildWithNullable + [@printer fun fmt _ -> Format.pp_print_string fmt "ChildWithNullable"] + [@name "ChildWithNullable"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let parentwithnullable_type_of_yojson json = + parentwithnullable_type_of_yojson (`List [ json ]) -let parentwithnullable_type_of_yojson json = parentwithnullable_type_of_yojson (`List [json]) let parentwithnullable_type_to_yojson e = - match parentwithnullable_type_to_yojson e with - | `List [json] -> json - | json -> json + match parentwithnullable_type_to_yojson e with + | `List [ json ] -> json + | json -> json + +type enum_number = + [ `_1Period1 + [@printer fun fmt _ -> Format.pp_print_string fmt "1.1"] + [@name "1.1"] + | `Minus1Period2 + [@printer fun fmt _ -> Format.pp_print_string fmt "-1.2"] + [@name "-1.2"] ] +[@@deriving yojson, show { with_path = false }, eq] -type enum_number = [ -| `_1Period1 [@printer fun fmt _ -> Format.pp_print_string fmt "1.1"] [@name "1.1"] -| `Minus1Period2 [@printer fun fmt _ -> Format.pp_print_string fmt "-1.2"] [@name "-1.2"] -] [@@deriving yojson, show { with_path = false }, eq];; +let enum_number_of_yojson json = enum_number_of_yojson (`List [ json ]) -let enum_number_of_yojson json = enum_number_of_yojson (`List [json]) let enum_number_to_yojson e = - match enum_number_to_yojson e with - | `List [json] -> json - | json -> json + match enum_number_to_yojson e with `List [ json ] -> json | json -> json -type array_enum = [ -| `Fish [@printer fun fmt _ -> Format.pp_print_string fmt "fish"] [@name "fish"] -| `Crab [@printer fun fmt _ -> Format.pp_print_string fmt "crab"] [@name "crab"] -] [@@deriving yojson, show { with_path = false }, eq];; +type array_enum = + [ `Fish + [@printer fun fmt _ -> Format.pp_print_string fmt "fish"] + [@name "fish"] + | `Crab + [@printer fun fmt _ -> Format.pp_print_string fmt "crab"] + [@name "crab"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let array_enum_of_yojson json = array_enum_of_yojson (`List [ json ]) -let array_enum_of_yojson json = array_enum_of_yojson (`List [json]) let array_enum_to_yojson e = - match array_enum_to_yojson e with - | `List [json] -> json - | json -> json + match array_enum_to_yojson e with `List [ json ] -> json | json -> json + +type singlereftype = + [ `Admin + [@printer fun fmt _ -> Format.pp_print_string fmt "admin"] + [@name "admin"] + | `User + [@printer fun fmt _ -> Format.pp_print_string fmt "user"] + [@name "user"] ] +[@@deriving yojson, show { with_path = false }, eq] -type singlereftype = [ -| `Admin [@printer fun fmt _ -> Format.pp_print_string fmt "admin"] [@name "admin"] -| `User [@printer fun fmt _ -> Format.pp_print_string fmt "user"] [@name "user"] -] [@@deriving yojson, show { with_path = false }, eq];; +let singlereftype_of_yojson json = singlereftype_of_yojson (`List [ json ]) -let singlereftype_of_yojson json = singlereftype_of_yojson (`List [json]) let singlereftype_to_yojson e = - match singlereftype_to_yojson e with - | `List [json] -> json - | json -> json + match singlereftype_to_yojson e with `List [ json ] -> json | json -> json + +type enum_string = + [ `UPPER + [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] + [@name "UPPER"] + | `Lower + [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] + [@name "lower"] ] +[@@deriving yojson, show { with_path = false }, eq] -type enum_string = [ -| `UPPER [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] [@name "UPPER"] -| `Lower [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] [@name "lower"] -] [@@deriving yojson, show { with_path = false }, eq];; +let enum_string_of_yojson json = enum_string_of_yojson (`List [ json ]) -let enum_string_of_yojson json = enum_string_of_yojson (`List [json]) let enum_string_to_yojson e = - match enum_string_to_yojson e with - | `List [json] -> json - | json -> json + match enum_string_to_yojson e with `List [ json ] -> json | json -> json diff --git a/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml b/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml index 0af0c25e759a..9b4d882c3c12 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml @@ -1,68 +1,55 @@ open Ppx_deriving_yojson_runtime let unwrap to_json json = - match to_json json with - | Result.Ok json -> json - | Result.Error s -> failwith s + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s let to_int json = - match json with - | `Int x -> x - | `Intlit s -> int_of_string s - | _ -> failwith "JsonSupport.to_int" + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" let to_bool json = - match json with - | `Bool x -> x - | _ -> failwith "JsonSupport.to_bool" + match json with `Bool x -> x | _ -> failwith "JsonSupport.to_bool" let to_float json = - match json with - | `Float x -> x - | _ -> failwith "JsonSupport.to_float" + match json with `Float x -> x | _ -> failwith "JsonSupport.to_float" let to_string json = - match json with - | `String s -> s - | _ -> failwith "JsonSupport.to_string" + match json with `String s -> s | _ -> failwith "JsonSupport.to_string" let to_int32 json : int32 = - match json with - | `Int x -> Int32.of_int x - | `Intlit s -> Int32.of_string s - | _ -> failwith "JsonSupport.to_int32" + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" let to_int64 json : int64 = - match json with - | `Int x -> Int64.of_int x - | `Intlit s -> Int64.of_string s - | _ -> failwith "JsonSupport.to_int64" + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" let of_int x = `Int x - let of_bool b = `Bool b - let of_float x = `Float x - let of_string s = `String s - let of_int32 x = `Intlit (Int32.to_string x) - let of_int64 x = `Intlit (Int64.to_string x) - let of_list_of of_f l = `List (Stdlib.List.map of_f l) - let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) let to_map_of of_f json = match json with | `Assoc l -> - Stdlib.List.fold_right - (fun (k, json) acc -> - match (of_f json, acc) with - | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> - Stdlib.Result.Ok ((k, parsed_v) :: tl) - | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e - | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) - l (Stdlib.Result.Ok []) + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml b/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml index cbb1a71ea697..dbf462c85e4e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml @@ -1,16 +1,9 @@ let api_key = "" let base_url = "http://petstore.swagger.io:80/v2" let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" - -let option_fold f default o = - match o with - | Some v -> f v - | None -> default - +let option_fold f default o = match o with Some v -> f v | None -> default let build_uri operation_path = Uri.of_string (base_url ^ operation_path) - -let add_string_header headers key value = - Cohttp.Header.add headers key value +let add_string_header headers key value = Cohttp.Header.add headers key value let add_string_header_multi headers key values = Cohttp.Header.add_multi headers key values @@ -37,13 +30,16 @@ let write_as_json_body to_json payload = write_json_body (to_json payload) let handle_response resp on_success_handler = match Cohttp.Response.status resp with | #Cohttp.Code.success_status -> on_success_handler () - | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + | s -> + failwith + ("Server responded with status " + ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) let read_json_body resp body = handle_response resp (fun () -> - (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) + Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string)) let read_json_body_as of_json resp body = Lwt.(read_json_body resp body >|= of_json) @@ -58,11 +54,15 @@ let read_json_body_as_map resp body = Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) let read_json_body_as_map_of of_json resp body = - Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + Lwt.( + read_json_body_as_map resp body + >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) let replace_string_path_param uri param_name param_value = let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in - let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in + let path = + Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) + in Uri.with_path uri path let replace_path_param uri param_name to_string param_value = @@ -85,26 +85,33 @@ let maybe_add_query_param uri param_name to_string param_value = - [explode = true] - type [object] - See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters + See + https://swagger.io/docs/specification/v3_0/serialization/#query-parameters *) let add_query_param_exploded_form_object uri _param_name to_string param_value = -Stdlib.List.fold_left - (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) - uri - param_value + Stdlib.List.fold_left + (fun uri (param_name, param_value) -> + add_query_param uri param_name to_string param_value) + uri param_value let init_form_encoded_body () = "" let add_form_encoded_body_param params param_name to_string param_value = - let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in - if params = "" - then new_param_enc + let new_param_enc = + Printf.sprintf {|%s=%s|} + (Uri.pct_encode param_name) + (Uri.pct_encode (to_string param_value)) + in + if params = "" then new_param_enc else Printf.sprintf {|%s&%s|} params new_param_enc let add_form_encoded_body_param_list params param_name to_string new_params = - add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) + add_form_encoded_body_param params param_name (String.concat ",") + (to_string new_params) let maybe_add_form_encoded_body_param params param_name to_string param_value = - option_fold (add_form_encoded_body_param params param_name to_string) params param_value + option_fold + (add_form_encoded_body_param params param_name to_string) + params param_value let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body diff --git a/samples/client/petstore/ocaml-oneOf/dune b/samples/client/petstore/ocaml-oneOf/dune index ed1c4d90e3df..d10b1d1a5075 100644 --- a/samples/client/petstore/ocaml-oneOf/dune +++ b/samples/client/petstore/ocaml-oneOf/dune @@ -1,9 +1,11 @@ (include_subdirs unqualified) + (library - (name petstore_client) - (public_name petstore_client) - (flags (:standard -w -27)) - (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) - (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) - (wrapped true) -) \ No newline at end of file + (name petstore_client) + (public_name petstore_client) + (flags + (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess + (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true)) diff --git a/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml b/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml index 93677e4bf1f5..432c068ba143 100644 --- a/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml +++ b/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml @@ -6,9 +6,8 @@ *) let list () = - let open Lwt.Infix in - let uri = Request.build_uri "/example" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Example.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/example" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Example.of_yojson) resp body diff --git a/samples/client/petstore/ocaml-oneOf/src/models/child.ml b/samples/client/petstore/ocaml-oneOf/src/models/child.ml index ff9a12f2eb4d..a33f47aed2e9 100644 --- a/samples/client/petstore/ocaml-oneOf/src/models/child.ml +++ b/samples/client/petstore/ocaml-oneOf/src/models/child.ml @@ -5,20 +5,7 @@ * *) +type t = { name : string option [@default None] [@key "name"] } +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - name: string - - option [@default None] - - - ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; - - let create () : t = { - name = None; - } - - +let create () : t = { name = None } diff --git a/samples/client/petstore/ocaml-oneOf/src/models/example.ml b/samples/client/petstore/ocaml-oneOf/src/models/example.ml index 42162d950c76..a9b61de3ed7c 100644 --- a/samples/client/petstore/ocaml-oneOf/src/models/example.ml +++ b/samples/client/petstore/ocaml-oneOf/src/models/example.ml @@ -5,35 +5,35 @@ * *) - type t = - | OneOf0 of Child.t - | OneOf1 of int32 - [@@deriving show, eq];; - - let to_yojson = function - | OneOf0 v -> [%to_yojson: Child.t] v - | OneOf1 v -> [%to_yojson: int32] v - - (* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *) - - let of_yojson json = - [ - [%of_yojson: Child.t] json - |> Stdlib.Result.to_option - |> Stdlib.Option.map (fun v -> OneOf0 v); - [%of_yojson: int32] json - |> Stdlib.Result.to_option - |> Stdlib.Option.map (fun v -> OneOf1 v); - ] - |> Stdlib.List.filter_map (Fun.id) - |> function - | [t] -> Ok t - | [] -> Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type Example.t") - | ts -> let parsed_ts = ts - |> Stdlib.List.map show - |> Stdlib.String.concat " | " - in Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type Example.t: oneOf should only succeed on one parser, but the JSON was parsed into [" ^ parsed_ts ^ "]") +type t = OneOf0 of Child.t | OneOf1 of int32 [@@deriving show, eq] +let to_yojson = function + | OneOf0 v -> [%to_yojson: Child.t] v + | OneOf1 v -> [%to_yojson: int32] v - +(* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *) +let of_yojson json = + [ + [%of_yojson: Child.t] json + |> Stdlib.Result.to_option + |> Stdlib.Option.map (fun v -> OneOf0 v); + [%of_yojson: int32] json + |> Stdlib.Result.to_option + |> Stdlib.Option.map (fun v -> OneOf1 v); + ] + |> Stdlib.List.filter_map Fun.id + |> function + | [ t ] -> Ok t + | [] -> + Error + ("Failed to parse JSON " ^ Yojson.Safe.show json + ^ " into a value of type Example.t") + | ts -> + let parsed_ts = + ts |> Stdlib.List.map show |> Stdlib.String.concat " | " + in + Error + ("Failed to parse JSON " ^ Yojson.Safe.show json + ^ " into a value of type Example.t: oneOf should only succeed on one \ + parser, but the JSON was parsed into [" ^ parsed_ts ^ "]") diff --git a/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml b/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml index 0af0c25e759a..9b4d882c3c12 100644 --- a/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml +++ b/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml @@ -1,68 +1,55 @@ open Ppx_deriving_yojson_runtime let unwrap to_json json = - match to_json json with - | Result.Ok json -> json - | Result.Error s -> failwith s + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s let to_int json = - match json with - | `Int x -> x - | `Intlit s -> int_of_string s - | _ -> failwith "JsonSupport.to_int" + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" let to_bool json = - match json with - | `Bool x -> x - | _ -> failwith "JsonSupport.to_bool" + match json with `Bool x -> x | _ -> failwith "JsonSupport.to_bool" let to_float json = - match json with - | `Float x -> x - | _ -> failwith "JsonSupport.to_float" + match json with `Float x -> x | _ -> failwith "JsonSupport.to_float" let to_string json = - match json with - | `String s -> s - | _ -> failwith "JsonSupport.to_string" + match json with `String s -> s | _ -> failwith "JsonSupport.to_string" let to_int32 json : int32 = - match json with - | `Int x -> Int32.of_int x - | `Intlit s -> Int32.of_string s - | _ -> failwith "JsonSupport.to_int32" + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" let to_int64 json : int64 = - match json with - | `Int x -> Int64.of_int x - | `Intlit s -> Int64.of_string s - | _ -> failwith "JsonSupport.to_int64" + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" let of_int x = `Int x - let of_bool b = `Bool b - let of_float x = `Float x - let of_string s = `String s - let of_int32 x = `Intlit (Int32.to_string x) - let of_int64 x = `Intlit (Int64.to_string x) - let of_list_of of_f l = `List (Stdlib.List.map of_f l) - let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) let to_map_of of_f json = match json with | `Assoc l -> - Stdlib.List.fold_right - (fun (k, json) acc -> - match (of_f json, acc) with - | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> - Stdlib.Result.Ok ((k, parsed_v) :: tl) - | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e - | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) - l (Stdlib.Result.Ok []) + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml-oneOf/src/support/request.ml b/samples/client/petstore/ocaml-oneOf/src/support/request.ml index c89862d5d0ea..29eaa66901c9 100644 --- a/samples/client/petstore/ocaml-oneOf/src/support/request.ml +++ b/samples/client/petstore/ocaml-oneOf/src/support/request.ml @@ -1,16 +1,9 @@ let api_key = "" let base_url = "http://api.example.xyz/v1" let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" - -let option_fold f default o = - match o with - | Some v -> f v - | None -> default - +let option_fold f default o = match o with Some v -> f v | None -> default let build_uri operation_path = Uri.of_string (base_url ^ operation_path) - -let add_string_header headers key value = - Cohttp.Header.add headers key value +let add_string_header headers key value = Cohttp.Header.add headers key value let add_string_header_multi headers key values = Cohttp.Header.add_multi headers key values @@ -37,13 +30,16 @@ let write_as_json_body to_json payload = write_json_body (to_json payload) let handle_response resp on_success_handler = match Cohttp.Response.status resp with | #Cohttp.Code.success_status -> on_success_handler () - | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + | s -> + failwith + ("Server responded with status " + ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) let read_json_body resp body = handle_response resp (fun () -> - (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) + Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string)) let read_json_body_as of_json resp body = Lwt.(read_json_body resp body >|= of_json) @@ -58,11 +54,15 @@ let read_json_body_as_map resp body = Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) let read_json_body_as_map_of of_json resp body = - Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + Lwt.( + read_json_body_as_map resp body + >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) let replace_string_path_param uri param_name param_value = let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in - let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in + let path = + Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) + in Uri.with_path uri path let replace_path_param uri param_name to_string param_value = @@ -85,26 +85,33 @@ let maybe_add_query_param uri param_name to_string param_value = - [explode = true] - type [object] - See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters + See + https://swagger.io/docs/specification/v3_0/serialization/#query-parameters *) let add_query_param_exploded_form_object uri _param_name to_string param_value = -Stdlib.List.fold_left - (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) - uri - param_value + Stdlib.List.fold_left + (fun uri (param_name, param_value) -> + add_query_param uri param_name to_string param_value) + uri param_value let init_form_encoded_body () = "" let add_form_encoded_body_param params param_name to_string param_value = - let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in - if params = "" - then new_param_enc + let new_param_enc = + Printf.sprintf {|%s=%s|} + (Uri.pct_encode param_name) + (Uri.pct_encode (to_string param_value)) + in + if params = "" then new_param_enc else Printf.sprintf {|%s&%s|} params new_param_enc let add_form_encoded_body_param_list params param_name to_string new_params = - add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) + add_form_encoded_body_param params param_name (String.concat ",") + (to_string new_params) let maybe_add_form_encoded_body_param params param_name to_string param_value = - option_fold (add_form_encoded_body_param params param_name to_string) params param_value + option_fold + (add_form_encoded_body_param params param_name to_string) + params param_value let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body diff --git a/samples/client/petstore/ocaml/dune b/samples/client/petstore/ocaml/dune index ed1c4d90e3df..d10b1d1a5075 100644 --- a/samples/client/petstore/ocaml/dune +++ b/samples/client/petstore/ocaml/dune @@ -1,9 +1,11 @@ (include_subdirs unqualified) + (library - (name petstore_client) - (public_name petstore_client) - (flags (:standard -w -27)) - (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) - (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) - (wrapped true) -) \ No newline at end of file + (name petstore_client) + (public_name petstore_client) + (flags + (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess + (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true)) diff --git a/samples/client/petstore/ocaml/src/apis/pet_api.ml b/samples/client/petstore/ocaml/src/apis/pet_api.ml index 386163121bda..5157abf622ca 100644 --- a/samples/client/petstore/ocaml/src/apis/pet_api.ml +++ b/samples/client/petstore/ocaml/src/apis/pet_api.ml @@ -6,260 +6,95 @@ *) let add_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Pet.to_yojson - - - - pet_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Pet.to_yojson pet_t in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let delete_pet ~pet_id ?api_key () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = Request.maybe_add_header headers "api_key" - - - - - - - - - (fun x -> x) - - - - - api_key in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = + Request.maybe_add_header headers "api_key" (fun x -> x) api_key + in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let find_pets_by_status ~status = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByStatus" in - let headers = Request.default_headers in - let uri = Request.add_query_param_list uri "status" (Stdlib.List.map Enums.show_pet_status - -) - status in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByStatus" in + let headers = Request.default_headers in + let uri = + Request.add_query_param_list uri "status" + (Stdlib.List.map Enums.show_pet_status) + status + in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let find_pets_by_tags ~tags = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByTags" in - let headers = Request.default_headers in - let uri = Request.add_query_param_list uri "tags" (Stdlib.List.map - - - - - - - - - (fun x -> x) - - - - -) - - - - - - - - - - - - - tags in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByTags" in + let headers = Request.default_headers in + let uri = + Request.add_query_param_list uri "tags" (Stdlib.List.map (fun x -> x)) tags + in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let get_pet_by_id ~pet_id = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let update_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Pet.to_yojson - - - - pet_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Pet.to_yojson pet_t in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let update_pet_with_form ~pet_id ?name ?status () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - let body = Request.init_form_encoded_body () in - let body = Request.maybe_add_form_encoded_body_param body "name" - - - - - - - - - (fun x -> x) - - - - - name in - let body = Request.maybe_add_form_encoded_body_param body "status" - - - - - - - - - (fun x -> x) - - - - - status in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + let body = Request.init_form_encoded_body () in + let body = + Request.maybe_add_form_encoded_body_param body "name" (fun x -> x) name + in + let body = + Request.maybe_add_form_encoded_body_param body "status" (fun x -> x) status + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let upload_file ~pet_id ?additional_metadata ?file () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}/uploadImage" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string - - - - - - - - - - - - - - pet_id in - let body = Request.init_form_encoded_body () in - let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" - - - - - - - - - (fun x -> x) - - - - - additional_metadata in - let body = Request.maybe_add_form_encoded_body_param body "file" - - - - - - (fun x -> x) - - - - - - - - file in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}/uploadImage" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in + let body = Request.init_form_encoded_body () in + let body = + Request.maybe_add_form_encoded_body_param body "additional_metadata" + (fun x -> x) + additional_metadata + in + let body = + Request.maybe_add_form_encoded_body_param body "file" (fun x -> x) file + in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as + (JsonSupport.unwrap Api_response.of_yojson) + resp body diff --git a/samples/client/petstore/ocaml/src/apis/pet_api.mli b/samples/client/petstore/ocaml/src/apis/pet_api.mli index c52ae12f1202..6a36f1df74bb 100644 --- a/samples/client/petstore/ocaml/src/apis/pet_api.mli +++ b/samples/client/petstore/ocaml/src/apis/pet_api.mli @@ -11,5 +11,13 @@ val find_pets_by_status : status:Enums.pet_status list -> Pet.t list Lwt.t val find_pets_by_tags : tags:string list -> Pet.t list Lwt.t val get_pet_by_id : pet_id:int64 -> Pet.t Lwt.t val update_pet : pet_t:Pet.t -> Pet.t Lwt.t -val update_pet_with_form : pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t -val upload_file : pet_id:int64 -> ?additional_metadata:string -> ?file:string -> unit -> Api_response.t Lwt.t + +val update_pet_with_form : + pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t + +val upload_file : + pet_id:int64 -> + ?additional_metadata:string -> + ?file:string -> + unit -> + Api_response.t Lwt.t diff --git a/samples/client/petstore/ocaml/src/apis/store_api.ml b/samples/client/petstore/ocaml/src/apis/store_api.ml index 510e9ea48325..25e0561d13d3 100644 --- a/samples/client/petstore/ocaml/src/apis/store_api.ml +++ b/samples/client/petstore/ocaml/src/apis/store_api.ml @@ -6,76 +6,33 @@ *) let delete_order ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{orderId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "orderId" - - - - - - - - - (fun x -> x) - - - - - order_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{orderId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "orderId" (fun x -> x) order_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_inventory () = - let open Lwt.Infix in - let uri = Request.build_uri "/store/inventory" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_map_of (JsonSupport.to_int32) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/inventory" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_map_of JsonSupport.to_int32 resp body let get_order_by_id ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{orderId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "orderId" Int64.to_string - - - - - - - - - - - - - - order_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{orderId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "orderId" Int64.to_string order_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body let place_order ~order_t = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order" in - let headers = Request.default_headers in - let body = Request. - - write_as_json_body - - - - - - - Order.to_yojson - - - - order_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body - + let open Lwt.Infix in + let uri = Request.build_uri "/store/order" in + let headers = Request.default_headers in + let body = Request.write_as_json_body Order.to_yojson order_t in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body diff --git a/samples/client/petstore/ocaml/src/apis/user_api.ml b/samples/client/petstore/ocaml/src/apis/user_api.ml index d034b4b22851..3202ec0291d2 100644 --- a/samples/client/petstore/ocaml/src/apis/user_api.ml +++ b/samples/client/petstore/ocaml/src/apis/user_api.ml @@ -6,201 +6,76 @@ *) let create_user ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let body = Request. - - write_as_json_body - - - - - - - User.to_yojson - - - - user_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let body = Request.write_as_json_body User.to_yojson user_t in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_array_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithArray" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let body = Request. - - write_as_json_body (JsonSupport.of_list_of - - - - - - - User.to_yojson - - - -) - user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithArray" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let body = + Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_list_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithList" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let body = Request. - - write_as_json_body (JsonSupport.of_list_of - - - - - - - User.to_yojson - - - -) - user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithList" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let body = + Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let delete_user ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "username" (fun x -> x) username in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_user_by_name ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" (fun x -> x) username in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body let login_user ~username ~password = - let open Lwt.Infix in - let uri = Request.build_uri "/user/login" in - let headers = Request.default_headers in - let uri = Request.add_query_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - let uri = Request.add_query_param uri "password" - - - - - - - - - (fun x -> x) - - - - - password in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.to_string) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/login" in + let headers = Request.default_headers in + let uri = Request.add_query_param uri "username" (fun x -> x) username in + let uri = Request.add_query_param uri "password" (fun x -> x) password in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as JsonSupport.to_string resp body let logout_user () = - let open Lwt.Infix in - let uri = Request.build_uri "/user/logout" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/logout" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let update_user ~username ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "username" - - - - - - - - - (fun x -> x) - - - - - username in - let body = Request. - - write_as_json_body - - - - - - - User.to_yojson - - - - user_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp - + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "username" (fun x -> x) username in + let body = Request.write_as_json_body User.to_yojson user_t in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp diff --git a/samples/client/petstore/ocaml/src/models/api_response.ml b/samples/client/petstore/ocaml/src/models/api_response.ml index b2a6f6824638..a261e879691a 100644 --- a/samples/client/petstore/ocaml/src/models/api_response.ml +++ b/samples/client/petstore/ocaml/src/models/api_response.ml @@ -6,35 +6,12 @@ * Schema Api_response.t : Describes the result of uploading an image resource *) +type t = { + code : int32 option; [@default None] [@key "code"] + _type : string option; [@default None] [@key "type"] + message : string option; [@default None] [@key "message"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - code: int32 - - option [@default None] - - - ; [@key "code"] - _type: string - - option [@default None] - - - ; [@key "type"] - message: string - - option [@default None] - - - ; [@key "message"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** Describes the result of uploading an image resource *) - let create () : t = { - code = None; - _type = None; - message = None; - } - - +(** Describes the result of uploading an image resource *) +let create () : t = { code = None; _type = None; message = None } diff --git a/samples/client/petstore/ocaml/src/models/category.ml b/samples/client/petstore/ocaml/src/models/category.ml index cb63d1c6ff83..7b6ea140558e 100644 --- a/samples/client/petstore/ocaml/src/models/category.ml +++ b/samples/client/petstore/ocaml/src/models/category.ml @@ -6,28 +6,11 @@ * Schema Category.t : A category for a pet *) +type t = { + id : int64 option; [@default None] [@key "id"] + name : string option; [@default None] [@key "name"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - name: string - - option [@default None] - - - ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** A category for a pet *) - let create () : t = { - id = None; - name = None; - } - - +(** A category for a pet *) +let create () : t = { id = None; name = None } diff --git a/samples/client/petstore/ocaml/src/models/inline_object.ml b/samples/client/petstore/ocaml/src/models/inline_object.ml index 37a44a8d6835..90970779f5a5 100644 --- a/samples/client/petstore/ocaml/src/models/inline_object.ml +++ b/samples/client/petstore/ocaml/src/models/inline_object.ml @@ -6,14 +6,11 @@ *) type t = { - (* Updated name of the pet *) - name: string option [@default None]; - (* Updated status of the pet *) - status: string option [@default None]; -} [@@deriving yojson { strict = false }, show ];; - -let create () : t = { - name = None; - status = None; + (* Updated name of the pet *) + name : string option; [@default None] + (* Updated status of the pet *) + status : string option; [@default None] } +[@@deriving yojson { strict = false }, show] +let create () : t = { name = None; status = None } diff --git a/samples/client/petstore/ocaml/src/models/inline_object_1.ml b/samples/client/petstore/ocaml/src/models/inline_object_1.ml index 2d453134c439..893ae9b6b989 100644 --- a/samples/client/petstore/ocaml/src/models/inline_object_1.ml +++ b/samples/client/petstore/ocaml/src/models/inline_object_1.ml @@ -6,14 +6,11 @@ *) type t = { - (* Additional data to pass to server *) - additional_metadata: string option [@default None]; - (* file to upload *) - file: string option [@default None]; -} [@@deriving yojson { strict = false }, show ];; - -let create () : t = { - additional_metadata = None; - file = None; + (* Additional data to pass to server *) + additional_metadata : string option; [@default None] + (* file to upload *) + file : string option; [@default None] } +[@@deriving yojson { strict = false }, show] +let create () : t = { additional_metadata = None; file = None } diff --git a/samples/client/petstore/ocaml/src/models/order.ml b/samples/client/petstore/ocaml/src/models/order.ml index 3e4e63cda43d..b661dfa06b60 100644 --- a/samples/client/petstore/ocaml/src/models/order.ml +++ b/samples/client/petstore/ocaml/src/models/order.ml @@ -6,57 +6,24 @@ * Schema Order.t : An order for a pets from the pet store *) +type t = { + id : int64 option; [@default None] [@key "id"] + pet_id : int64 option; [@default None] [@key "petId"] + quantity : int32 option; [@default None] [@key "quantity"] + ship_date : string option; [@default None] [@key "shipDate"] + (* Order Status *) + status : Enums.status option; [@default None] [@key "status"] + complete : bool option; [@default None] [@key "complete"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - pet_id: int64 - - option [@default None] - - - ; [@key "petId"] - quantity: int32 - - option [@default None] - - - ; [@key "quantity"] - ship_date: string - - option [@default None] - - - ; [@key "shipDate"] - (* Order Status *) - status: Enums.status - option [@default - - None - ] - ; [@key "status"] - complete: bool - - option [@default None] - - - ; [@key "complete"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** An order for a pets from the pet store *) - let create () : t = { - id = None; - pet_id = None; - quantity = None; - ship_date = None; - status = None; - complete = None; - } - - +(** An order for a pets from the pet store *) +let create () : t = + { + id = None; + pet_id = None; + quantity = None; + ship_date = None; + status = None; + complete = None; + } diff --git a/samples/client/petstore/ocaml/src/models/pet.ml b/samples/client/petstore/ocaml/src/models/pet.ml index af5288538870..bfeff9aa3aaa 100644 --- a/samples/client/petstore/ocaml/src/models/pet.ml +++ b/samples/client/petstore/ocaml/src/models/pet.ml @@ -6,53 +6,16 @@ * Schema Pet.t : A pet for sale in the pet store *) +type t = { + id : int64 option; [@default None] [@key "id"] + category : Category.t option; [@default None] [@key "category"] + name : string; [@key "name"] + photo_urls : string list; [@key "photoUrls"] + tags : Tag.t list; [@default []] [@key "tags"] (* pet status in the store *) + status : Enums.pet_status option; [@default None] [@key "status"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - category: Category.t - - option [@default None] - - - ; [@key "category"] - name: string - - - - - ; [@key "name"] - photo_urls: string list - - - ; [@key "photoUrls"] - tags: Tag.t list - [@default []] - - ; [@key "tags"] - (* pet status in the store *) - status: Enums.pet_status - option [@default - - None - ] - ; [@key "status"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** A pet for sale in the pet store *) - let create (name : string) (photo_urls : string list) : t = { - id = None; - category = None; - name = name; - photo_urls = photo_urls; - tags = []; - status = None; - } - - +(** A pet for sale in the pet store *) +let create (name : string) (photo_urls : string list) : t = + { id = None; category = None; name; photo_urls; tags = []; status = None } diff --git a/samples/client/petstore/ocaml/src/models/tag.ml b/samples/client/petstore/ocaml/src/models/tag.ml index 8a4cd6418109..92ddc86c19d9 100644 --- a/samples/client/petstore/ocaml/src/models/tag.ml +++ b/samples/client/petstore/ocaml/src/models/tag.ml @@ -6,28 +6,11 @@ * Schema Tag.t : A tag for a pet *) +type t = { + id : int64 option; [@default None] [@key "id"] + name : string option; [@default None] [@key "name"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - name: string - - option [@default None] - - - ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** A tag for a pet *) - let create () : t = { - id = None; - name = None; - } - - +(** A tag for a pet *) +let create () : t = { id = None; name = None } diff --git a/samples/client/petstore/ocaml/src/models/user.ml b/samples/client/petstore/ocaml/src/models/user.ml index 4f79bf2b71c0..e52dd96561bc 100644 --- a/samples/client/petstore/ocaml/src/models/user.ml +++ b/samples/client/petstore/ocaml/src/models/user.ml @@ -6,71 +6,28 @@ * Schema User.t : A User who is purchasing from the pet store *) +type t = { + id : int64 option; [@default None] [@key "id"] + username : string option; [@default None] [@key "username"] + first_name : string option; [@default None] [@key "firstName"] + last_name : string option; [@default None] [@key "lastName"] + email : string option; [@default None] [@key "email"] + password : string option; [@default None] [@key "password"] + phone : string option; [@default None] [@key "phone"] + (* User Status *) + user_status : int32 option; [@default None] [@key "userStatus"] +} +[@@deriving yojson { strict = false }, show, eq] - - - type t = { - id: int64 - - option [@default None] - - - ; [@key "id"] - username: string - - option [@default None] - - - ; [@key "username"] - first_name: string - - option [@default None] - - - ; [@key "firstName"] - last_name: string - - option [@default None] - - - ; [@key "lastName"] - email: string - - option [@default None] - - - ; [@key "email"] - password: string - - option [@default None] - - - ; [@key "password"] - phone: string - - option [@default None] - - - ; [@key "phone"] - (* User Status *) - user_status: int32 - - option [@default None] - - - ; [@key "userStatus"] - } [@@deriving yojson { strict = false }, show, eq ];; - - (** A User who is purchasing from the pet store *) - let create () : t = { - id = None; - username = None; - first_name = None; - last_name = None; - email = None; - password = None; - phone = None; - user_status = None; - } - - +(** A User who is purchasing from the pet store *) +let create () : t = + { + id = None; + username = None; + first_name = None; + last_name = None; + email = None; + password = None; + phone = None; + user_status = None; + } diff --git a/samples/client/petstore/ocaml/src/support/enums.ml b/samples/client/petstore/ocaml/src/support/enums.ml index 4e4c2d61edc0..e93e6430e667 100644 --- a/samples/client/petstore/ocaml/src/support/enums.ml +++ b/samples/client/petstore/ocaml/src/support/enums.ml @@ -5,26 +5,36 @@ * *) -type status = [ -| `Placed [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] [@name "placed"] -| `Approved [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] [@name "approved"] -| `Delivered [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] [@name "delivered"] -] [@@deriving yojson, show { with_path = false }, eq];; +type status = + [ `Placed + [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] + [@name "placed"] + | `Approved + [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] + [@name "approved"] + | `Delivered + [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] + [@name "delivered"] ] +[@@deriving yojson, show { with_path = false }, eq] + +let status_of_yojson json = status_of_yojson (`List [ json ]) -let status_of_yojson json = status_of_yojson (`List [json]) let status_to_yojson e = - match status_to_yojson e with - | `List [json] -> json - | json -> json + match status_to_yojson e with `List [ json ] -> json | json -> json + +type pet_status = + [ `Available + [@printer fun fmt _ -> Format.pp_print_string fmt "available"] + [@name "available"] + | `Pending + [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] + [@name "pending"] + | `Sold + [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] + [@name "sold"] ] +[@@deriving yojson, show { with_path = false }, eq] -type pet_status = [ -| `Available [@printer fun fmt _ -> Format.pp_print_string fmt "available"] [@name "available"] -| `Pending [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] [@name "pending"] -| `Sold [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] [@name "sold"] -] [@@deriving yojson, show { with_path = false }, eq];; +let pet_status_of_yojson json = pet_status_of_yojson (`List [ json ]) -let pet_status_of_yojson json = pet_status_of_yojson (`List [json]) let pet_status_to_yojson e = - match pet_status_to_yojson e with - | `List [json] -> json - | json -> json + match pet_status_to_yojson e with `List [ json ] -> json | json -> json diff --git a/samples/client/petstore/ocaml/src/support/jsonSupport.ml b/samples/client/petstore/ocaml/src/support/jsonSupport.ml index 0af0c25e759a..9b4d882c3c12 100644 --- a/samples/client/petstore/ocaml/src/support/jsonSupport.ml +++ b/samples/client/petstore/ocaml/src/support/jsonSupport.ml @@ -1,68 +1,55 @@ open Ppx_deriving_yojson_runtime let unwrap to_json json = - match to_json json with - | Result.Ok json -> json - | Result.Error s -> failwith s + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s let to_int json = - match json with - | `Int x -> x - | `Intlit s -> int_of_string s - | _ -> failwith "JsonSupport.to_int" + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" let to_bool json = - match json with - | `Bool x -> x - | _ -> failwith "JsonSupport.to_bool" + match json with `Bool x -> x | _ -> failwith "JsonSupport.to_bool" let to_float json = - match json with - | `Float x -> x - | _ -> failwith "JsonSupport.to_float" + match json with `Float x -> x | _ -> failwith "JsonSupport.to_float" let to_string json = - match json with - | `String s -> s - | _ -> failwith "JsonSupport.to_string" + match json with `String s -> s | _ -> failwith "JsonSupport.to_string" let to_int32 json : int32 = - match json with - | `Int x -> Int32.of_int x - | `Intlit s -> Int32.of_string s - | _ -> failwith "JsonSupport.to_int32" + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" let to_int64 json : int64 = - match json with - | `Int x -> Int64.of_int x - | `Intlit s -> Int64.of_string s - | _ -> failwith "JsonSupport.to_int64" + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" let of_int x = `Int x - let of_bool b = `Bool b - let of_float x = `Float x - let of_string s = `String s - let of_int32 x = `Intlit (Int32.to_string x) - let of_int64 x = `Intlit (Int64.to_string x) - let of_list_of of_f l = `List (Stdlib.List.map of_f l) - let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) let to_map_of of_f json = match json with | `Assoc l -> - Stdlib.List.fold_right - (fun (k, json) acc -> - match (of_f json, acc) with - | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> - Stdlib.Result.Ok ((k, parsed_v) :: tl) - | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e - | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) - l (Stdlib.Result.Ok []) + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml/src/support/request.ml b/samples/client/petstore/ocaml/src/support/request.ml index fea945d04cf3..cc8a0fba248a 100644 --- a/samples/client/petstore/ocaml/src/support/request.ml +++ b/samples/client/petstore/ocaml/src/support/request.ml @@ -1,16 +1,9 @@ let api_key = "" let base_url = "http://petstore.swagger.io/v2" let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" - -let option_fold f default o = - match o with - | Some v -> f v - | None -> default - +let option_fold f default o = match o with Some v -> f v | None -> default let build_uri operation_path = Uri.of_string (base_url ^ operation_path) - -let add_string_header headers key value = - Cohttp.Header.add headers key value +let add_string_header headers key value = Cohttp.Header.add headers key value let add_string_header_multi headers key values = Cohttp.Header.add_multi headers key values @@ -37,13 +30,16 @@ let write_as_json_body to_json payload = write_json_body (to_json payload) let handle_response resp on_success_handler = match Cohttp.Response.status resp with | #Cohttp.Code.success_status -> on_success_handler () - | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + | s -> + failwith + ("Server responded with status " + ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) let read_json_body resp body = handle_response resp (fun () -> - (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) + Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string)) let read_json_body_as of_json resp body = Lwt.(read_json_body resp body >|= of_json) @@ -58,11 +54,15 @@ let read_json_body_as_map resp body = Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) let read_json_body_as_map_of of_json resp body = - Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + Lwt.( + read_json_body_as_map resp body + >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) let replace_string_path_param uri param_name param_value = let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in - let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in + let path = + Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) + in Uri.with_path uri path let replace_path_param uri param_name to_string param_value = @@ -85,26 +85,33 @@ let maybe_add_query_param uri param_name to_string param_value = - [explode = true] - type [object] - See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters + See + https://swagger.io/docs/specification/v3_0/serialization/#query-parameters *) let add_query_param_exploded_form_object uri _param_name to_string param_value = -Stdlib.List.fold_left - (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) - uri - param_value + Stdlib.List.fold_left + (fun uri (param_name, param_value) -> + add_query_param uri param_name to_string param_value) + uri param_value let init_form_encoded_body () = "" let add_form_encoded_body_param params param_name to_string param_value = - let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in - if params = "" - then new_param_enc + let new_param_enc = + Printf.sprintf {|%s=%s|} + (Uri.pct_encode param_name) + (Uri.pct_encode (to_string param_value)) + in + if params = "" then new_param_enc else Printf.sprintf {|%s&%s|} params new_param_enc let add_form_encoded_body_param_list params param_name to_string new_params = - add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) + add_form_encoded_body_param params param_name (String.concat ",") + (to_string new_params) let maybe_add_form_encoded_body_param params param_name to_string param_value = - option_fold (add_form_encoded_body_param params param_name to_string) params param_value + option_fold + (add_form_encoded_body_param params param_name to_string) + params param_value let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body From 6c690c389aebf18ca4983feda53733f6fc015f8e Mon Sep 17 00:00:00 2001 From: Julien Debon Date: Mon, 25 Aug 2025 17:52:02 +0200 Subject: [PATCH 3/4] Don't format in Git --- .github/workflows/samples-ocaml.yaml | 3 - .../client/petstore/ocaml-fake-petstore/dune | 16 +- .../src/apis/another_fake_api.ml | 27 +- .../src/apis/default_api.ml | 13 +- .../ocaml-fake-petstore/src/apis/fake_api.ml | 1285 ++++++++++++----- .../ocaml-fake-petstore/src/apis/fake_api.mli | 96 +- .../src/apis/fake_classname_tags123_api.ml | 29 +- .../ocaml-fake-petstore/src/apis/pet_api.ml | 396 +++-- .../ocaml-fake-petstore/src/apis/pet_api.mli | 20 +- .../ocaml-fake-petstore/src/apis/store_api.ml | 93 +- .../ocaml-fake-petstore/src/apis/user_api.ml | 231 ++- .../src/models/additional_properties_class.ml | 33 +- .../src/models/all_of_with_single_ref.ml | 32 +- .../ocaml-fake-petstore/src/models/animal.ml | 29 +- .../src/models/api_response.ml | 39 +- .../models/array_of_array_of_number_only.ml | 19 +- .../src/models/array_of_number_only.ml | 17 +- .../src/models/array_test.ml | 38 +- .../src/models/capitalization.ml | 72 +- .../ocaml-fake-petstore/src/models/cat.ml | 38 +- .../src/models/category.ml | 29 +- .../src/models/child_with_nullable.ml | 39 +- .../src/models/class_model.ml | 21 +- .../ocaml-fake-petstore/src/models/client.ml | 19 +- .../src/models/deprecated_object.ml | 19 +- .../ocaml-fake-petstore/src/models/dog.ml | 38 +- .../src/models/enum_arrays.ml | 25 +- .../src/models/enum_test.ml | 88 +- .../fake_big_decimal_map_200_response.ml | 31 +- .../ocaml-fake-petstore/src/models/file.ml | 25 +- .../src/models/file_schema_test_class.ml | 27 +- .../ocaml-fake-petstore/src/models/foo.ml | 19 +- .../src/models/format_test.ml | 166 ++- .../src/models/has_only_read_only.ml | 29 +- .../src/models/health_check_result.ml | 24 +- .../ocaml-fake-petstore/src/models/list.ml | 19 +- .../src/models/map_test.ml | 54 +- ...perties_and_additional_properties_class.ml | 39 +- .../src/models/model_200_response.ml | 31 +- .../models/model__foo_get_default_response.ml | 19 +- .../src/models/model__special_model_name_.ml | 22 +- .../ocaml-fake-petstore/src/models/name.ml | 48 +- .../src/models/nullable_class.ml | 126 +- .../src/models/number_only.ml | 19 +- .../models/object_with_deprecated_fields.ml | 44 +- .../ocaml-fake-petstore/src/models/order.ml | 71 +- .../src/models/outer_composite.ml | 39 +- .../models/outer_object_with_enum_property.ml | 19 +- .../src/models/parent_with_nullable.ml | 32 +- .../ocaml-fake-petstore/src/models/pet.ml | 59 +- .../src/models/read_only_first.ml | 29 +- .../ocaml-fake-petstore/src/models/return.ml | 21 +- .../ocaml-fake-petstore/src/models/tag.ml | 29 +- ..._freeform_additional_properties_request.ml | 19 +- .../ocaml-fake-petstore/src/models/user.ml | 89 +- .../ocaml-fake-petstore/src/support/enums.ml | 287 ++-- .../src/support/jsonSupport.ml | 65 +- .../src/support/request.ml | 53 +- samples/client/petstore/ocaml-oneOf/dune | 16 +- .../ocaml-oneOf/src/apis/default_api.ml | 11 +- .../petstore/ocaml-oneOf/src/models/child.ml | 19 +- .../ocaml-oneOf/src/models/example.ml | 58 +- .../ocaml-oneOf/src/support/jsonSupport.ml | 65 +- .../ocaml-oneOf/src/support/request.ml | 53 +- samples/client/petstore/ocaml/dune | 16 +- .../client/petstore/ocaml/src/apis/pet_api.ml | 321 +++- .../petstore/ocaml/src/apis/pet_api.mli | 12 +- .../petstore/ocaml/src/apis/store_api.ml | 91 +- .../petstore/ocaml/src/apis/user_api.ml | 243 +++- .../petstore/ocaml/src/models/api_response.ml | 39 +- .../petstore/ocaml/src/models/category.ml | 31 +- .../client/petstore/ocaml/src/models/order.ml | 73 +- .../client/petstore/ocaml/src/models/pet.ml | 61 +- .../client/petstore/ocaml/src/models/tag.ml | 31 +- .../client/petstore/ocaml/src/models/user.ml | 91 +- .../petstore/ocaml/src/support/enums.ml | 46 +- .../petstore/ocaml/src/support/jsonSupport.ml | 65 +- .../petstore/ocaml/src/support/request.ml | 53 +- 78 files changed, 3997 insertions(+), 1756 deletions(-) diff --git a/.github/workflows/samples-ocaml.yaml b/.github/workflows/samples-ocaml.yaml index 718acf39d95e..9206c578d893 100644 --- a/.github/workflows/samples-ocaml.yaml +++ b/.github/workflows/samples-ocaml.yaml @@ -35,6 +35,3 @@ jobs: - name: Build run: opam exec -- dune build working-directory: ${{ matrix.sample }} - - name: Check formatting - run: opam exec -- dune fmt - working-directory: ${{ matrix.sample }} diff --git a/samples/client/petstore/ocaml-fake-petstore/dune b/samples/client/petstore/ocaml-fake-petstore/dune index d10b1d1a5075..ed1c4d90e3df 100644 --- a/samples/client/petstore/ocaml-fake-petstore/dune +++ b/samples/client/petstore/ocaml-fake-petstore/dune @@ -1,11 +1,9 @@ (include_subdirs unqualified) - (library - (name petstore_client) - (public_name petstore_client) - (flags - (:standard -w -27)) - (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) - (preprocess - (pps ppx_deriving_yojson ppx_deriving.std)) - (wrapped true)) + (name petstore_client) + (public_name petstore_client) + (flags (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true) +) \ No newline at end of file diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml index f421d17f609a..8e40a663d9be 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml @@ -6,9 +6,24 @@ *) let call_123_test_special_tags ~client_t = - let open Lwt.Infix in - let uri = Request.build_uri "/another-fake/dummy" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Client.to_yojson client_t in - Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/another-fake/dummy" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Client.to_yojson + + + + client_t + in + Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml index 65b79273bfba..0184891735dd 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/default_api.ml @@ -6,10 +6,9 @@ *) let foo_get () = - let open Lwt.Infix in - let uri = Request.build_uri "/foo" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Model__foo_get_default_response.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/foo" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Model__foo_get_default_response.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml index fac126b8a8b6..7dd18fe3ceb2 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml @@ -6,368 +6,997 @@ *) let fake_big_decimal_map () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/BigDecimalMap" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Fake_big_decimal_map_200_response.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/BigDecimalMap" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Fake_big_decimal_map_200_response.of_yojson) resp body let fake_health_get () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/health" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Health_check_result.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/health" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Health_check_result.of_yojson) resp body let fake_http_signature_test ~pet_t ?query_1 ?header_1 () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/http-signature-test" in - let headers = Request.default_headers in - let headers = - Request.maybe_add_header headers "header_1" (fun x -> x) header_1 - in - let uri = Request.maybe_add_query_param uri "query_1" (fun x -> x) query_1 in - let body = Request.write_as_json_body Pet.to_yojson pet_t in - Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/http-signature-test" in + let headers = Request.default_headers in + let headers = Request.maybe_add_header headers "header_1" + + + + + + + + + (fun x -> x) + + + + + header_1 in + let uri = Request.maybe_add_query_param uri "query_1" + + + + + + + + + (fun x -> x) + + + + + query_1 in + let body = Request. + + write_as_json_body + + + + + + + Pet.to_yojson + + + + pet_t + in + Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let fake_outer_boolean_serialize ~body () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/boolean" in - let headers = Request.default_headers in - let body = Request.write_as_json_body JsonSupport.of_bool body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as JsonSupport.to_bool resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/boolean" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + JsonSupport.of_bool + + + + body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.to_bool) resp body let fake_outer_composite_serialize ~outer_composite_t () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/composite" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body Outer_composite.to_yojson outer_composite_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Outer_composite.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/composite" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Outer_composite.to_yojson + + + + outer_composite_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Outer_composite.of_yojson) resp body let fake_outer_number_serialize ~body () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/number" in - let headers = Request.default_headers in - let body = Request.write_as_json_body JsonSupport.of_float body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as JsonSupport.to_float resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/number" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + JsonSupport.of_float + + + + + + body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.to_float) resp body let fake_outer_string_serialize ~body () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/outer/string" in - let headers = Request.default_headers in - let body = Request.write_as_json_body JsonSupport.of_string body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as JsonSupport.to_string resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/outer/string" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body JsonSupport.of_string + + + + + + + + + + body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.to_string) resp body let fake_property_enum_integer_serialize ~outer_object_with_enum_property_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/property/enum-int" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body Outer_object_with_enum_property.to_yojson - outer_object_with_enum_property_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Outer_object_with_enum_property.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake/property/enum-int" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Outer_object_with_enum_property.to_yojson + + + + outer_object_with_enum_property_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Outer_object_with_enum_property.of_yojson) resp body let test_additional_properties_reference ~request_body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/additionalProperties-reference" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body (JsonSupport.of_map_of (fun x -> x)) request_body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/additionalProperties-reference" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body (JsonSupport.of_map_of + + + + + + + + (fun x -> x) + +) + request_body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_body_with_binary ~body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/body-with-binary" in - let headers = Request.default_headers in - let body = Request.write_as_json_body JsonSupport.of_string body in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/body-with-binary" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + JsonSupport.of_string + + + body + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_body_with_file_schema ~file_schema_test_class_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/body-with-file-schema" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body File_schema_test_class.to_yojson - file_schema_test_class_t - in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/body-with-file-schema" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + File_schema_test_class.to_yojson + + + + file_schema_test_class_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_body_with_query_params ~query ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/body-with-query-params" in - let headers = Request.default_headers in - let uri = Request.add_query_param uri "query" (fun x -> x) query in - let body = Request.write_as_json_body User.to_yojson user_t in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/body-with-query-params" in + let headers = Request.default_headers in + let uri = Request.add_query_param uri "query" + + + + + + + + + (fun x -> x) + + + + + query in + let body = Request. + + write_as_json_body + + + + + + + User.to_yojson + + + + user_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_client_model ~client_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Client.to_yojson client_t in - Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Client.to_yojson + + + + client_t + in + Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body -let test_endpoint_parameters ~number ~double ~pattern_without_delimiter ~byte - ?integer ?int32 ?int64 ?float ?string ?binary ?date ?date_time ?password - ?callback () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let body = Request.init_form_encoded_body () in - let body = - Request.maybe_add_form_encoded_body_param body "integer" Int32.to_string - integer - in - let body = - Request.maybe_add_form_encoded_body_param body "int32" Int32.to_string int32 - in - let body = - Request.maybe_add_form_encoded_body_param body "int64" Int64.to_string int64 - in - let body = - Request.add_form_encoded_body_param body "number" string_of_float number - in - let body = - Request.maybe_add_form_encoded_body_param body "float" string_of_float float - in - let body = - Request.add_form_encoded_body_param body "double" string_of_float double - in - let body = - Request.maybe_add_form_encoded_body_param body "string" (fun x -> x) string - in - let body = - Request.add_form_encoded_body_param body "pattern_without_delimiter" - (fun x -> x) - pattern_without_delimiter - in - let body = - Request.add_form_encoded_body_param body "byte" (fun x -> x) byte - in - let body = - Request.maybe_add_form_encoded_body_param body "binary" (fun x -> x) binary - in - let body = - Request.maybe_add_form_encoded_body_param body "date" (fun x -> x) date - in - let body = - Request.maybe_add_form_encoded_body_param body "date_time" - (fun x -> x) - date_time - in - let body = - Request.maybe_add_form_encoded_body_param body "password" - (fun x -> x) - password - in - let body = - Request.maybe_add_form_encoded_body_param body "callback" - (fun x -> x) - callback - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_endpoint_parameters ~number ~double ~pattern_without_delimiter ~byte ?integer ?int32 ?int64 ?float ?string ?binary ?date ?date_time ?password ?callback () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let body = Request.init_form_encoded_body () in + let body = Request.maybe_add_form_encoded_body_param body "integer" + Int32.to_string + + + + + + + + + + + + + integer in + let body = Request.maybe_add_form_encoded_body_param body "int32" + Int32.to_string + + + + + + + + + + + + + int32 in + let body = Request.maybe_add_form_encoded_body_param body "int64" Int64.to_string + + + + + + + + + + + + + + int64 in + let body = Request.add_form_encoded_body_param body "number" + + + string_of_float + + + + + + + + + + + number in + let body = Request.maybe_add_form_encoded_body_param body "float" + + string_of_float + + + + + + + + + + + + float in + let body = Request.add_form_encoded_body_param body "double" + + + + string_of_float + + + + + + + + + + double in + let body = Request.maybe_add_form_encoded_body_param body "string" + + + + + + + + + (fun x -> x) + + + + + string in + let body = Request.add_form_encoded_body_param body "pattern_without_delimiter" + + + + + + + + + (fun x -> x) + + + + + pattern_without_delimiter in + let body = Request.add_form_encoded_body_param body "byte" + + + + + + + + + + (fun x -> x) + + + + byte in + let body = Request.maybe_add_form_encoded_body_param body "binary" + + + + + + (fun x -> x) + + + + + + + + binary in + let body = Request.maybe_add_form_encoded_body_param body "date" + + + + + + + (fun x -> x) + + + + + + + date in + let body = Request.maybe_add_form_encoded_body_param body "date_time" + + + + + + + + (fun x -> x) + + + + + + date_time in + let body = Request.maybe_add_form_encoded_body_param body "password" + + + + + + + + + (fun x -> x) + + + + + password in + let body = Request.maybe_add_form_encoded_body_param body "callback" + + + + + + + + + (fun x -> x) + + + + + callback in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_enum_parameters ?(enum_header_string_array = []) - ?(enum_header_string = `Minusefg) ?(enum_query_string_array = []) - ?(enum_query_string = `Minusefg) ?enum_query_integer ?enum_query_double - ?(enum_query_model_array = []) ?(enum_form_string_array = [ `Dollar ]) - ?(enum_form_string = `Minusefg) () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let headers = - Request.add_header_multi headers "enum_header_string_array" - (Stdlib.List.map Enums.show_enum_form_string_array) - enum_header_string_array - in - let headers = - Request.add_header headers "enum_header_string" Enums.show_enumclass - enum_header_string - in - let uri = - Request.add_query_param_list uri "enum_query_string_array" - (Stdlib.List.map Enums.show_enum_form_string_array) - enum_query_string_array - in - let uri = - Request.add_query_param uri "enum_query_string" Enums.show_enumclass - enum_query_string - in - let uri = - Request.maybe_add_query_param uri "enum_query_integer" - Enums.show_enum_query_integer enum_query_integer - in - let uri = - Request.maybe_add_query_param uri "enum_query_double" Enums.show_enum_number - enum_query_double - in - let uri = - Request.add_query_param_list uri "enum_query_model_array" - (Stdlib.List.map (failwith "Unsupported: enum reference")) - enum_query_model_array - in - let body = Request.init_form_encoded_body () in - let body = - Request.add_form_encoded_body_param_list body "enum_form_string_array" - (Stdlib.List.map Enums.show_enum_form_string_array) - enum_form_string_array - in - let body = - Request.add_form_encoded_body_param body "enum_form_string" - Enums.show_enumclass enum_form_string - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_enum_parameters ?(enum_header_string_array = []) ?(enum_header_string = `Minusefg) ?(enum_query_string_array = []) ?(enum_query_string = `Minusefg) ?enum_query_integer ?enum_query_double ?(enum_query_model_array = []) ?(enum_form_string_array = [`Dollar]) ?(enum_form_string = `Minusefg) () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let headers = Request.add_header_multi headers "enum_header_string_array" (Stdlib.List.map Enums.show_enum_form_string_array + +) + enum_header_string_array in + let headers = Request.add_header headers "enum_header_string" Enums.show_enumclass + + enum_header_string in + let uri = Request.add_query_param_list uri "enum_query_string_array" (Stdlib.List.map Enums.show_enum_form_string_array + +) + enum_query_string_array in + let uri = Request.add_query_param uri "enum_query_string" Enums.show_enumclass + + enum_query_string in + let uri = Request.maybe_add_query_param uri "enum_query_integer" Enums.show_enum_query_integer + + enum_query_integer in + let uri = Request.maybe_add_query_param uri "enum_query_double" Enums.show_enum_number + + enum_query_double in + let uri = Request.add_query_param_list uri "enum_query_model_array" (Stdlib.List.map + + + + + + + + + + + + + (failwith "Unsupported: enum reference") +) + + + + + + + + + + + + + enum_query_model_array in + let body = Request.init_form_encoded_body () in + let body = Request.add_form_encoded_body_param_list body "enum_form_string_array" (Stdlib.List.map Enums.show_enum_form_string_array + +) + enum_form_string_array in + let body = Request.add_form_encoded_body_param body "enum_form_string" Enums.show_enumclass + + enum_form_string in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_group_parameters ~required_string_group ~required_boolean_group - ~required_int64_group ?string_group ?boolean_group ?int64_group () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake" in - let headers = Request.default_headers in - let headers = - Request.add_header headers "required_boolean_group" string_of_bool - required_boolean_group - in - let headers = - Request.maybe_add_header headers "boolean_group" string_of_bool - boolean_group - in - let uri = - Request.add_query_param uri "required_string_group" Int32.to_string - required_string_group - in - let uri = - Request.add_query_param uri "required_int64_group" Int64.to_string - required_int64_group - in - let uri = - Request.maybe_add_query_param uri "string_group" Int32.to_string - string_group - in - let uri = - Request.maybe_add_query_param uri "int64_group" Int64.to_string int64_group - in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_group_parameters ~required_string_group ~required_boolean_group ~required_int64_group ?string_group ?boolean_group ?int64_group () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake" in + let headers = Request.default_headers in + let headers = Request.add_header headers "required_boolean_group" + + + + + string_of_bool + + + + + + + + + required_boolean_group in + let headers = Request.maybe_add_header headers "boolean_group" + + + + + string_of_bool + + + + + + + + + boolean_group in + let uri = Request.add_query_param uri "required_string_group" + Int32.to_string + + + + + + + + + + + + + required_string_group in + let uri = Request.add_query_param uri "required_int64_group" Int64.to_string + + + + + + + + + + + + + + required_int64_group in + let uri = Request.maybe_add_query_param uri "string_group" + Int32.to_string + + + + + + + + + + + + + string_group in + let uri = Request.maybe_add_query_param uri "int64_group" Int64.to_string + + + + + + + + + + + + + + int64_group in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let test_inline_additional_properties ~request_body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/inline-additionalProperties" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body - (JsonSupport.of_map_of JsonSupport.of_string) - request_body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/inline-additionalProperties" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body (JsonSupport.of_map_of JsonSupport.of_string + + + + + + + + + +) + request_body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_inline_freeform_additional_properties - ~test_inline_freeform_additional_properties_request_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/inline-freeform-additionalProperties" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body - Test_inline_freeform_additional_properties_request.to_yojson - test_inline_freeform_additional_properties_request_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_inline_freeform_additional_properties ~test_inline_freeform_additional_properties_request_t = + let open Lwt.Infix in + let uri = Request.build_uri "/fake/inline-freeform-additionalProperties" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Test_inline_freeform_additional_properties_request.to_yojson + + + + test_inline_freeform_additional_properties_request_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_json_form_data ~param ~param2 = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/jsonFormData" in - let headers = Request.default_headers in - let body = Request.init_form_encoded_body () in - let body = - Request.add_form_encoded_body_param body "param" (fun x -> x) param - in - let body = - Request.add_form_encoded_body_param body "param2" (fun x -> x) param2 - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/jsonFormData" in + let headers = Request.default_headers in + let body = Request.init_form_encoded_body () in + let body = Request.add_form_encoded_body_param body "param" + + + + + + + + + (fun x -> x) + + + + + param in + let body = Request.add_form_encoded_body_param body "param2" + + + + + + + + + (fun x -> x) + + + + + param2 in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let test_nullable ~child_with_nullable_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/nullable" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body Child_with_nullable.to_yojson - child_with_nullable_t - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/nullable" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Child_with_nullable.to_yojson + + + + child_with_nullable_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp -let test_query_parameter_collection_format ~pipe ~ioutil ~http ~url ~context - ~allow_empty ?(language = []) () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/test-query-parameters" in - let headers = Request.default_headers in - let uri = - Request.add_query_param_list uri "pipe" (Stdlib.List.map (fun x -> x)) pipe - in - let uri = - Request.add_query_param_list uri "ioutil" - (Stdlib.List.map (fun x -> x)) - ioutil - in - let uri = - Request.add_query_param_list uri "http" (Stdlib.List.map (fun x -> x)) http - in - let uri = - Request.add_query_param_list uri "url" (Stdlib.List.map (fun x -> x)) url - in - let uri = - Request.add_query_param_list uri "context" - (Stdlib.List.map (fun x -> x)) - context - in - let uri = - Request.add_query_param_exploded_form_object uri "language" - (fun x -> x) - language - in - let uri = Request.add_query_param uri "allowEmpty" (fun x -> x) allow_empty in - Cohttp_lwt_unix.Client.call `PUT uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp +let test_query_parameter_collection_format ~pipe ~ioutil ~http ~url ~context ~allow_empty ?(language = []) () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake/test-query-parameters" in + let headers = Request.default_headers in + let uri = Request.add_query_param_list uri "pipe" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + pipe in + let uri = Request.add_query_param_list uri "ioutil" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + ioutil in + let uri = Request.add_query_param_list uri "http" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + http in + let uri = Request.add_query_param_list uri "url" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + url in + let uri = Request.add_query_param_list uri "context" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + context in + let uri = Request.add_query_param_exploded_form_object uri "language" + + + + + + + + + + (fun x -> x) + + + + + + + + + + + + + + + + + + language in + let uri = Request.add_query_param uri "allowEmpty" + + + + + + + + + (fun x -> x) + + + + + allow_empty in + Cohttp_lwt_unix.Client.call `PUT uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let test_string_map_reference ~request_body = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/stringMap-reference" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body - (JsonSupport.of_map_of JsonSupport.of_string) - request_body - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/fake/stringMap-reference" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body (JsonSupport.of_map_of JsonSupport.of_string + + + + + + + + + +) + request_body + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli index b8d835f83f66..259a66dd29e0 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.mli @@ -7,95 +7,23 @@ val fake_big_decimal_map : unit -> Fake_big_decimal_map_200_response.t Lwt.t val fake_health_get : unit -> Health_check_result.t Lwt.t - -val fake_http_signature_test : - pet_t:Pet.t -> ?query_1:string -> ?header_1:string -> unit -> unit Lwt.t - +val fake_http_signature_test : pet_t:Pet.t -> ?query_1:string -> ?header_1:string -> unit -> unit Lwt.t val fake_outer_boolean_serialize : body:bool -> unit -> bool Lwt.t - -val fake_outer_composite_serialize : - outer_composite_t:Outer_composite.t -> unit -> Outer_composite.t Lwt.t - +val fake_outer_composite_serialize : outer_composite_t:Outer_composite.t -> unit -> Outer_composite.t Lwt.t val fake_outer_number_serialize : body:float -> unit -> float Lwt.t val fake_outer_string_serialize : body:string -> unit -> string Lwt.t - -val fake_property_enum_integer_serialize : - outer_object_with_enum_property_t:Outer_object_with_enum_property.t -> - Outer_object_with_enum_property.t Lwt.t - -val test_additional_properties_reference : - request_body:(string * Yojson.Safe.t) list -> unit Lwt.t - +val fake_property_enum_integer_serialize : outer_object_with_enum_property_t:Outer_object_with_enum_property.t -> Outer_object_with_enum_property.t Lwt.t +val test_additional_properties_reference : request_body:(string * Yojson.Safe.t) list -> unit Lwt.t val test_body_with_binary : body:string -> unit Lwt.t - -val test_body_with_file_schema : - file_schema_test_class_t:File_schema_test_class.t -> unit Lwt.t - +val test_body_with_file_schema : file_schema_test_class_t:File_schema_test_class.t -> unit Lwt.t val test_body_with_query_params : query:string -> user_t:User.t -> unit Lwt.t val test_client_model : client_t:Client.t -> Client.t Lwt.t - -val test_endpoint_parameters : - number:float -> - double:float -> - pattern_without_delimiter:string -> - byte:string -> - ?integer:int32 -> - ?int32:int32 -> - ?int64:int64 -> - ?float:float -> - ?string:string -> - ?binary:string -> - ?date:string -> - ?date_time:string -> - ?password:string -> - ?callback:string -> - unit -> - unit Lwt.t - -val test_enum_parameters : - ?enum_header_string_array:Enums.enum_form_string_array list -> - ?enum_header_string:Enums.enumclass -> - ?enum_query_string_array:Enums.enum_form_string_array list -> - ?enum_query_string:Enums.enumclass -> - ?enum_query_integer:Enums.enum_query_integer -> - ?enum_query_double:Enums.enum_number -> - ?enum_query_model_array:Enums.enumclass list -> - ?enum_form_string_array:Enums.enum_form_string_array list -> - ?enum_form_string:Enums.enumclass -> - unit -> - unit Lwt.t - -val test_group_parameters : - required_string_group:int32 -> - required_boolean_group:bool -> - required_int64_group:int64 -> - ?string_group:int32 -> - ?boolean_group:bool -> - ?int64_group:int64 -> - unit -> - unit Lwt.t - -val test_inline_additional_properties : - request_body:(string * string) list -> unit Lwt.t - -val test_inline_freeform_additional_properties : - test_inline_freeform_additional_properties_request_t: - Test_inline_freeform_additional_properties_request.t -> - unit Lwt.t - +val test_endpoint_parameters : number:float -> double:float -> pattern_without_delimiter:string -> byte:string -> ?integer:int32 -> ?int32:int32 -> ?int64:int64 -> ?float:float -> ?string:string -> ?binary:string -> ?date:string -> ?date_time:string -> ?password:string -> ?callback:string -> unit -> unit Lwt.t +val test_enum_parameters : ?enum_header_string_array:Enums.enum_form_string_array list -> ?enum_header_string:Enums.enumclass -> ?enum_query_string_array:Enums.enum_form_string_array list -> ?enum_query_string:Enums.enumclass -> ?enum_query_integer:Enums.enum_query_integer -> ?enum_query_double:Enums.enum_number -> ?enum_query_model_array:Enums.enumclass list -> ?enum_form_string_array:Enums.enum_form_string_array list -> ?enum_form_string:Enums.enumclass -> unit -> unit Lwt.t +val test_group_parameters : required_string_group:int32 -> required_boolean_group:bool -> required_int64_group:int64 -> ?string_group:int32 -> ?boolean_group:bool -> ?int64_group:int64 -> unit -> unit Lwt.t +val test_inline_additional_properties : request_body:(string * string) list -> unit Lwt.t +val test_inline_freeform_additional_properties : test_inline_freeform_additional_properties_request_t:Test_inline_freeform_additional_properties_request.t -> unit Lwt.t val test_json_form_data : param:string -> param2:string -> unit Lwt.t val test_nullable : child_with_nullable_t:Child_with_nullable.t -> unit Lwt.t - -val test_query_parameter_collection_format : - pipe:string list -> - ioutil:string list -> - http:string list -> - url:string list -> - context:string list -> - allow_empty:string -> - ?language:(string * string) list -> - unit -> - unit Lwt.t - -val test_string_map_reference : - request_body:(string * string) list -> unit Lwt.t +val test_query_parameter_collection_format : pipe:string list -> ioutil:string list -> http:string list -> url:string list -> context:string list -> allow_empty:string -> ?language:(string * string) list -> unit -> unit Lwt.t +val test_string_map_reference : request_body:(string * string) list -> unit Lwt.t diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml index 14bbcdda6505..5eb1391914f8 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml @@ -6,10 +6,25 @@ *) let test_classname ~client_t = - let open Lwt.Infix in - let uri = Request.build_uri "/fake_classname_test" in - let headers = Request.default_headers in - let uri = Uri.add_query_param' uri ("api_key_query", Request.api_key) in - let body = Request.write_as_json_body Client.to_yojson client_t in - Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/fake_classname_test" in + let headers = Request.default_headers in + let uri = Uri.add_query_param' uri ("api_key_query", Request.api_key) in + let body = Request. + + write_as_json_body + + + + + + + Client.to_yojson + + + + client_t + in + Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml index 6cbf1c1fae3f..95637700510d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml @@ -6,118 +6,314 @@ *) let add_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Pet.to_yojson pet_t in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Pet.to_yojson + + + + pet_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let delete_pet ~pet_id ?api_key () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = - Request.maybe_add_header headers "api_key" (fun x -> x) api_key - in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = Request.maybe_add_header headers "api_key" + + + + + + + + + (fun x -> x) + + + + + api_key in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let find_pets_by_status ~status = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByStatus" in - let headers = Request.default_headers in - let uri = - Request.add_query_param_list uri "status" - (Stdlib.List.map Enums.show_status) - status - in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByStatus" in + let headers = Request.default_headers in + let uri = Request.add_query_param_list uri "status" (Stdlib.List.map Enums.show_status + +) + status in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let find_pets_by_tags ~tags = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByTags" in - let headers = Request.default_headers in - let uri = - Request.add_query_param_list uri "tags" (Stdlib.List.map (fun x -> x)) tags - in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByTags" in + let headers = Request.default_headers in + let uri = Request.add_query_param_list uri "tags" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + tags in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let get_pet_by_id ~pet_id = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let update_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Pet.to_yojson pet_t in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Pet.to_yojson + + + + pet_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let update_pet_with_form ~pet_id ?name ?status () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - let body = Request.init_form_encoded_body () in - let body = - Request.maybe_add_form_encoded_body_param body "name" (fun x -> x) name - in - let body = - Request.maybe_add_form_encoded_body_param body "status" (fun x -> x) status - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + let body = Request.init_form_encoded_body () in + let body = Request.maybe_add_form_encoded_body_param body "name" + + + + + + + + + (fun x -> x) + + + + + name in + let body = Request.maybe_add_form_encoded_body_param body "status" + + + + + + + + + (fun x -> x) + + + + + status in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let upload_file ~pet_id ?additional_metadata ?file () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}/uploadImage" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - let body = Request.init_form_encoded_body () in - let body = - Request.maybe_add_form_encoded_body_param body "additional_metadata" - (fun x -> x) - additional_metadata - in - let body = - Request.maybe_add_form_encoded_body_param body "file" (fun x -> x) file - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Api_response.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}/uploadImage" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + let body = Request.init_form_encoded_body () in + let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" + + + + + + + + + (fun x -> x) + + + + + additional_metadata in + let body = Request.maybe_add_form_encoded_body_param body "file" + + + + + + (fun x -> x) + + + + + + + + file in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body + +let upload_file_with_required_file ~pet_id ~required_file ?additional_metadata () = + let open Lwt.Infix in + let uri = Request.build_uri "/fake/{petId}/uploadImageWithRequiredFile" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + let body = Request.init_form_encoded_body () in + let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" + + + + + + + + + (fun x -> x) + + + + + additional_metadata in + let body = Request.add_form_encoded_body_param body "required_file" + + + + + + (fun x -> x) + + + + + + + + required_file in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body -let upload_file_with_required_file ~pet_id ~required_file ?additional_metadata - () = - let open Lwt.Infix in - let uri = Request.build_uri "/fake/{petId}/uploadImageWithRequiredFile" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - let body = Request.init_form_encoded_body () in - let body = - Request.maybe_add_form_encoded_body_param body "additional_metadata" - (fun x -> x) - additional_metadata - in - let body = - Request.add_form_encoded_body_param body "required_file" - (fun x -> x) - required_file - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Api_response.of_yojson) - resp body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli index 786d33e787f3..f0aa4208b358 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.mli @@ -11,20 +11,6 @@ val find_pets_by_status : status:Enums.status list -> Pet.t list Lwt.t val find_pets_by_tags : tags:string list -> Pet.t list Lwt.t val get_pet_by_id : pet_id:int64 -> Pet.t Lwt.t val update_pet : pet_t:Pet.t -> unit Lwt.t - -val update_pet_with_form : - pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t - -val upload_file : - pet_id:int64 -> - ?additional_metadata:string -> - ?file:string -> - unit -> - Api_response.t Lwt.t - -val upload_file_with_required_file : - pet_id:int64 -> - required_file:string -> - ?additional_metadata:string -> - unit -> - Api_response.t Lwt.t +val update_pet_with_form : pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t +val upload_file : pet_id:int64 -> ?additional_metadata:string -> ?file:string -> unit -> Api_response.t Lwt.t +val upload_file_with_required_file : pet_id:int64 -> required_file:string -> ?additional_metadata:string -> unit -> Api_response.t Lwt.t diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml index 459578fe49d2..96c52f9b9ed7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/store_api.ml @@ -6,35 +6,76 @@ *) let delete_order ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{order_id}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "order_id" (fun x -> x) order_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{order_id}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "order_id" + + + + + + + + + (fun x -> x) + + + + + order_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_inventory () = - let open Lwt.Infix in - let uri = Request.build_uri "/store/inventory" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_map_of JsonSupport.to_int32 resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/inventory" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_map_of (JsonSupport.to_int32) resp body let get_order_by_id ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{order_id}" in - let headers = Request.default_headers in - let uri = - Request.replace_path_param uri "order_id" Int64.to_string order_id - in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{order_id}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "order_id" Int64.to_string + + + + + + + + + + + + + + order_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body let place_order ~order_t = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Order.to_yojson order_t in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/order" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Order.to_yojson + + + + order_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml b/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml index 6e8f74f19024..c5f913e57a30 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml @@ -6,70 +6,195 @@ *) let create_user ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user" in - let headers = Request.default_headers in - let body = Request.write_as_json_body User.to_yojson user_t in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + User.to_yojson + + + + user_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_array_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithArray" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithArray" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body (JsonSupport.of_list_of + + + + + + + User.to_yojson + + + +) + user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_list_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithList" in - let headers = Request.default_headers in - let body = - Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithList" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body (JsonSupport.of_list_of + + + + + + + User.to_yojson + + + +) + user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let delete_user ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" (fun x -> x) username in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_user_by_name ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" (fun x -> x) username in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body let login_user ~username ~password = - let open Lwt.Infix in - let uri = Request.build_uri "/user/login" in - let headers = Request.default_headers in - let uri = Request.add_query_param uri "username" (fun x -> x) username in - let uri = Request.add_query_param uri "password" (fun x -> x) password in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as JsonSupport.to_string resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/login" in + let headers = Request.default_headers in + let uri = Request.add_query_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + let uri = Request.add_query_param uri "password" + + + + + + + + + (fun x -> x) + + + + + password in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.to_string) resp body let logout_user () = - let open Lwt.Infix in - let uri = Request.build_uri "/user/logout" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/logout" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let update_user ~username ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" (fun x -> x) username in - let body = Request.write_as_json_body User.to_yojson user_t in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + let body = Request. + + write_as_json_body + + + + + + + User.to_yojson + + + + user_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml index 9548cf7f824d..1070136f5dec 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml @@ -5,18 +5,23 @@ * *) -type t = { - map_property : (string * string) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] - [@key "map_property"] - map_of_map_property : (string * (string * string) list) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] - [@key "map_of_map_property"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { map_property = []; map_of_map_property = [] } + + + type t = { + map_property: (string * string) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] + ; [@key "map_property"] + map_of_map_property: (string * (string * string) list) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] + ; [@key "map_of_map_property"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + map_property = []; + map_of_map_property = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml index fe5a1957ad61..8824bf45851d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml @@ -5,11 +5,27 @@ * *) -type t = { - username : string option; [@default None] [@key "username"] - single_ref_type : Enums.singlereftype option; - [@default None] [@key "SingleRefType"] -} -[@@deriving yojson { strict = false }, show, eq] - -let create () : t = { username = None; single_ref_type = None } + + + + type t = { + username: string + + option [@default None] + + + ; [@key "username"] + single_ref_type: Enums.singlereftype + + option [@default None] + + + ; [@key "SingleRefType"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + username = None; + single_ref_type = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml index 235d96870ad7..bb9694548e1e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml @@ -5,10 +5,27 @@ * *) -type t = { - class_name : string; [@key "className"] - color : string option; [@default None] [@key "color"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (class_name : string) : t = { class_name; color = None } + + + type t = { + class_name: string + + + + + ; [@key "className"] + color: string + + option [@default None] + + + ; [@key "color"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (class_name : string) : t = { + class_name = class_name; + color = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml index 461249d759b4..38c83657c392 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml @@ -5,11 +5,34 @@ * *) -type t = { - code : int32 option; [@default None] [@key "code"] - _type : string option; [@default None] [@key "type"] - message : string option; [@default None] [@key "message"] -} -[@@deriving yojson { strict = false }, show, eq] - -let create () : t = { code = None; _type = None; message = None } + + + + type t = { + code: int32 + + option [@default None] + + + ; [@key "code"] + _type: string + + option [@default None] + + + ; [@key "type"] + message: string + + option [@default None] + + + ; [@key "message"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + code = None; + _type = None; + message = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml index c45ec72c3160..17d2b550a3dc 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml @@ -5,9 +5,18 @@ * *) -type t = { - array_array_number : float list list; [@default []] [@key "ArrayArrayNumber"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { array_array_number = [] } + + + type t = { + array_array_number: float list list + [@default []] + + ; [@key "ArrayArrayNumber"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + array_array_number = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml index 9dd6ebd5b828..e4ea0cc597d1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml @@ -5,7 +5,18 @@ * *) -type t = { array_number : float list [@default []] [@key "ArrayNumber"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { array_number = [] } + + + type t = { + array_number: float list + [@default []] + + ; [@key "ArrayNumber"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + array_number = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml index 70d4d2fccfc8..850e8d6d7197 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml @@ -5,18 +5,28 @@ * *) -type t = { - array_of_string : string list; [@default []] [@key "array_of_string"] - array_array_of_integer : int64 list list; - [@default []] [@key "array_array_of_integer"] - array_array_of_model : Read_only_first.t list list; - [@default []] [@key "array_array_of_model"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { - array_of_string = []; - array_array_of_integer = []; - array_array_of_model = []; - } + + + type t = { + array_of_string: string list + [@default []] + + ; [@key "array_of_string"] + array_array_of_integer: int64 list list + [@default []] + + ; [@key "array_array_of_integer"] + array_array_of_model: Read_only_first.t list list + [@default []] + + ; [@key "array_array_of_model"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + array_of_string = []; + array_array_of_integer = []; + array_array_of_model = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml index 0fbe5becf357..2725a870b917 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml @@ -5,24 +5,56 @@ * *) -type t = { - small_camel : string option; [@default None] [@key "smallCamel"] - capital_camel : string option; [@default None] [@key "CapitalCamel"] - small_snake : string option; [@default None] [@key "small_Snake"] - capital_snake : string option; [@default None] [@key "Capital_Snake"] - sca_eth_flow_points : string option; - [@default None] [@key "SCA_ETH_Flow_Points"] - (* Name of the pet *) - att_name : string option; [@default None] [@key "ATT_NAME"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { - small_camel = None; - capital_camel = None; - small_snake = None; - capital_snake = None; - sca_eth_flow_points = None; - att_name = None; - } + + + type t = { + small_camel: string + + option [@default None] + + + ; [@key "smallCamel"] + capital_camel: string + + option [@default None] + + + ; [@key "CapitalCamel"] + small_snake: string + + option [@default None] + + + ; [@key "small_Snake"] + capital_snake: string + + option [@default None] + + + ; [@key "Capital_Snake"] + sca_eth_flow_points: string + + option [@default None] + + + ; [@key "SCA_ETH_Flow_Points"] + (* Name of the pet *) + att_name: string + + option [@default None] + + + ; [@key "ATT_NAME"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + small_camel = None; + capital_camel = None; + small_snake = None; + capital_snake = None; + sca_eth_flow_points = None; + att_name = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml index 63fe5e4ea66f..d9dcd55ac0af 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml @@ -5,12 +5,34 @@ * *) -type t = { - class_name : string; [@key "className"] - color : string option; [@default None] [@key "color"] - declawed : bool option; [@default None] [@key "declawed"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (class_name : string) : t = - { class_name; color = None; declawed = None } + + + type t = { + class_name: string + + + + + ; [@key "className"] + color: string + + option [@default None] + + + ; [@key "color"] + declawed: bool + + option [@default None] + + + ; [@key "declawed"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (class_name : string) : t = { + class_name = class_name; + color = None; + declawed = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml index fb57d9078918..95e0b50ee994 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml @@ -5,10 +5,27 @@ * *) -type t = { - id : int64 option; [@default None] [@key "id"] - name : string; [@key "name"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (name : string) : t = { id = None; name } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + name: string + + + + + ; [@key "name"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (name : string) : t = { + id = None; + name = name; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml index d791fa513c0b..61eba92d86ce 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml @@ -5,13 +5,34 @@ * *) -type t = { - _type : Enums.parentwithnullable_type option; - [@default Some `ChildWithNullable] [@key "type"] - nullable_property : string option; [@default None] [@key "nullableProperty"] - other_property : string option; [@default None] [@key "otherProperty"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { _type = None; nullable_property = None; other_property = None } + + + type t = { + _type: Enums.parentwithnullable_type + option [@default + Some(`ChildWithNullable) + + ] + ; [@key "type"] + nullable_property: string + + option [@default None] + + + ; [@key "nullableProperty"] + other_property: string + + option [@default None] + + + ; [@key "otherProperty"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + _type = None; + nullable_property = None; + other_property = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml index 979fe4f45ca7..f63be054b150 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml @@ -6,8 +6,21 @@ * Schema Class_model.t : Model for testing model with \''_class\'' property *) -type t = { _class : string option [@default None] [@key "_class"] } -[@@deriving yojson { strict = false }, show, eq] -(** Model for testing model with \''_class\'' property *) -let create () : t = { _class = None } + + + type t = { + _class: string + + option [@default None] + + + ; [@key "_class"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Model for testing model with \''_class\'' property *) + let create () : t = { + _class = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml index 66e50db036a1..d3b578e2509f 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml @@ -5,7 +5,20 @@ * *) -type t = { client : string option [@default None] [@key "client"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { client = None } + + + type t = { + client: string + + option [@default None] + + + ; [@key "client"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + client = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml index a33f47aed2e9..ff9a12f2eb4d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml @@ -5,7 +5,20 @@ * *) -type t = { name : string option [@default None] [@key "name"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { name = None } + + + type t = { + name: string + + option [@default None] + + + ; [@key "name"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + name = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml index 0621e75c12dc..004e9bb56406 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml @@ -5,12 +5,34 @@ * *) -type t = { - class_name : string; [@key "className"] - color : string option; [@default None] [@key "color"] - breed : string option; [@default None] [@key "breed"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (class_name : string) : t = - { class_name; color = None; breed = None } + + + type t = { + class_name: string + + + + + ; [@key "className"] + color: string + + option [@default None] + + + ; [@key "color"] + breed: string + + option [@default None] + + + ; [@key "breed"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (class_name : string) : t = { + class_name = class_name; + color = None; + breed = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml index 6bd89813af6a..612cdf25beba 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml @@ -5,10 +5,23 @@ * *) -type t = { - just_symbol : Enums.just_symbol option; [@default None] [@key "just_symbol"] - array_enum : Enums.array_enum list; [@key "array_enum"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { just_symbol = None; array_enum = [] } + + + type t = { + just_symbol: Enums.just_symbol + option [@default + + None + ] + ; [@key "just_symbol"] + array_enum: Enums.array_enum list +; [@key "array_enum"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + just_symbol = None; + array_enum = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml index d390d986175e..e9df9f2fec4e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml @@ -5,30 +5,66 @@ * *) -type t = { - enum_string : Enums.enum_string option; [@default None] [@key "enum_string"] - enum_string_required : Enums.enum_string; [@key "enum_string_required"] - enum_integer : Enums.enum_integer option; - [@default None] [@key "enum_integer"] - enum_number : Enums.enum_number option; [@default None] [@key "enum_number"] - outer_enum : Enums.order_status option; [@default None] [@key "outerEnum"] - outer_enum_integer : Enums.outerenuminteger option; - [@default None] [@key "outerEnumInteger"] - outer_enum_default_value : Enums.order_status option; - [@default None] [@key "outerEnumDefaultValue"] - outer_enum_integer_default_value : Enums.outerenuminteger option; - [@default None] [@key "outerEnumIntegerDefaultValue"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (enum_string_required : Enums.enum_string) : t = - { - enum_string = None; - enum_string_required; - enum_integer = None; - enum_number = None; - outer_enum = None; - outer_enum_integer = None; - outer_enum_default_value = None; - outer_enum_integer_default_value = None; - } + + + type t = { + enum_string: Enums.enum_string + option [@default + + None + ] + ; [@key "enum_string"] + enum_string_required: Enums.enum_string + + ; [@key "enum_string_required"] + enum_integer: Enums.enum_integer + option [@default + + None + ] + ; [@key "enum_integer"] + enum_number: Enums.enum_number + option [@default + + None + ] + ; [@key "enum_number"] + outer_enum: Enums.order_status + + option [@default None] + + + ; [@key "outerEnum"] + outer_enum_integer: Enums.outerenuminteger + + option [@default None] + + + ; [@key "outerEnumInteger"] + outer_enum_default_value: Enums.order_status + + option [@default None] + + + ; [@key "outerEnumDefaultValue"] + outer_enum_integer_default_value: Enums.outerenuminteger + + option [@default None] + + + ; [@key "outerEnumIntegerDefaultValue"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (enum_string_required : Enums.enum_string) : t = { + enum_string = None; + enum_string_required = enum_string_required; + enum_integer = None; + enum_number = None; + outer_enum = None; + outer_enum_integer = None; + outer_enum_default_value = None; + outer_enum_integer_default_value = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml index e4b59b0d1540..6abba727a131 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml @@ -5,14 +5,25 @@ * *) -type t = { - some_id : float option; [@default None] [@key "someId"] - some_map : (string * float) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: float]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: float]] - [@key "someMap"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { some_id = None; some_map = [] } + + + type t = { + some_id: float + + option [@default None] + + + ; [@key "someId"] + some_map: (string * float) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: float]] [@of_yojson JsonSupport.to_map_of [%of_yojson: float]] + ; [@key "someMap"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + some_id = None; + some_map = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml index 56659a378665..e02dec2b6bde 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml @@ -6,11 +6,22 @@ * Schema File.t : Must be named `File` for test. *) -type t = { - (* Test capitalization *) - source_uri : string option; [@default None] [@key "sourceURI"] -} -[@@deriving yojson { strict = false }, show, eq] -(** Must be named `File` for test. *) -let create () : t = { source_uri = None } + + + type t = { + (* Test capitalization *) + source_uri: string + + option [@default None] + + + ; [@key "sourceURI"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Must be named `File` for test. *) + let create () : t = { + source_uri = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml index be5000e9a080..e9bb0b52c6b6 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml @@ -5,10 +5,25 @@ * *) -type t = { - file : File.t option; [@default None] [@key "file"] - files : File.t list; [@default []] [@key "files"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { file = None; files = [] } + + + type t = { + file: File.t + + option [@default None] + + + ; [@key "file"] + files: File.t list + [@default []] + + ; [@key "files"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + file = None; + files = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml index 2914c782f1b6..a3f48385e0d7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml @@ -5,7 +5,20 @@ * *) -type t = { bar : string option [@default None] [@key "bar"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { bar = None } + + + type t = { + bar: string + + option [@default None] + + + ; [@key "bar"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + bar = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml index 9602d17da10b..03631a54e643 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml @@ -5,47 +5,127 @@ * *) -type t = { - integer : int32 option; [@default None] [@key "integer"] - int32 : int32 option; [@default None] [@key "int32"] - int64 : int64 option; [@default None] [@key "int64"] - number : float; [@key "number"] - float : float option; [@default None] [@key "float"] - double : float option; [@default None] [@key "double"] - decimal : string option; [@default None] [@key "decimal"] - string : string option; [@default None] [@key "string"] - byte : string; [@key "byte"] - binary : string option; [@default None] [@key "binary"] - date : string; [@key "date"] - date_time : string option; [@default None] [@key "dateTime"] - uuid : string option; [@default None] [@key "uuid"] - password : string; [@key "password"] - (* A string that is a 10 digit number. Can have leading zeros. *) - pattern_with_digits : string option; - [@default None] [@key "pattern_with_digits"] - (* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. *) - pattern_with_digits_and_delimiter : string option; - [@default None] [@key "pattern_with_digits_and_delimiter"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (number : float) (byte : string) (date : string) (password : string) - : t = - { - integer = None; - int32 = None; - int64 = None; - number; - float = None; - double = None; - decimal = None; - string = None; - byte; - binary = None; - date; - date_time = None; - uuid = None; - password; - pattern_with_digits = None; - pattern_with_digits_and_delimiter = None; - } + + + type t = { + integer: int32 + + option [@default None] + + + ; [@key "integer"] + int32: int32 + + option [@default None] + + + ; [@key "int32"] + int64: int64 + + option [@default None] + + + ; [@key "int64"] + number: float + + + + + ; [@key "number"] + float: float + + option [@default None] + + + ; [@key "float"] + double: float + + option [@default None] + + + ; [@key "double"] + decimal: string + + option [@default None] + + + ; [@key "decimal"] + string: string + + option [@default None] + + + ; [@key "string"] + byte: string + + + + + ; [@key "byte"] + binary: string + + option [@default None] + + + ; [@key "binary"] + date: string + + + + + ; [@key "date"] + date_time: string + + option [@default None] + + + ; [@key "dateTime"] + uuid: string + + option [@default None] + + + ; [@key "uuid"] + password: string + + + + + ; [@key "password"] + (* A string that is a 10 digit number. Can have leading zeros. *) + pattern_with_digits: string + + option [@default None] + + + ; [@key "pattern_with_digits"] + (* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. *) + pattern_with_digits_and_delimiter: string + + option [@default None] + + + ; [@key "pattern_with_digits_and_delimiter"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (number : float) (byte : string) (date : string) (password : string) : t = { + integer = None; + int32 = None; + int64 = None; + number = number; + float = None; + double = None; + decimal = None; + string = None; + byte = byte; + binary = None; + date = date; + date_time = None; + uuid = None; + password = password; + pattern_with_digits = None; + pattern_with_digits_and_delimiter = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml index ba67253836d1..cebf14ba37f9 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml @@ -5,10 +5,27 @@ * *) -type t = { - bar : string option; [@default None] [@key "bar"] - foo : string option; [@default None] [@key "foo"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { bar = None; foo = None } + + + type t = { + bar: string + + option [@default None] + + + ; [@key "bar"] + foo: string + + option [@default None] + + + ; [@key "foo"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + bar = None; + foo = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml index 73c38dc2e21a..b58d7cd6cfeb 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml @@ -6,11 +6,21 @@ * Schema Health_check_result.t : Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. *) -type t = { - nullable_message : string option; [@default None] [@key "NullableMessage"] -} -[@@deriving yojson { strict = false }, show, eq] -(** Just a string to inform instance is up and running. Make it nullable in hope - to get it as pointer in generated model. *) -let create () : t = { nullable_message = None } + + + type t = { + nullable_message: string + + option [@default None] + + + ; [@key "NullableMessage"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. *) + let create () : t = { + nullable_message = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml index efa83eac1340..13e71de7e641 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml @@ -5,7 +5,20 @@ * *) -type t = { var_123_list : string option [@default None] [@key "123-list"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { var_123_list = None } + + + type t = { + var_123_list: string + + option [@default None] + + + ; [@key "123-list"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + var_123_list = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml index a52060401c35..22a05cd8e6d1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml @@ -5,31 +5,31 @@ * *) -type t = { - map_map_of_string : (string * (string * string) list) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] - [@key "map_map_of_string"] - map_of_enum_string : (string * Enums.map_of_enum_string) list; - [@key "map_of_enum_string"] - direct_map : (string * bool) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] - [@key "direct_map"] - indirect_map : (string * bool) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] - [@key "indirect_map"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { - map_map_of_string = []; - map_of_enum_string = []; - direct_map = []; - indirect_map = []; - } + + + type t = { + map_map_of_string: (string * (string * string) list) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] + ; [@key "map_map_of_string"] + map_of_enum_string: (string * Enums.map_of_enum_string) list +; [@key "map_of_enum_string"] + direct_map: (string * bool) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] + ; [@key "direct_map"] + indirect_map: (string * bool) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] + ; [@key "indirect_map"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + map_map_of_string = []; + map_of_enum_string = []; + direct_map = []; + indirect_map = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml index 4e410c224ee7..b3c6cedecc23 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml @@ -5,15 +5,32 @@ * *) -type t = { - uuid : string option; [@default None] [@key "uuid"] - date_time : string option; [@default None] [@key "dateTime"] - map : (string * Animal.t) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: Animal.t]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: Animal.t]] - [@key "map"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { uuid = None; date_time = None; map = [] } + + + type t = { + uuid: string + + option [@default None] + + + ; [@key "uuid"] + date_time: string + + option [@default None] + + + ; [@key "dateTime"] + map: (string * Animal.t) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Animal.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Animal.t]] + ; [@key "map"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + uuid = None; + date_time = None; + map = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml index 6ed73fd52846..06031bb76b08 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml @@ -6,11 +6,28 @@ * Schema Model_200_response.t : Model for testing model name starting with number *) -type t = { - name : int32 option; [@default None] [@key "name"] - _class : string option; [@default None] [@key "class"] -} -[@@deriving yojson { strict = false }, show, eq] -(** Model for testing model name starting with number *) -let create () : t = { name = None; _class = None } + + + type t = { + name: int32 + + option [@default None] + + + ; [@key "name"] + _class: string + + option [@default None] + + + ; [@key "class"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Model for testing model name starting with number *) + let create () : t = { + name = None; + _class = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml index fe553a89fb78..3231ca32596c 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml @@ -5,7 +5,20 @@ * *) -type t = { string : Foo.t option [@default None] [@key "string"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { string = None } + + + type t = { + string: Foo.t + + option [@default None] + + + ; [@key "string"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + string = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml index 92857fe3b57e..ae3b926c52b1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml @@ -5,10 +5,20 @@ * *) -type t = { - special_property_name : int64 option; - [@default None] [@key "$special[property.name]"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { special_property_name = None } + + + type t = { + special_property_name: int64 + + option [@default None] + + + ; [@key "$special[property.name]"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + special_property_name = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml index 8a99873c31ef..4b1861ea51ad 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml @@ -6,14 +6,42 @@ * Schema Name.t : Model for testing model name same as property name *) -type t = { - name : int32; [@key "name"] - snake_case : int32 option; [@default None] [@key "snake_case"] - property : string option; [@default None] [@key "property"] - var_123_number : int32 option; [@default None] [@key "123Number"] -} -[@@deriving yojson { strict = false }, show, eq] -(** Model for testing model name same as property name *) -let create (name : int32) : t = - { name; snake_case = None; property = None; var_123_number = None } + + + type t = { + name: int32 + + + + + ; [@key "name"] + snake_case: int32 + + option [@default None] + + + ; [@key "snake_case"] + property: string + + option [@default None] + + + ; [@key "property"] + var_123_number: int32 + + option [@default None] + + + ; [@key "123Number"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Model for testing model name same as property name *) + let create (name : int32) : t = { + name = name; + snake_case = None; + property = None; + var_123_number = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml index d00f8f718fe3..690eb51db5e7 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml @@ -5,49 +5,85 @@ * *) -type t = { - integer_prop : int32 option; [@default None] [@key "integer_prop"] - number_prop : float option; [@default None] [@key "number_prop"] - boolean_prop : bool option; [@default None] [@key "boolean_prop"] - string_prop : string option; [@default None] [@key "string_prop"] - date_prop : string option; [@default None] [@key "date_prop"] - datetime_prop : string option; [@default None] [@key "datetime_prop"] - array_nullable_prop : Yojson.Safe.t list; - [@default []] [@key "array_nullable_prop"] - array_and_items_nullable_prop : Yojson.Safe.t list; - [@default []] [@key "array_and_items_nullable_prop"] - array_items_nullable : Yojson.Safe.t list; - [@default []] [@key "array_items_nullable"] - object_nullable_prop : (string * Yojson.Safe.t) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] - [@key "object_nullable_prop"] - object_and_items_nullable_prop : (string * Yojson.Safe.t) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] - [@key "object_and_items_nullable_prop"] - object_items_nullable : (string * Yojson.Safe.t) list; - [@default []] - [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] - [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] - [@key "object_items_nullable"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { - integer_prop = None; - number_prop = None; - boolean_prop = None; - string_prop = None; - date_prop = None; - datetime_prop = None; - array_nullable_prop = []; - array_and_items_nullable_prop = []; - array_items_nullable = []; - object_nullable_prop = []; - object_and_items_nullable_prop = []; - object_items_nullable = []; - } + + + type t = { + integer_prop: int32 + + option [@default None] + + + ; [@key "integer_prop"] + number_prop: float + + option [@default None] + + + ; [@key "number_prop"] + boolean_prop: bool + + option [@default None] + + + ; [@key "boolean_prop"] + string_prop: string + + option [@default None] + + + ; [@key "string_prop"] + date_prop: string + + option [@default None] + + + ; [@key "date_prop"] + datetime_prop: string + + option [@default None] + + + ; [@key "datetime_prop"] + array_nullable_prop: Yojson.Safe.t list + [@default []] + + ; [@key "array_nullable_prop"] + array_and_items_nullable_prop: Yojson.Safe.t list + [@default []] + + ; [@key "array_and_items_nullable_prop"] + array_items_nullable: Yojson.Safe.t list + [@default []] + + ; [@key "array_items_nullable"] + object_nullable_prop: (string * Yojson.Safe.t) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + ; [@key "object_nullable_prop"] + object_and_items_nullable_prop: (string * Yojson.Safe.t) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + ; [@key "object_and_items_nullable_prop"] + object_items_nullable: (string * Yojson.Safe.t) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + ; [@key "object_items_nullable"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + integer_prop = None; + number_prop = None; + boolean_prop = None; + string_prop = None; + date_prop = None; + datetime_prop = None; + array_nullable_prop = []; + array_and_items_nullable_prop = []; + array_items_nullable = []; + object_nullable_prop = []; + object_and_items_nullable_prop = []; + object_items_nullable = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml index 297e4f68afcd..2ca1bb224c58 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml @@ -5,7 +5,20 @@ * *) -type t = { just_number : float option [@default None] [@key "JustNumber"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { just_number = None } + + + type t = { + just_number: float + + option [@default None] + + + ; [@key "JustNumber"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + just_number = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml index 49ce5b2ee2dd..93bb27889b10 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml @@ -5,13 +5,39 @@ * *) -type t = { - uuid : string option; [@default None] [@key "uuid"] - id : float option; [@default None] [@key "id"] - deprecated_ref : Deprecated_object.t option; - [@default None] [@key "deprecatedRef"] - bars : string list; [@default []] [@key "bars"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { uuid = None; id = None; deprecated_ref = None; bars = [] } + + + type t = { + uuid: string + + option [@default None] + + + ; [@key "uuid"] + id: float + + option [@default None] + + + ; [@key "id"] + deprecated_ref: Deprecated_object.t + + option [@default None] + + + ; [@key "deprecatedRef"] + bars: string list + [@default []] + + ; [@key "bars"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + uuid = None; + id = None; + deprecated_ref = None; + bars = []; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml index bb28c2a8bf26..edeb14daf189 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml @@ -5,23 +5,56 @@ * *) -type t = { - id : int64 option; [@default None] [@key "id"] - pet_id : int64 option; [@default None] [@key "petId"] - quantity : int32 option; [@default None] [@key "quantity"] - ship_date : string option; [@default None] [@key "shipDate"] - (* Order Status *) - status : Enums.order_status option; [@default None] [@key "status"] - complete : bool option; [@default None] [@key "complete"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { - id = None; - pet_id = None; - quantity = None; - ship_date = None; - status = None; - complete = None; - } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + pet_id: int64 + + option [@default None] + + + ; [@key "petId"] + quantity: int32 + + option [@default None] + + + ; [@key "quantity"] + ship_date: string + + option [@default None] + + + ; [@key "shipDate"] + (* Order Status *) + status: Enums.order_status + option [@default + + None + ] + ; [@key "status"] + complete: bool + + option [@default None] + + + ; [@key "complete"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + id = None; + pet_id = None; + quantity = None; + ship_date = None; + status = None; + complete = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml index cc7ccb2c6304..5ab6dc894cfc 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml @@ -5,11 +5,34 @@ * *) -type t = { - my_number : float option; [@default None] [@key "my_number"] - my_string : string option; [@default None] [@key "my_string"] - my_boolean : bool option; [@default None] [@key "my_boolean"] -} -[@@deriving yojson { strict = false }, show, eq] - -let create () : t = { my_number = None; my_string = None; my_boolean = None } + + + + type t = { + my_number: float + + option [@default None] + + + ; [@key "my_number"] + my_string: string + + option [@default None] + + + ; [@key "my_string"] + my_boolean: bool + + option [@default None] + + + ; [@key "my_boolean"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + my_number = None; + my_string = None; + my_boolean = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml index 59e02911a776..defddabc9421 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml @@ -5,7 +5,20 @@ * *) -type t = { value : Enums.outerenuminteger [@key "value"] } -[@@deriving yojson { strict = false }, show, eq] -let create (value : Enums.outerenuminteger) : t = { value } + + + type t = { + value: Enums.outerenuminteger + + + + + ; [@key "value"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (value : Enums.outerenuminteger) : t = { + value = value; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml index e62c2584e79b..0a82027599dc 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml @@ -5,11 +5,27 @@ * *) -type t = { - _type : Enums.parentwithnullable_type option; - [@default Some `ChildWithNullable] [@key "type"] - nullable_property : string option; [@default None] [@key "nullableProperty"] -} -[@@deriving yojson { strict = false }, show, eq] - -let create () : t = { _type = None; nullable_property = None } + + + + type t = { + _type: Enums.parentwithnullable_type + option [@default + Some(`ChildWithNullable) + + ] + ; [@key "type"] + nullable_property: string + + option [@default None] + + + ; [@key "nullableProperty"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + _type = None; + nullable_property = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml index a2311c5dc720..bf5b6f289e3c 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml @@ -5,15 +5,52 @@ * *) -type t = { - id : int64 option; [@default None] [@key "id"] - category : Category.t option; [@default None] [@key "category"] - name : string; [@key "name"] - photo_urls : string list; [@key "photoUrls"] - tags : Tag.t list; [@default []] [@key "tags"] (* pet status in the store *) - status : Enums.status option; [@default None] [@key "status"] -} -[@@deriving yojson { strict = false }, show, eq] -let create (name : string) (photo_urls : string list) : t = - { id = None; category = None; name; photo_urls; tags = []; status = None } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + category: Category.t + + option [@default None] + + + ; [@key "category"] + name: string + + + + + ; [@key "name"] + photo_urls: string list + + + ; [@key "photoUrls"] + tags: Tag.t list + [@default []] + + ; [@key "tags"] + (* pet status in the store *) + status: Enums.status + option [@default + + None + ] + ; [@key "status"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (name : string) (photo_urls : string list) : t = { + id = None; + category = None; + name = name; + photo_urls = photo_urls; + tags = []; + status = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml index 52837ce4c713..42764810c586 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml @@ -5,10 +5,27 @@ * *) -type t = { - bar : string option; [@default None] [@key "bar"] - baz : string option; [@default None] [@key "baz"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { bar = None; baz = None } + + + type t = { + bar: string + + option [@default None] + + + ; [@key "bar"] + baz: string + + option [@default None] + + + ; [@key "baz"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + bar = None; + baz = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml index ed4f30407168..1b27a9c0c5b5 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml @@ -6,8 +6,21 @@ * Schema Return.t : Model for testing reserved words *) -type t = { return : int32 option [@default None] [@key "return"] } -[@@deriving yojson { strict = false }, show, eq] -(** Model for testing reserved words *) -let create () : t = { return = None } + + + type t = { + return: int32 + + option [@default None] + + + ; [@key "return"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Model for testing reserved words *) + let create () : t = { + return = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml index 335112074190..01467b5e0745 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml @@ -5,10 +5,27 @@ * *) -type t = { - id : int64 option; [@default None] [@key "id"] - name : string option; [@default None] [@key "name"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { id = None; name = None } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + name: string + + option [@default None] + + + ; [@key "name"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + id = None; + name = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml index be86989e9f1b..9aa631abe7bc 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml @@ -5,7 +5,20 @@ * *) -type t = { some_property : string option [@default None] [@key "someProperty"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { some_property = None } + + + type t = { + some_property: string + + option [@default None] + + + ; [@key "someProperty"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + some_property = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml index 32f410b2e563..4582d3115276 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml @@ -5,27 +5,70 @@ * *) -type t = { - id : int64 option; [@default None] [@key "id"] - username : string option; [@default None] [@key "username"] - first_name : string option; [@default None] [@key "firstName"] - last_name : string option; [@default None] [@key "lastName"] - email : string option; [@default None] [@key "email"] - password : string option; [@default None] [@key "password"] - phone : string option; [@default None] [@key "phone"] - (* User Status *) - user_status : int32 option; [@default None] [@key "userStatus"] -} -[@@deriving yojson { strict = false }, show, eq] -let create () : t = - { - id = None; - username = None; - first_name = None; - last_name = None; - email = None; - password = None; - phone = None; - user_status = None; - } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + username: string + + option [@default None] + + + ; [@key "username"] + first_name: string + + option [@default None] + + + ; [@key "firstName"] + last_name: string + + option [@default None] + + + ; [@key "lastName"] + email: string + + option [@default None] + + + ; [@key "email"] + password: string + + option [@default None] + + + ; [@key "password"] + phone: string + + option [@default None] + + + ; [@key "phone"] + (* User Status *) + user_status: int32 + + option [@default None] + + + ; [@key "userStatus"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + id = None; + username = None; + first_name = None; + last_name = None; + email = None; + password = None; + phone = None; + user_status = None; + } + + diff --git a/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml b/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml index e17deb86aaef..38b8eb297499 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml @@ -5,208 +5,159 @@ * *) -type outerenuminteger = - [ `_0 [@printer fun fmt _ -> Format.pp_print_string fmt "0"] [@name "0"] - | `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] - | `_2 [@printer fun fmt _ -> Format.pp_print_string fmt "2"] [@name "2"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let outerenuminteger_of_yojson json = - outerenuminteger_of_yojson (`List [ json ]) +type outerenuminteger = [ +| `_0 [@printer fun fmt _ -> Format.pp_print_string fmt "0"] [@name "0"] +| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] +| `_2 [@printer fun fmt _ -> Format.pp_print_string fmt "2"] [@name "2"] +] [@@deriving yojson, show { with_path = false }, eq];; +let outerenuminteger_of_yojson json = outerenuminteger_of_yojson (`List [json]) let outerenuminteger_to_yojson e = - match outerenuminteger_to_yojson e with - | `List [ json ] -> json - | json -> json - -type map_of_enum_string = - [ `UPPER - [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] - [@name "UPPER"] - | `Lower - [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] - [@name "lower"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let map_of_enum_string_of_yojson json = - map_of_enum_string_of_yojson (`List [ json ]) + match outerenuminteger_to_yojson e with + | `List [json] -> json + | json -> json -let map_of_enum_string_to_yojson e = - match map_of_enum_string_to_yojson e with - | `List [ json ] -> json - | json -> json +type map_of_enum_string = [ +| `UPPER [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] [@name "UPPER"] +| `Lower [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] [@name "lower"] +] [@@deriving yojson, show { with_path = false }, eq];; -type enum_integer = - [ `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] - | `Minus1 [@printer fun fmt _ -> Format.pp_print_string fmt "-1"] [@name "-1"] - ] -[@@deriving yojson, show { with_path = false }, eq] +let map_of_enum_string_of_yojson json = map_of_enum_string_of_yojson (`List [json]) +let map_of_enum_string_to_yojson e = + match map_of_enum_string_to_yojson e with + | `List [json] -> json + | json -> json -let enum_integer_of_yojson json = enum_integer_of_yojson (`List [ json ]) +type enum_integer = [ +| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] +| `Minus1 [@printer fun fmt _ -> Format.pp_print_string fmt "-1"] [@name "-1"] +] [@@deriving yojson, show { with_path = false }, eq];; +let enum_integer_of_yojson json = enum_integer_of_yojson (`List [json]) let enum_integer_to_yojson e = - match enum_integer_to_yojson e with `List [ json ] -> json | json -> json - -type just_symbol = - [ `Greater_ThanEqual - [@printer fun fmt _ -> Format.pp_print_string fmt ">="] - [@name ">="] - | `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] - ] -[@@deriving yojson, show { with_path = false }, eq] + match enum_integer_to_yojson e with + | `List [json] -> json + | json -> json -let just_symbol_of_yojson json = just_symbol_of_yojson (`List [ json ]) +type just_symbol = [ +| `Greater_ThanEqual [@printer fun fmt _ -> Format.pp_print_string fmt ">="] [@name ">="] +| `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] +] [@@deriving yojson, show { with_path = false }, eq];; +let just_symbol_of_yojson json = just_symbol_of_yojson (`List [json]) let just_symbol_to_yojson e = - match just_symbol_to_yojson e with `List [ json ] -> json | json -> json - -type enumclass = - [ `_abc - [@printer fun fmt _ -> Format.pp_print_string fmt "_abc"] - [@name "_abc"] - | `Minusefg - [@printer fun fmt _ -> Format.pp_print_string fmt "-efg"] - [@name "-efg"] - | `Left_ParenthesisxyzRight_Parenthesis - [@printer fun fmt _ -> Format.pp_print_string fmt "(xyz)"] - [@name "(xyz)"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let enumclass_of_yojson json = enumclass_of_yojson (`List [ json ]) + match just_symbol_to_yojson e with + | `List [json] -> json + | json -> json +type enumclass = [ +| `_abc [@printer fun fmt _ -> Format.pp_print_string fmt "_abc"] [@name "_abc"] +| `Minusefg [@printer fun fmt _ -> Format.pp_print_string fmt "-efg"] [@name "-efg"] +| `Left_ParenthesisxyzRight_Parenthesis [@printer fun fmt _ -> Format.pp_print_string fmt "(xyz)"] [@name "(xyz)"] +] [@@deriving yojson, show { with_path = false }, eq];; + +let enumclass_of_yojson json = enumclass_of_yojson (`List [json]) let enumclass_to_yojson e = - match enumclass_to_yojson e with `List [ json ] -> json | json -> json - -type status = - [ `Available - [@printer fun fmt _ -> Format.pp_print_string fmt "available"] - [@name "available"] - | `Pending - [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] - [@name "pending"] - | `Sold - [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] - [@name "sold"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let status_of_yojson json = status_of_yojson (`List [ json ]) + match enumclass_to_yojson e with + | `List [json] -> json + | json -> json + +type status = [ +| `Available [@printer fun fmt _ -> Format.pp_print_string fmt "available"] [@name "available"] +| `Pending [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] [@name "pending"] +| `Sold [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] [@name "sold"] +] [@@deriving yojson, show { with_path = false }, eq];; +let status_of_yojson json = status_of_yojson (`List [json]) let status_to_yojson e = - match status_to_yojson e with `List [ json ] -> json | json -> json - -type order_status = - [ `Placed - [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] - [@name "placed"] - | `Approved - [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] - [@name "approved"] - | `Delivered - [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] - [@name "delivered"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let order_status_of_yojson json = order_status_of_yojson (`List [ json ]) + match status_to_yojson e with + | `List [json] -> json + | json -> json -let order_status_to_yojson e = - match order_status_to_yojson e with `List [ json ] -> json | json -> json +type order_status = [ +| `Placed [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] [@name "placed"] +| `Approved [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] [@name "approved"] +| `Delivered [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] [@name "delivered"] +] [@@deriving yojson, show { with_path = false }, eq];; -type enum_query_integer = - [ `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] - | `Minus2 [@printer fun fmt _ -> Format.pp_print_string fmt "-2"] [@name "-2"] - ] -[@@deriving yojson, show { with_path = false }, eq] +let order_status_of_yojson json = order_status_of_yojson (`List [json]) +let order_status_to_yojson e = + match order_status_to_yojson e with + | `List [json] -> json + | json -> json -let enum_query_integer_of_yojson json = - enum_query_integer_of_yojson (`List [ json ]) +type enum_query_integer = [ +| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"] +| `Minus2 [@printer fun fmt _ -> Format.pp_print_string fmt "-2"] [@name "-2"] +] [@@deriving yojson, show { with_path = false }, eq];; +let enum_query_integer_of_yojson json = enum_query_integer_of_yojson (`List [json]) let enum_query_integer_to_yojson e = - match enum_query_integer_to_yojson e with - | `List [ json ] -> json - | json -> json - -type enum_form_string_array = - [ `Greater_Than - [@printer fun fmt _ -> Format.pp_print_string fmt ">"] - [@name ">"] - | `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] - ] -[@@deriving yojson, show { with_path = false }, eq] + match enum_query_integer_to_yojson e with + | `List [json] -> json + | json -> json -let enum_form_string_array_of_yojson json = - enum_form_string_array_of_yojson (`List [ json ]) +type enum_form_string_array = [ +| `Greater_Than [@printer fun fmt _ -> Format.pp_print_string fmt ">"] [@name ">"] +| `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"] +] [@@deriving yojson, show { with_path = false }, eq];; +let enum_form_string_array_of_yojson json = enum_form_string_array_of_yojson (`List [json]) let enum_form_string_array_to_yojson e = - match enum_form_string_array_to_yojson e with - | `List [ json ] -> json - | json -> json + match enum_form_string_array_to_yojson e with + | `List [json] -> json + | json -> json -type parentwithnullable_type = - [ `ChildWithNullable - [@printer fun fmt _ -> Format.pp_print_string fmt "ChildWithNullable"] - [@name "ChildWithNullable"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let parentwithnullable_type_of_yojson json = - parentwithnullable_type_of_yojson (`List [ json ]) +type parentwithnullable_type = [ +| `ChildWithNullable [@printer fun fmt _ -> Format.pp_print_string fmt "ChildWithNullable"] [@name "ChildWithNullable"] +] [@@deriving yojson, show { with_path = false }, eq];; +let parentwithnullable_type_of_yojson json = parentwithnullable_type_of_yojson (`List [json]) let parentwithnullable_type_to_yojson e = - match parentwithnullable_type_to_yojson e with - | `List [ json ] -> json - | json -> json - -type enum_number = - [ `_1Period1 - [@printer fun fmt _ -> Format.pp_print_string fmt "1.1"] - [@name "1.1"] - | `Minus1Period2 - [@printer fun fmt _ -> Format.pp_print_string fmt "-1.2"] - [@name "-1.2"] ] -[@@deriving yojson, show { with_path = false }, eq] + match parentwithnullable_type_to_yojson e with + | `List [json] -> json + | json -> json -let enum_number_of_yojson json = enum_number_of_yojson (`List [ json ]) +type enum_number = [ +| `_1Period1 [@printer fun fmt _ -> Format.pp_print_string fmt "1.1"] [@name "1.1"] +| `Minus1Period2 [@printer fun fmt _ -> Format.pp_print_string fmt "-1.2"] [@name "-1.2"] +] [@@deriving yojson, show { with_path = false }, eq];; +let enum_number_of_yojson json = enum_number_of_yojson (`List [json]) let enum_number_to_yojson e = - match enum_number_to_yojson e with `List [ json ] -> json | json -> json + match enum_number_to_yojson e with + | `List [json] -> json + | json -> json -type array_enum = - [ `Fish - [@printer fun fmt _ -> Format.pp_print_string fmt "fish"] - [@name "fish"] - | `Crab - [@printer fun fmt _ -> Format.pp_print_string fmt "crab"] - [@name "crab"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let array_enum_of_yojson json = array_enum_of_yojson (`List [ json ]) +type array_enum = [ +| `Fish [@printer fun fmt _ -> Format.pp_print_string fmt "fish"] [@name "fish"] +| `Crab [@printer fun fmt _ -> Format.pp_print_string fmt "crab"] [@name "crab"] +] [@@deriving yojson, show { with_path = false }, eq];; +let array_enum_of_yojson json = array_enum_of_yojson (`List [json]) let array_enum_to_yojson e = - match array_enum_to_yojson e with `List [ json ] -> json | json -> json - -type singlereftype = - [ `Admin - [@printer fun fmt _ -> Format.pp_print_string fmt "admin"] - [@name "admin"] - | `User - [@printer fun fmt _ -> Format.pp_print_string fmt "user"] - [@name "user"] ] -[@@deriving yojson, show { with_path = false }, eq] + match array_enum_to_yojson e with + | `List [json] -> json + | json -> json -let singlereftype_of_yojson json = singlereftype_of_yojson (`List [ json ]) +type singlereftype = [ +| `Admin [@printer fun fmt _ -> Format.pp_print_string fmt "admin"] [@name "admin"] +| `User [@printer fun fmt _ -> Format.pp_print_string fmt "user"] [@name "user"] +] [@@deriving yojson, show { with_path = false }, eq];; +let singlereftype_of_yojson json = singlereftype_of_yojson (`List [json]) let singlereftype_to_yojson e = - match singlereftype_to_yojson e with `List [ json ] -> json | json -> json - -type enum_string = - [ `UPPER - [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] - [@name "UPPER"] - | `Lower - [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] - [@name "lower"] ] -[@@deriving yojson, show { with_path = false }, eq] + match singlereftype_to_yojson e with + | `List [json] -> json + | json -> json -let enum_string_of_yojson json = enum_string_of_yojson (`List [ json ]) +type enum_string = [ +| `UPPER [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] [@name "UPPER"] +| `Lower [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] [@name "lower"] +] [@@deriving yojson, show { with_path = false }, eq];; +let enum_string_of_yojson json = enum_string_of_yojson (`List [json]) let enum_string_to_yojson e = - match enum_string_to_yojson e with `List [ json ] -> json | json -> json + match enum_string_to_yojson e with + | `List [json] -> json + | json -> json diff --git a/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml b/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml index 9b4d882c3c12..0af0c25e759a 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/support/jsonSupport.ml @@ -1,55 +1,68 @@ open Ppx_deriving_yojson_runtime let unwrap to_json json = - match to_json json with - | Result.Ok json -> json - | Result.Error s -> failwith s + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s let to_int json = - match json with - | `Int x -> x - | `Intlit s -> int_of_string s - | _ -> failwith "JsonSupport.to_int" + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" let to_bool json = - match json with `Bool x -> x | _ -> failwith "JsonSupport.to_bool" + match json with + | `Bool x -> x + | _ -> failwith "JsonSupport.to_bool" let to_float json = - match json with `Float x -> x | _ -> failwith "JsonSupport.to_float" + match json with + | `Float x -> x + | _ -> failwith "JsonSupport.to_float" let to_string json = - match json with `String s -> s | _ -> failwith "JsonSupport.to_string" + match json with + | `String s -> s + | _ -> failwith "JsonSupport.to_string" let to_int32 json : int32 = - match json with - | `Int x -> Int32.of_int x - | `Intlit s -> Int32.of_string s - | _ -> failwith "JsonSupport.to_int32" + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" let to_int64 json : int64 = - match json with - | `Int x -> Int64.of_int x - | `Intlit s -> Int64.of_string s - | _ -> failwith "JsonSupport.to_int64" + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" let of_int x = `Int x + let of_bool b = `Bool b + let of_float x = `Float x + let of_string s = `String s + let of_int32 x = `Intlit (Int32.to_string x) + let of_int64 x = `Intlit (Int64.to_string x) + let of_list_of of_f l = `List (Stdlib.List.map of_f l) + let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) let to_map_of of_f json = match json with | `Assoc l -> - Stdlib.List.fold_right - (fun (k, json) acc -> - match (of_f json, acc) with - | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> - Stdlib.Result.Ok ((k, parsed_v) :: tl) - | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e - | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) - l (Stdlib.Result.Ok []) + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml b/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml index dbf462c85e4e..cbb1a71ea697 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/support/request.ml @@ -1,9 +1,16 @@ let api_key = "" let base_url = "http://petstore.swagger.io:80/v2" let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" -let option_fold f default o = match o with Some v -> f v | None -> default + +let option_fold f default o = + match o with + | Some v -> f v + | None -> default + let build_uri operation_path = Uri.of_string (base_url ^ operation_path) -let add_string_header headers key value = Cohttp.Header.add headers key value + +let add_string_header headers key value = + Cohttp.Header.add headers key value let add_string_header_multi headers key values = Cohttp.Header.add_multi headers key values @@ -30,16 +37,13 @@ let write_as_json_body to_json payload = write_json_body (to_json payload) let handle_response resp on_success_handler = match Cohttp.Response.status resp with | #Cohttp.Code.success_status -> on_success_handler () - | s -> - failwith - ("Server responded with status " - ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) let read_json_body resp body = handle_response resp (fun () -> - Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string)) + (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) let read_json_body_as of_json resp body = Lwt.(read_json_body resp body >|= of_json) @@ -54,15 +58,11 @@ let read_json_body_as_map resp body = Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) let read_json_body_as_map_of of_json resp body = - Lwt.( - read_json_body_as_map resp body - >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) let replace_string_path_param uri param_name param_value = let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in - let path = - Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) - in + let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in Uri.with_path uri path let replace_path_param uri param_name to_string param_value = @@ -85,33 +85,26 @@ let maybe_add_query_param uri param_name to_string param_value = - [explode = true] - type [object] - See - https://swagger.io/docs/specification/v3_0/serialization/#query-parameters + See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters *) let add_query_param_exploded_form_object uri _param_name to_string param_value = - Stdlib.List.fold_left - (fun uri (param_name, param_value) -> - add_query_param uri param_name to_string param_value) - uri param_value +Stdlib.List.fold_left + (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) + uri + param_value let init_form_encoded_body () = "" let add_form_encoded_body_param params param_name to_string param_value = - let new_param_enc = - Printf.sprintf {|%s=%s|} - (Uri.pct_encode param_name) - (Uri.pct_encode (to_string param_value)) - in - if params = "" then new_param_enc + let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in + if params = "" + then new_param_enc else Printf.sprintf {|%s&%s|} params new_param_enc let add_form_encoded_body_param_list params param_name to_string new_params = - add_form_encoded_body_param params param_name (String.concat ",") - (to_string new_params) + add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) let maybe_add_form_encoded_body_param params param_name to_string param_value = - option_fold - (add_form_encoded_body_param params param_name to_string) - params param_value + option_fold (add_form_encoded_body_param params param_name to_string) params param_value let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body diff --git a/samples/client/petstore/ocaml-oneOf/dune b/samples/client/petstore/ocaml-oneOf/dune index d10b1d1a5075..ed1c4d90e3df 100644 --- a/samples/client/petstore/ocaml-oneOf/dune +++ b/samples/client/petstore/ocaml-oneOf/dune @@ -1,11 +1,9 @@ (include_subdirs unqualified) - (library - (name petstore_client) - (public_name petstore_client) - (flags - (:standard -w -27)) - (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) - (preprocess - (pps ppx_deriving_yojson ppx_deriving.std)) - (wrapped true)) + (name petstore_client) + (public_name petstore_client) + (flags (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true) +) \ No newline at end of file diff --git a/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml b/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml index 432c068ba143..93677e4bf1f5 100644 --- a/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml +++ b/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml @@ -6,8 +6,9 @@ *) let list () = - let open Lwt.Infix in - let uri = Request.build_uri "/example" in - let headers = Request.default_headers in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Example.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/example" in + let headers = Request.default_headers in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Example.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml-oneOf/src/models/child.ml b/samples/client/petstore/ocaml-oneOf/src/models/child.ml index a33f47aed2e9..ff9a12f2eb4d 100644 --- a/samples/client/petstore/ocaml-oneOf/src/models/child.ml +++ b/samples/client/petstore/ocaml-oneOf/src/models/child.ml @@ -5,7 +5,20 @@ * *) -type t = { name : string option [@default None] [@key "name"] } -[@@deriving yojson { strict = false }, show, eq] -let create () : t = { name = None } + + + type t = { + name: string + + option [@default None] + + + ; [@key "name"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + name = None; + } + + diff --git a/samples/client/petstore/ocaml-oneOf/src/models/example.ml b/samples/client/petstore/ocaml-oneOf/src/models/example.ml index a9b61de3ed7c..42162d950c76 100644 --- a/samples/client/petstore/ocaml-oneOf/src/models/example.ml +++ b/samples/client/petstore/ocaml-oneOf/src/models/example.ml @@ -5,35 +5,35 @@ * *) -type t = OneOf0 of Child.t | OneOf1 of int32 [@@deriving show, eq] + type t = + | OneOf0 of Child.t + | OneOf1 of int32 + [@@deriving show, eq];; + + let to_yojson = function + | OneOf0 v -> [%to_yojson: Child.t] v + | OneOf1 v -> [%to_yojson: int32] v + + (* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *) + + let of_yojson json = + [ + [%of_yojson: Child.t] json + |> Stdlib.Result.to_option + |> Stdlib.Option.map (fun v -> OneOf0 v); + [%of_yojson: int32] json + |> Stdlib.Result.to_option + |> Stdlib.Option.map (fun v -> OneOf1 v); + ] + |> Stdlib.List.filter_map (Fun.id) + |> function + | [t] -> Ok t + | [] -> Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type Example.t") + | ts -> let parsed_ts = ts + |> Stdlib.List.map show + |> Stdlib.String.concat " | " + in Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type Example.t: oneOf should only succeed on one parser, but the JSON was parsed into [" ^ parsed_ts ^ "]") -let to_yojson = function - | OneOf0 v -> [%to_yojson: Child.t] v - | OneOf1 v -> [%to_yojson: int32] v -(* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *) + -let of_yojson json = - [ - [%of_yojson: Child.t] json - |> Stdlib.Result.to_option - |> Stdlib.Option.map (fun v -> OneOf0 v); - [%of_yojson: int32] json - |> Stdlib.Result.to_option - |> Stdlib.Option.map (fun v -> OneOf1 v); - ] - |> Stdlib.List.filter_map Fun.id - |> function - | [ t ] -> Ok t - | [] -> - Error - ("Failed to parse JSON " ^ Yojson.Safe.show json - ^ " into a value of type Example.t") - | ts -> - let parsed_ts = - ts |> Stdlib.List.map show |> Stdlib.String.concat " | " - in - Error - ("Failed to parse JSON " ^ Yojson.Safe.show json - ^ " into a value of type Example.t: oneOf should only succeed on one \ - parser, but the JSON was parsed into [" ^ parsed_ts ^ "]") diff --git a/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml b/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml index 9b4d882c3c12..0af0c25e759a 100644 --- a/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml +++ b/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml @@ -1,55 +1,68 @@ open Ppx_deriving_yojson_runtime let unwrap to_json json = - match to_json json with - | Result.Ok json -> json - | Result.Error s -> failwith s + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s let to_int json = - match json with - | `Int x -> x - | `Intlit s -> int_of_string s - | _ -> failwith "JsonSupport.to_int" + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" let to_bool json = - match json with `Bool x -> x | _ -> failwith "JsonSupport.to_bool" + match json with + | `Bool x -> x + | _ -> failwith "JsonSupport.to_bool" let to_float json = - match json with `Float x -> x | _ -> failwith "JsonSupport.to_float" + match json with + | `Float x -> x + | _ -> failwith "JsonSupport.to_float" let to_string json = - match json with `String s -> s | _ -> failwith "JsonSupport.to_string" + match json with + | `String s -> s + | _ -> failwith "JsonSupport.to_string" let to_int32 json : int32 = - match json with - | `Int x -> Int32.of_int x - | `Intlit s -> Int32.of_string s - | _ -> failwith "JsonSupport.to_int32" + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" let to_int64 json : int64 = - match json with - | `Int x -> Int64.of_int x - | `Intlit s -> Int64.of_string s - | _ -> failwith "JsonSupport.to_int64" + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" let of_int x = `Int x + let of_bool b = `Bool b + let of_float x = `Float x + let of_string s = `String s + let of_int32 x = `Intlit (Int32.to_string x) + let of_int64 x = `Intlit (Int64.to_string x) + let of_list_of of_f l = `List (Stdlib.List.map of_f l) + let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) let to_map_of of_f json = match json with | `Assoc l -> - Stdlib.List.fold_right - (fun (k, json) acc -> - match (of_f json, acc) with - | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> - Stdlib.Result.Ok ((k, parsed_v) :: tl) - | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e - | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) - l (Stdlib.Result.Ok []) + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml-oneOf/src/support/request.ml b/samples/client/petstore/ocaml-oneOf/src/support/request.ml index 29eaa66901c9..c89862d5d0ea 100644 --- a/samples/client/petstore/ocaml-oneOf/src/support/request.ml +++ b/samples/client/petstore/ocaml-oneOf/src/support/request.ml @@ -1,9 +1,16 @@ let api_key = "" let base_url = "http://api.example.xyz/v1" let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" -let option_fold f default o = match o with Some v -> f v | None -> default + +let option_fold f default o = + match o with + | Some v -> f v + | None -> default + let build_uri operation_path = Uri.of_string (base_url ^ operation_path) -let add_string_header headers key value = Cohttp.Header.add headers key value + +let add_string_header headers key value = + Cohttp.Header.add headers key value let add_string_header_multi headers key values = Cohttp.Header.add_multi headers key values @@ -30,16 +37,13 @@ let write_as_json_body to_json payload = write_json_body (to_json payload) let handle_response resp on_success_handler = match Cohttp.Response.status resp with | #Cohttp.Code.success_status -> on_success_handler () - | s -> - failwith - ("Server responded with status " - ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) let read_json_body resp body = handle_response resp (fun () -> - Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string)) + (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) let read_json_body_as of_json resp body = Lwt.(read_json_body resp body >|= of_json) @@ -54,15 +58,11 @@ let read_json_body_as_map resp body = Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) let read_json_body_as_map_of of_json resp body = - Lwt.( - read_json_body_as_map resp body - >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) let replace_string_path_param uri param_name param_value = let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in - let path = - Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) - in + let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in Uri.with_path uri path let replace_path_param uri param_name to_string param_value = @@ -85,33 +85,26 @@ let maybe_add_query_param uri param_name to_string param_value = - [explode = true] - type [object] - See - https://swagger.io/docs/specification/v3_0/serialization/#query-parameters + See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters *) let add_query_param_exploded_form_object uri _param_name to_string param_value = - Stdlib.List.fold_left - (fun uri (param_name, param_value) -> - add_query_param uri param_name to_string param_value) - uri param_value +Stdlib.List.fold_left + (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) + uri + param_value let init_form_encoded_body () = "" let add_form_encoded_body_param params param_name to_string param_value = - let new_param_enc = - Printf.sprintf {|%s=%s|} - (Uri.pct_encode param_name) - (Uri.pct_encode (to_string param_value)) - in - if params = "" then new_param_enc + let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in + if params = "" + then new_param_enc else Printf.sprintf {|%s&%s|} params new_param_enc let add_form_encoded_body_param_list params param_name to_string new_params = - add_form_encoded_body_param params param_name (String.concat ",") - (to_string new_params) + add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) let maybe_add_form_encoded_body_param params param_name to_string param_value = - option_fold - (add_form_encoded_body_param params param_name to_string) - params param_value + option_fold (add_form_encoded_body_param params param_name to_string) params param_value let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body diff --git a/samples/client/petstore/ocaml/dune b/samples/client/petstore/ocaml/dune index d10b1d1a5075..ed1c4d90e3df 100644 --- a/samples/client/petstore/ocaml/dune +++ b/samples/client/petstore/ocaml/dune @@ -1,11 +1,9 @@ (include_subdirs unqualified) - (library - (name petstore_client) - (public_name petstore_client) - (flags - (:standard -w -27)) - (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) - (preprocess - (pps ppx_deriving_yojson ppx_deriving.std)) - (wrapped true)) + (name petstore_client) + (public_name petstore_client) + (flags (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true) +) \ No newline at end of file diff --git a/samples/client/petstore/ocaml/src/apis/pet_api.ml b/samples/client/petstore/ocaml/src/apis/pet_api.ml index 5157abf622ca..386163121bda 100644 --- a/samples/client/petstore/ocaml/src/apis/pet_api.ml +++ b/samples/client/petstore/ocaml/src/apis/pet_api.ml @@ -6,95 +6,260 @@ *) let add_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Pet.to_yojson pet_t in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Pet.to_yojson + + + + pet_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let delete_pet ~pet_id ?api_key () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = - Request.maybe_add_header headers "api_key" (fun x -> x) api_key - in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = Request.maybe_add_header headers "api_key" + + + + + + + + + (fun x -> x) + + + + + api_key in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let find_pets_by_status ~status = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByStatus" in - let headers = Request.default_headers in - let uri = - Request.add_query_param_list uri "status" - (Stdlib.List.map Enums.show_pet_status) - status - in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByStatus" in + let headers = Request.default_headers in + let uri = Request.add_query_param_list uri "status" (Stdlib.List.map Enums.show_pet_status + +) + status in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let find_pets_by_tags ~tags = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/findByTags" in - let headers = Request.default_headers in - let uri = - Request.add_query_param_list uri "tags" (Stdlib.List.map (fun x -> x)) tags - in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/findByTags" in + let headers = Request.default_headers in + let uri = Request.add_query_param_list uri "tags" (Stdlib.List.map + + + + + + + + + (fun x -> x) + + + + +) + + + + + + + + + + + + + tags in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body let get_pet_by_id ~pet_id = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let update_pet ~pet_t = - let open Lwt.Infix in - let uri = Request.build_uri "/pet" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Pet.to_yojson pet_t in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Pet.to_yojson + + + + pet_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body let update_pet_with_form ~pet_id ?name ?status () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - let body = Request.init_form_encoded_body () in - let body = - Request.maybe_add_form_encoded_body_param body "name" (fun x -> x) name - in - let body = - Request.maybe_add_form_encoded_body_param body "status" (fun x -> x) status - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + let body = Request.init_form_encoded_body () in + let body = Request.maybe_add_form_encoded_body_param body "name" + + + + + + + + + (fun x -> x) + + + + + name in + let body = Request.maybe_add_form_encoded_body_param body "status" + + + + + + + + + (fun x -> x) + + + + + status in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let upload_file ~pet_id ?additional_metadata ?file () = - let open Lwt.Infix in - let uri = Request.build_uri "/pet/{petId}/uploadImage" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in - let body = Request.init_form_encoded_body () in - let body = - Request.maybe_add_form_encoded_body_param body "additional_metadata" - (fun x -> x) - additional_metadata - in - let body = - Request.maybe_add_form_encoded_body_param body "file" (fun x -> x) file - in - let body = Request.finalize_form_encoded_body body in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as - (JsonSupport.unwrap Api_response.of_yojson) - resp body + let open Lwt.Infix in + let uri = Request.build_uri "/pet/{petId}/uploadImage" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "petId" Int64.to_string + + + + + + + + + + + + + + pet_id in + let body = Request.init_form_encoded_body () in + let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" + + + + + + + + + (fun x -> x) + + + + + additional_metadata in + let body = Request.maybe_add_form_encoded_body_param body "file" + + + + + + (fun x -> x) + + + + + + + + file in + let body = Request.finalize_form_encoded_body body in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml/src/apis/pet_api.mli b/samples/client/petstore/ocaml/src/apis/pet_api.mli index 6a36f1df74bb..c52ae12f1202 100644 --- a/samples/client/petstore/ocaml/src/apis/pet_api.mli +++ b/samples/client/petstore/ocaml/src/apis/pet_api.mli @@ -11,13 +11,5 @@ val find_pets_by_status : status:Enums.pet_status list -> Pet.t list Lwt.t val find_pets_by_tags : tags:string list -> Pet.t list Lwt.t val get_pet_by_id : pet_id:int64 -> Pet.t Lwt.t val update_pet : pet_t:Pet.t -> Pet.t Lwt.t - -val update_pet_with_form : - pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t - -val upload_file : - pet_id:int64 -> - ?additional_metadata:string -> - ?file:string -> - unit -> - Api_response.t Lwt.t +val update_pet_with_form : pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t +val upload_file : pet_id:int64 -> ?additional_metadata:string -> ?file:string -> unit -> Api_response.t Lwt.t diff --git a/samples/client/petstore/ocaml/src/apis/store_api.ml b/samples/client/petstore/ocaml/src/apis/store_api.ml index 25e0561d13d3..510e9ea48325 100644 --- a/samples/client/petstore/ocaml/src/apis/store_api.ml +++ b/samples/client/petstore/ocaml/src/apis/store_api.ml @@ -6,33 +6,76 @@ *) let delete_order ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{orderId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "orderId" (fun x -> x) order_id in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{orderId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "orderId" + + + + + + + + + (fun x -> x) + + + + + order_id in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_inventory () = - let open Lwt.Infix in - let uri = Request.build_uri "/store/inventory" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as_map_of JsonSupport.to_int32 resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/inventory" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as_map_of (JsonSupport.to_int32) resp body let get_order_by_id ~order_id = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order/{orderId}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "orderId" Int64.to_string order_id in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/order/{orderId}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "orderId" Int64.to_string + + + + + + + + + + + + + + order_id in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body let place_order ~order_t = - let open Lwt.Infix in - let uri = Request.build_uri "/store/order" in - let headers = Request.default_headers in - let body = Request.write_as_json_body Order.to_yojson order_t in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/store/order" in + let headers = Request.default_headers in + let body = Request. + + write_as_json_body + + + + + + + Order.to_yojson + + + + order_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body + diff --git a/samples/client/petstore/ocaml/src/apis/user_api.ml b/samples/client/petstore/ocaml/src/apis/user_api.ml index 3202ec0291d2..d034b4b22851 100644 --- a/samples/client/petstore/ocaml/src/apis/user_api.ml +++ b/samples/client/petstore/ocaml/src/apis/user_api.ml @@ -6,76 +6,201 @@ *) let create_user ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let body = Request.write_as_json_body User.to_yojson user_t in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let body = Request. + + write_as_json_body + + + + + + + User.to_yojson + + + + user_t + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_array_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithArray" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let body = - Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithArray" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let body = Request. + + write_as_json_body (JsonSupport.of_list_of + + + + + + + User.to_yojson + + + +) + user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let create_users_with_list_input ~user = - let open Lwt.Infix in - let uri = Request.build_uri "/user/createWithList" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let body = - Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user - in - Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/createWithList" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let body = Request. + + write_as_json_body (JsonSupport.of_list_of + + + + + + + User.to_yojson + + + +) + user + in + Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp let delete_user ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "username" (fun x -> x) username in - Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let get_user_by_name ~username = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let uri = Request.replace_path_param uri "username" (fun x -> x) username in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let uri = Request.replace_path_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body let login_user ~username ~password = - let open Lwt.Infix in - let uri = Request.build_uri "/user/login" in - let headers = Request.default_headers in - let uri = Request.add_query_param uri "username" (fun x -> x) username in - let uri = Request.add_query_param uri "password" (fun x -> x) password in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.read_json_body_as JsonSupport.to_string resp body + let open Lwt.Infix in + let uri = Request.build_uri "/user/login" in + let headers = Request.default_headers in + let uri = Request.add_query_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + let uri = Request.add_query_param uri "password" + + + + + + + + + (fun x -> x) + + + + + password in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.read_json_body_as (JsonSupport.to_string) resp body let logout_user () = - let open Lwt.Infix in - let uri = Request.build_uri "/user/logout" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/logout" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) -> + Request.handle_unit_response resp let update_user ~username ~user_t = - let open Lwt.Infix in - let uri = Request.build_uri "/user/{username}" in - let headers = Request.default_headers in - let headers = Cohttp.Header.add headers "api_key" Request.api_key in - let uri = Request.replace_path_param uri "username" (fun x -> x) username in - let body = Request.write_as_json_body User.to_yojson user_t in - Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> - Request.handle_unit_response resp + let open Lwt.Infix in + let uri = Request.build_uri "/user/{username}" in + let headers = Request.default_headers in + let headers = Cohttp.Header.add headers "api_key" Request.api_key in + let uri = Request.replace_path_param uri "username" + + + + + + + + + (fun x -> x) + + + + + username in + let body = Request. + + write_as_json_body + + + + + + + User.to_yojson + + + + user_t + in + Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) -> + Request.handle_unit_response resp + diff --git a/samples/client/petstore/ocaml/src/models/api_response.ml b/samples/client/petstore/ocaml/src/models/api_response.ml index a261e879691a..b2a6f6824638 100644 --- a/samples/client/petstore/ocaml/src/models/api_response.ml +++ b/samples/client/petstore/ocaml/src/models/api_response.ml @@ -6,12 +6,35 @@ * Schema Api_response.t : Describes the result of uploading an image resource *) -type t = { - code : int32 option; [@default None] [@key "code"] - _type : string option; [@default None] [@key "type"] - message : string option; [@default None] [@key "message"] -} -[@@deriving yojson { strict = false }, show, eq] -(** Describes the result of uploading an image resource *) -let create () : t = { code = None; _type = None; message = None } + + + type t = { + code: int32 + + option [@default None] + + + ; [@key "code"] + _type: string + + option [@default None] + + + ; [@key "type"] + message: string + + option [@default None] + + + ; [@key "message"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** Describes the result of uploading an image resource *) + let create () : t = { + code = None; + _type = None; + message = None; + } + + diff --git a/samples/client/petstore/ocaml/src/models/category.ml b/samples/client/petstore/ocaml/src/models/category.ml index 7b6ea140558e..cb63d1c6ff83 100644 --- a/samples/client/petstore/ocaml/src/models/category.ml +++ b/samples/client/petstore/ocaml/src/models/category.ml @@ -6,11 +6,28 @@ * Schema Category.t : A category for a pet *) -type t = { - id : int64 option; [@default None] [@key "id"] - name : string option; [@default None] [@key "name"] -} -[@@deriving yojson { strict = false }, show, eq] -(** A category for a pet *) -let create () : t = { id = None; name = None } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + name: string + + option [@default None] + + + ; [@key "name"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** A category for a pet *) + let create () : t = { + id = None; + name = None; + } + + diff --git a/samples/client/petstore/ocaml/src/models/order.ml b/samples/client/petstore/ocaml/src/models/order.ml index b661dfa06b60..3e4e63cda43d 100644 --- a/samples/client/petstore/ocaml/src/models/order.ml +++ b/samples/client/petstore/ocaml/src/models/order.ml @@ -6,24 +6,57 @@ * Schema Order.t : An order for a pets from the pet store *) -type t = { - id : int64 option; [@default None] [@key "id"] - pet_id : int64 option; [@default None] [@key "petId"] - quantity : int32 option; [@default None] [@key "quantity"] - ship_date : string option; [@default None] [@key "shipDate"] - (* Order Status *) - status : Enums.status option; [@default None] [@key "status"] - complete : bool option; [@default None] [@key "complete"] -} -[@@deriving yojson { strict = false }, show, eq] -(** An order for a pets from the pet store *) -let create () : t = - { - id = None; - pet_id = None; - quantity = None; - ship_date = None; - status = None; - complete = None; - } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + pet_id: int64 + + option [@default None] + + + ; [@key "petId"] + quantity: int32 + + option [@default None] + + + ; [@key "quantity"] + ship_date: string + + option [@default None] + + + ; [@key "shipDate"] + (* Order Status *) + status: Enums.status + option [@default + + None + ] + ; [@key "status"] + complete: bool + + option [@default None] + + + ; [@key "complete"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** An order for a pets from the pet store *) + let create () : t = { + id = None; + pet_id = None; + quantity = None; + ship_date = None; + status = None; + complete = None; + } + + diff --git a/samples/client/petstore/ocaml/src/models/pet.ml b/samples/client/petstore/ocaml/src/models/pet.ml index bfeff9aa3aaa..af5288538870 100644 --- a/samples/client/petstore/ocaml/src/models/pet.ml +++ b/samples/client/petstore/ocaml/src/models/pet.ml @@ -6,16 +6,53 @@ * Schema Pet.t : A pet for sale in the pet store *) -type t = { - id : int64 option; [@default None] [@key "id"] - category : Category.t option; [@default None] [@key "category"] - name : string; [@key "name"] - photo_urls : string list; [@key "photoUrls"] - tags : Tag.t list; [@default []] [@key "tags"] (* pet status in the store *) - status : Enums.pet_status option; [@default None] [@key "status"] -} -[@@deriving yojson { strict = false }, show, eq] -(** A pet for sale in the pet store *) -let create (name : string) (photo_urls : string list) : t = - { id = None; category = None; name; photo_urls; tags = []; status = None } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + category: Category.t + + option [@default None] + + + ; [@key "category"] + name: string + + + + + ; [@key "name"] + photo_urls: string list + + + ; [@key "photoUrls"] + tags: Tag.t list + [@default []] + + ; [@key "tags"] + (* pet status in the store *) + status: Enums.pet_status + option [@default + + None + ] + ; [@key "status"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** A pet for sale in the pet store *) + let create (name : string) (photo_urls : string list) : t = { + id = None; + category = None; + name = name; + photo_urls = photo_urls; + tags = []; + status = None; + } + + diff --git a/samples/client/petstore/ocaml/src/models/tag.ml b/samples/client/petstore/ocaml/src/models/tag.ml index 92ddc86c19d9..8a4cd6418109 100644 --- a/samples/client/petstore/ocaml/src/models/tag.ml +++ b/samples/client/petstore/ocaml/src/models/tag.ml @@ -6,11 +6,28 @@ * Schema Tag.t : A tag for a pet *) -type t = { - id : int64 option; [@default None] [@key "id"] - name : string option; [@default None] [@key "name"] -} -[@@deriving yojson { strict = false }, show, eq] -(** A tag for a pet *) -let create () : t = { id = None; name = None } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + name: string + + option [@default None] + + + ; [@key "name"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** A tag for a pet *) + let create () : t = { + id = None; + name = None; + } + + diff --git a/samples/client/petstore/ocaml/src/models/user.ml b/samples/client/petstore/ocaml/src/models/user.ml index e52dd96561bc..4f79bf2b71c0 100644 --- a/samples/client/petstore/ocaml/src/models/user.ml +++ b/samples/client/petstore/ocaml/src/models/user.ml @@ -6,28 +6,71 @@ * Schema User.t : A User who is purchasing from the pet store *) -type t = { - id : int64 option; [@default None] [@key "id"] - username : string option; [@default None] [@key "username"] - first_name : string option; [@default None] [@key "firstName"] - last_name : string option; [@default None] [@key "lastName"] - email : string option; [@default None] [@key "email"] - password : string option; [@default None] [@key "password"] - phone : string option; [@default None] [@key "phone"] - (* User Status *) - user_status : int32 option; [@default None] [@key "userStatus"] -} -[@@deriving yojson { strict = false }, show, eq] -(** A User who is purchasing from the pet store *) -let create () : t = - { - id = None; - username = None; - first_name = None; - last_name = None; - email = None; - password = None; - phone = None; - user_status = None; - } + + + type t = { + id: int64 + + option [@default None] + + + ; [@key "id"] + username: string + + option [@default None] + + + ; [@key "username"] + first_name: string + + option [@default None] + + + ; [@key "firstName"] + last_name: string + + option [@default None] + + + ; [@key "lastName"] + email: string + + option [@default None] + + + ; [@key "email"] + password: string + + option [@default None] + + + ; [@key "password"] + phone: string + + option [@default None] + + + ; [@key "phone"] + (* User Status *) + user_status: int32 + + option [@default None] + + + ; [@key "userStatus"] + } [@@deriving yojson { strict = false }, show, eq ];; + + (** A User who is purchasing from the pet store *) + let create () : t = { + id = None; + username = None; + first_name = None; + last_name = None; + email = None; + password = None; + phone = None; + user_status = None; + } + + diff --git a/samples/client/petstore/ocaml/src/support/enums.ml b/samples/client/petstore/ocaml/src/support/enums.ml index e93e6430e667..4e4c2d61edc0 100644 --- a/samples/client/petstore/ocaml/src/support/enums.ml +++ b/samples/client/petstore/ocaml/src/support/enums.ml @@ -5,36 +5,26 @@ * *) -type status = - [ `Placed - [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] - [@name "placed"] - | `Approved - [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] - [@name "approved"] - | `Delivered - [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] - [@name "delivered"] ] -[@@deriving yojson, show { with_path = false }, eq] - -let status_of_yojson json = status_of_yojson (`List [ json ]) +type status = [ +| `Placed [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] [@name "placed"] +| `Approved [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] [@name "approved"] +| `Delivered [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] [@name "delivered"] +] [@@deriving yojson, show { with_path = false }, eq];; +let status_of_yojson json = status_of_yojson (`List [json]) let status_to_yojson e = - match status_to_yojson e with `List [ json ] -> json | json -> json - -type pet_status = - [ `Available - [@printer fun fmt _ -> Format.pp_print_string fmt "available"] - [@name "available"] - | `Pending - [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] - [@name "pending"] - | `Sold - [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] - [@name "sold"] ] -[@@deriving yojson, show { with_path = false }, eq] + match status_to_yojson e with + | `List [json] -> json + | json -> json -let pet_status_of_yojson json = pet_status_of_yojson (`List [ json ]) +type pet_status = [ +| `Available [@printer fun fmt _ -> Format.pp_print_string fmt "available"] [@name "available"] +| `Pending [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] [@name "pending"] +| `Sold [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] [@name "sold"] +] [@@deriving yojson, show { with_path = false }, eq];; +let pet_status_of_yojson json = pet_status_of_yojson (`List [json]) let pet_status_to_yojson e = - match pet_status_to_yojson e with `List [ json ] -> json | json -> json + match pet_status_to_yojson e with + | `List [json] -> json + | json -> json diff --git a/samples/client/petstore/ocaml/src/support/jsonSupport.ml b/samples/client/petstore/ocaml/src/support/jsonSupport.ml index 9b4d882c3c12..0af0c25e759a 100644 --- a/samples/client/petstore/ocaml/src/support/jsonSupport.ml +++ b/samples/client/petstore/ocaml/src/support/jsonSupport.ml @@ -1,55 +1,68 @@ open Ppx_deriving_yojson_runtime let unwrap to_json json = - match to_json json with - | Result.Ok json -> json - | Result.Error s -> failwith s + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s let to_int json = - match json with - | `Int x -> x - | `Intlit s -> int_of_string s - | _ -> failwith "JsonSupport.to_int" + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" let to_bool json = - match json with `Bool x -> x | _ -> failwith "JsonSupport.to_bool" + match json with + | `Bool x -> x + | _ -> failwith "JsonSupport.to_bool" let to_float json = - match json with `Float x -> x | _ -> failwith "JsonSupport.to_float" + match json with + | `Float x -> x + | _ -> failwith "JsonSupport.to_float" let to_string json = - match json with `String s -> s | _ -> failwith "JsonSupport.to_string" + match json with + | `String s -> s + | _ -> failwith "JsonSupport.to_string" let to_int32 json : int32 = - match json with - | `Int x -> Int32.of_int x - | `Intlit s -> Int32.of_string s - | _ -> failwith "JsonSupport.to_int32" + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" let to_int64 json : int64 = - match json with - | `Int x -> Int64.of_int x - | `Intlit s -> Int64.of_string s - | _ -> failwith "JsonSupport.to_int64" + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" let of_int x = `Int x + let of_bool b = `Bool b + let of_float x = `Float x + let of_string s = `String s + let of_int32 x = `Intlit (Int32.to_string x) + let of_int64 x = `Intlit (Int64.to_string x) + let of_list_of of_f l = `List (Stdlib.List.map of_f l) + let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) let to_map_of of_f json = match json with | `Assoc l -> - Stdlib.List.fold_right - (fun (k, json) acc -> - match (of_f json, acc) with - | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> - Stdlib.Result.Ok ((k, parsed_v) :: tl) - | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e - | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) - l (Stdlib.Result.Ok []) + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml/src/support/request.ml b/samples/client/petstore/ocaml/src/support/request.ml index cc8a0fba248a..fea945d04cf3 100644 --- a/samples/client/petstore/ocaml/src/support/request.ml +++ b/samples/client/petstore/ocaml/src/support/request.ml @@ -1,9 +1,16 @@ let api_key = "" let base_url = "http://petstore.swagger.io/v2" let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" -let option_fold f default o = match o with Some v -> f v | None -> default + +let option_fold f default o = + match o with + | Some v -> f v + | None -> default + let build_uri operation_path = Uri.of_string (base_url ^ operation_path) -let add_string_header headers key value = Cohttp.Header.add headers key value + +let add_string_header headers key value = + Cohttp.Header.add headers key value let add_string_header_multi headers key values = Cohttp.Header.add_multi headers key values @@ -30,16 +37,13 @@ let write_as_json_body to_json payload = write_json_body (to_json payload) let handle_response resp on_success_handler = match Cohttp.Response.status resp with | #Cohttp.Code.success_status -> on_success_handler () - | s -> - failwith - ("Server responded with status " - ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) let read_json_body resp body = handle_response resp (fun () -> - Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string)) + (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) let read_json_body_as of_json resp body = Lwt.(read_json_body resp body >|= of_json) @@ -54,15 +58,11 @@ let read_json_body_as_map resp body = Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) let read_json_body_as_map_of of_json resp body = - Lwt.( - read_json_body_as_map resp body - >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) let replace_string_path_param uri param_name param_value = let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in - let path = - Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) - in + let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in Uri.with_path uri path let replace_path_param uri param_name to_string param_value = @@ -85,33 +85,26 @@ let maybe_add_query_param uri param_name to_string param_value = - [explode = true] - type [object] - See - https://swagger.io/docs/specification/v3_0/serialization/#query-parameters + See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters *) let add_query_param_exploded_form_object uri _param_name to_string param_value = - Stdlib.List.fold_left - (fun uri (param_name, param_value) -> - add_query_param uri param_name to_string param_value) - uri param_value +Stdlib.List.fold_left + (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) + uri + param_value let init_form_encoded_body () = "" let add_form_encoded_body_param params param_name to_string param_value = - let new_param_enc = - Printf.sprintf {|%s=%s|} - (Uri.pct_encode param_name) - (Uri.pct_encode (to_string param_value)) - in - if params = "" then new_param_enc + let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in + if params = "" + then new_param_enc else Printf.sprintf {|%s&%s|} params new_param_enc let add_form_encoded_body_param_list params param_name to_string new_params = - add_form_encoded_body_param params param_name (String.concat ",") - (to_string new_params) + add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) let maybe_add_form_encoded_body_param params param_name to_string param_value = - option_fold - (add_form_encoded_body_param params param_name to_string) - params param_value + option_fold (add_form_encoded_body_param params param_name to_string) params param_value let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body From e5a205a5d7c140a4002868a6bd1d0c1811d7e842 Mon Sep 17 00:00:00 2001 From: Julien Debon Date: Mon, 25 Aug 2025 18:07:39 +0200 Subject: [PATCH 4/4] Add myself for OCaml --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b30b6dd987c5..31532e1a4c88 100644 --- a/README.md +++ b/README.md @@ -1264,7 +1264,7 @@ If you want to join the committee, please kindly apply by sending an email to te | Nim | | | NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) | | ObjC | | -| OCaml | @cgensoul (2019/08) | +| OCaml | @cgensoul (2019/08), @sir4ur0n (2025/08) | | Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) | | PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), [@ybelenko](https://github.com/ybelenko) (2018/07), @renepardon (2018/12) | | PowerShell | @wing328 (2020/05) |