Skip to content

Commit 202d184

Browse files
authored
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 a7c12d9.
1 parent 583aa24 commit 202d184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+32
-1757
lines changed

bin/ocaml-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030

31-
args="generate -t modules/openapi-generator/src/main/resources/ocaml -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g ocaml -o samples/client/petstore/ocaml --additional-properties packageName=petstore_client $@"
31+
args="generate -t modules/openapi-generator/src/main/resources/ocaml -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ocaml -o samples/client/petstore/ocaml --additional-properties packageName=petstore_client $@"
3232

3333
echo "java ${JAVA_OPTS} -jar ${executable} ${args}"
3434
java $JAVA_OPTS -jar $executable $args

bin/openapi3/ocaml-client-petstore.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

bin/windows/ocaml-petstore.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
8-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g ocaml -o samples\client\petstore\ocaml
8+
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g ocaml -o samples\client\petstore\ocaml
99

1010
java %JAVA_OPTS% -jar %executable% %ags%
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.2-SNAPSHOT
1+
5.0.0-SNAPSHOT

samples/client/petstore/ocaml/src/apis/pet_api.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
*
66
*)
77

8-
let add_pet ~body =
8+
let add_pet ~pet_t =
99
let open Lwt in
1010
let uri = Request.build_uri "/pet" in
1111
let headers = Request.default_headers in
12-
let body = Request.write_as_json_body Pet.to_yojson body in
12+
let body = Request.write_as_json_body Pet.to_yojson pet_t in
1313
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
14-
Request.handle_unit_response resp
14+
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
1515

1616
let delete_pet ~pet_id ?api_key () =
1717
let open Lwt in
@@ -47,13 +47,13 @@ let get_pet_by_id ~pet_id =
4747
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
4848
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
4949

50-
let update_pet ~body =
50+
let update_pet ~pet_t =
5151
let open Lwt in
5252
let uri = Request.build_uri "/pet" in
5353
let headers = Request.default_headers in
54-
let body = Request.write_as_json_body Pet.to_yojson body in
54+
let body = Request.write_as_json_body Pet.to_yojson pet_t in
5555
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
56-
Request.handle_unit_response resp
56+
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
5757

5858
let update_pet_with_form ~pet_id ?name ?status () =
5959
let open Lwt in

samples/client/petstore/ocaml/src/apis/pet_api.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*
66
*)
77

8-
val add_pet : body:Pet.t -> unit Lwt.t
8+
val add_pet : pet_t:Pet.t -> Pet.t Lwt.t
99
val delete_pet : pet_id:int64 -> ?api_key:string -> unit -> unit Lwt.t
1010
val find_pets_by_status : status:Enums.pet_status list -> Pet.t list Lwt.t
1111
val find_pets_by_tags : tags:string list -> Pet.t list Lwt.t
1212
val get_pet_by_id : pet_id:int64 -> Pet.t Lwt.t
13-
val update_pet : body:Pet.t -> unit Lwt.t
13+
val update_pet : pet_t:Pet.t -> Pet.t Lwt.t
1414
val update_pet_with_form : pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t
1515
val upload_file : pet_id:int64 -> ?additional_metadata:string -> ?file:string -> unit -> Api_response.t Lwt.t

samples/client/petstore/ocaml/src/apis/store_api.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ let get_order_by_id ~order_id =
2929
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
3030
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
3131

32-
let place_order ~body =
32+
let place_order ~order_t =
3333
let open Lwt in
3434
let uri = Request.build_uri "/store/order" in
3535
let headers = Request.default_headers in
36-
let body = Request.write_as_json_body Order.to_yojson body in
36+
let body = Request.write_as_json_body Order.to_yojson order_t in
3737
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
3838
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
3939

samples/client/petstore/ocaml/src/apis/store_api.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
val delete_order : order_id:string -> unit Lwt.t
99
val get_inventory : unit -> (string * int32) list Lwt.t
1010
val get_order_by_id : order_id:int64 -> Order.t Lwt.t
11-
val place_order : body:Order.t -> Order.t Lwt.t
11+
val place_order : order_t:Order.t -> Order.t Lwt.t

samples/client/petstore/ocaml/src/apis/user_api.ml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,38 @@
55
*
66
*)
77

8-
let create_user ~body =
8+
let create_user ~user_t =
99
let open Lwt in
1010
let uri = Request.build_uri "/user" in
1111
let headers = Request.default_headers in
12-
let body = Request.write_as_json_body User.to_yojson body in
12+
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
13+
let body = Request.write_as_json_body User.to_yojson user_t in
1314
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
1415
Request.handle_unit_response resp
1516

16-
let create_users_with_array_input ~body =
17+
let create_users_with_array_input ~user =
1718
let open Lwt in
1819
let uri = Request.build_uri "/user/createWithArray" in
1920
let headers = Request.default_headers in
20-
let body = Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) body in
21+
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
22+
let body = Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user in
2123
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
2224
Request.handle_unit_response resp
2325

24-
let create_users_with_list_input ~body =
26+
let create_users_with_list_input ~user =
2527
let open Lwt in
2628
let uri = Request.build_uri "/user/createWithList" in
2729
let headers = Request.default_headers in
28-
let body = Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) body in
30+
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
31+
let body = Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user in
2932
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
3033
Request.handle_unit_response resp
3134

3235
let delete_user ~username =
3336
let open Lwt in
3437
let uri = Request.build_uri "/user/{username}" in
3538
let headers = Request.default_headers in
39+
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
3640
let uri = Request.replace_path_param uri "username" (fun x -> x) username in
3741
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
3842
Request.handle_unit_response resp
@@ -58,15 +62,17 @@ let logout_user () =
5862
let open Lwt in
5963
let uri = Request.build_uri "/user/logout" in
6064
let headers = Request.default_headers in
65+
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
6166
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
6267
Request.handle_unit_response resp
6368

64-
let update_user ~username ~body =
69+
let update_user ~username ~user_t =
6570
let open Lwt in
6671
let uri = Request.build_uri "/user/{username}" in
6772
let headers = Request.default_headers in
73+
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
6874
let uri = Request.replace_path_param uri "username" (fun x -> x) username in
69-
let body = Request.write_as_json_body User.to_yojson body in
75+
let body = Request.write_as_json_body User.to_yojson user_t in
7076
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
7177
Request.handle_unit_response resp
7278

samples/client/petstore/ocaml/src/apis/user_api.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*
66
*)
77

8-
val create_user : body:User.t -> unit Lwt.t
9-
val create_users_with_array_input : body:User.t list -> unit Lwt.t
10-
val create_users_with_list_input : body:User.t list -> unit Lwt.t
8+
val create_user : user_t:User.t -> unit Lwt.t
9+
val create_users_with_array_input : user:User.t list -> unit Lwt.t
10+
val create_users_with_list_input : user:User.t list -> unit Lwt.t
1111
val delete_user : username:string -> unit Lwt.t
1212
val get_user_by_name : username:string -> User.t Lwt.t
1313
val login_user : username:string -> password:string -> string Lwt.t
1414
val logout_user : unit -> unit Lwt.t
15-
val update_user : username:string -> body:User.t -> unit Lwt.t
15+
val update_user : username:string -> user_t:User.t -> unit Lwt.t

0 commit comments

Comments
 (0)