mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 22:42:43 +00:00
Migrate OCaml petstore to use OAS v3 spec (#6348)
* migrate ocaml petstore to use oas3
* break the build
* Revert "break the build"
This reverts commit a7c12d90fe.
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
*
|
||||
*)
|
||||
|
||||
let add_pet ~body =
|
||||
let add_pet ~pet_t =
|
||||
let open Lwt in
|
||||
let uri = Request.build_uri "/pet" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.write_as_json_body Pet.to_yojson body 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
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let delete_pet ~pet_id ?api_key () =
|
||||
let open Lwt in
|
||||
@@ -47,13 +47,13 @@ let get_pet_by_id ~pet_id =
|
||||
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 ~body =
|
||||
let update_pet ~pet_t =
|
||||
let open Lwt in
|
||||
let uri = Request.build_uri "/pet" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.write_as_json_body Pet.to_yojson body 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
|
||||
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
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*
|
||||
*)
|
||||
|
||||
val add_pet : body:Pet.t -> unit Lwt.t
|
||||
val add_pet : pet_t:Pet.t -> Pet.t Lwt.t
|
||||
val delete_pet : pet_id:int64 -> ?api_key:string -> unit -> unit Lwt.t
|
||||
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 : body:Pet.t -> unit 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
|
||||
|
||||
@@ -29,11 +29,11 @@ let get_order_by_id ~order_id =
|
||||
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 ~body =
|
||||
let place_order ~order_t =
|
||||
let open Lwt 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 body 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
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
val delete_order : order_id:string -> unit Lwt.t
|
||||
val get_inventory : unit -> (string * int32) list Lwt.t
|
||||
val get_order_by_id : order_id:int64 -> Order.t Lwt.t
|
||||
val place_order : body:Order.t -> Order.t Lwt.t
|
||||
val place_order : order_t:Order.t -> Order.t Lwt.t
|
||||
|
||||
@@ -5,27 +5,30 @@
|
||||
*
|
||||
*)
|
||||
|
||||
let create_user ~body =
|
||||
let create_user ~user_t =
|
||||
let open Lwt in
|
||||
let uri = Request.build_uri "/user" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.write_as_json_body User.to_yojson body 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 ~body =
|
||||
let create_users_with_array_input ~user =
|
||||
let open Lwt 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) body 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 ~body =
|
||||
let create_users_with_list_input ~user =
|
||||
let open Lwt 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) body 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
|
||||
|
||||
@@ -33,6 +36,7 @@ let delete_user ~username =
|
||||
let open Lwt 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
|
||||
@@ -58,15 +62,17 @@ let logout_user () =
|
||||
let open Lwt 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 ~body =
|
||||
let update_user ~username ~user_t =
|
||||
let open Lwt 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 body 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
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*
|
||||
*)
|
||||
|
||||
val create_user : body:User.t -> unit Lwt.t
|
||||
val create_users_with_array_input : body:User.t list -> unit Lwt.t
|
||||
val create_users_with_list_input : body:User.t list -> unit Lwt.t
|
||||
val create_user : user_t:User.t -> unit Lwt.t
|
||||
val create_users_with_array_input : user:User.t list -> unit Lwt.t
|
||||
val create_users_with_list_input : user:User.t list -> unit Lwt.t
|
||||
val delete_user : username:string -> unit Lwt.t
|
||||
val get_user_by_name : username:string -> User.t Lwt.t
|
||||
val login_user : username:string -> password:string -> string Lwt.t
|
||||
val logout_user : unit -> unit Lwt.t
|
||||
val update_user : username:string -> body:User.t -> unit Lwt.t
|
||||
val update_user : username:string -> user_t:User.t -> unit Lwt.t
|
||||
|
||||
19
samples/client/petstore/ocaml/src/models/inline_object.ml
Normal file
19
samples/client/petstore/ocaml/src/models/inline_object.ml
Normal file
@@ -0,0 +1,19 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
19
samples/client/petstore/ocaml/src/models/inline_object_1.ml
Normal file
19
samples/client/petstore/ocaml/src/models/inline_object_1.ml
Normal file
@@ -0,0 +1,19 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user