forked from loafle/openapi-generator-original
[OCaml] Code generation fixes (#12395)
* [ocaml] Open Lwt.Infix rather than Lwt The Lwt module has functions that might shadow parameters, and all the functions we use from Lwt are in Lwt.Infix too. File "src/apis/image_api.ml", line 13, characters 69-72: 13 | let uri = Request.maybe_add_query_param uri "all" string_of_bool all in ^^^ Error: This expression has type 'a t list -> 'a list t but an expression was expected of type bool option * [ocaml] update petstore samples
This commit is contained in:
parent
54dca39459
commit
5cce050260
@ -11,7 +11,7 @@
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
let {{{operationId}}} {{^hasParams}}(){{/hasParams}}{{#allParams}}{{> to_param}}{{^-last}} {{/-last}}{{#-last}}{{^required}} (){{/required}}{{/-last}}{{/allParams}} =
|
||||
let open Lwt in
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "{{{path}}}" in
|
||||
let headers = Request.default_headers in
|
||||
{{#hasAuthMethods}}
|
||||
|
@ -1 +1 @@
|
||||
5.0.1-SNAPSHOT
|
||||
6.0.0-SNAPSHOT
|
@ -24,4 +24,3 @@ dune build
|
||||
## Getting Started
|
||||
|
||||
TODO
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*)
|
||||
|
||||
let add_pet ~pet_t =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -14,7 +14,7 @@ let add_pet ~pet_t =
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let delete_pet ~pet_id ?api_key () =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -23,7 +23,7 @@ let delete_pet ~pet_id ?api_key () =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let find_pets_by_status ~status =
|
||||
let open Lwt in
|
||||
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" (List.map Enums.show_pet_status) status in
|
||||
@ -31,7 +31,7 @@ let find_pets_by_status ~status =
|
||||
Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let find_pets_by_tags ~tags =
|
||||
let open Lwt in
|
||||
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" (List.map (fun x -> x)) tags in
|
||||
@ -39,7 +39,7 @@ let find_pets_by_tags ~tags =
|
||||
Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let get_pet_by_id ~pet_id =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -48,7 +48,7 @@ let get_pet_by_id ~pet_id =
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let update_pet ~pet_t =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -56,7 +56,7 @@ let update_pet ~pet_t =
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let update_pet_with_form ~pet_id ?name ?status () =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -68,7 +68,7 @@ let update_pet_with_form ~pet_id ?name ?status () =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let upload_file ~pet_id ?additional_metadata ?file () =
|
||||
let open Lwt in
|
||||
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
|
||||
|
@ -6,7 +6,7 @@
|
||||
*)
|
||||
|
||||
let delete_order ~order_id =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -14,7 +14,7 @@ let delete_order ~order_id =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let get_inventory () =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -22,7 +22,7 @@ let get_inventory () =
|
||||
Request.read_json_body_as_map_of (JsonSupport.to_int32) resp body
|
||||
|
||||
let get_order_by_id ~order_id =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -30,7 +30,7 @@ let get_order_by_id ~order_id =
|
||||
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
|
||||
|
||||
let place_order ~order_t =
|
||||
let open Lwt in
|
||||
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
|
||||
|
@ -6,7 +6,7 @@
|
||||
*)
|
||||
|
||||
let create_user ~user_t =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -15,7 +15,7 @@ let create_user ~user_t =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let create_users_with_array_input ~user =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -24,7 +24,7 @@ let create_users_with_array_input ~user =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let create_users_with_list_input ~user =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -33,7 +33,7 @@ let create_users_with_list_input ~user =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let delete_user ~username =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -42,7 +42,7 @@ let delete_user ~username =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let get_user_by_name ~username =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -50,7 +50,7 @@ let get_user_by_name ~username =
|
||||
Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body
|
||||
|
||||
let login_user ~username ~password =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -59,7 +59,7 @@ let login_user ~username ~password =
|
||||
Request.read_json_body_as (JsonSupport.to_string) resp body
|
||||
|
||||
let logout_user () =
|
||||
let open Lwt in
|
||||
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
|
||||
@ -67,7 +67,7 @@ let logout_user () =
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let update_user ~username ~user_t =
|
||||
let open Lwt in
|
||||
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
|
||||
|
@ -39,8 +39,8 @@ let handle_response resp on_success_handler =
|
||||
| #Cohttp.Code.success_status -> on_success_handler ()
|
||||
| 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 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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user