Skip to content

Commit 0f70f91

Browse files
committed
Fix free-form body params
1 parent fb4c946 commit 0f70f91

File tree

11 files changed

+58
-34
lines changed

11 files changed

+58
-34
lines changed

modules/openapi-generator/src/main/resources/ocaml/api-impl.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ let {{{operationId}}} {{^hasParams}}(){{/hasParams}}{{#allParams}}{{> to_param}}
4343
{{/hasAuthMethods}}
4444
{{#bodyParams}}
4545
let body = Request.
46-
{{#isFreeFormObject}}write_json_body {{{paramName}}}{{/isFreeFormObject}}
4746
{{#isByteArray}}write_string_body {{{paramName}}}{{/isByteArray}}
48-
{{^isFreeFormObject}}{{^isByteArray}}write_as_json_body {{> to_json}} {{{paramName}}}{{/isByteArray}}{{/isFreeFormObject}}
47+
{{^isByteArray}}write_as_json_body {{> to_json}} {{{paramName}}}{{/isByteArray}}
4948
in
5049
{{/bodyParams}}
5150
{{^hasBodyParam}}

modules/openapi-generator/src/main/resources/ocaml/to_json.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
{{/isContainer}}
3434
{{/isModel}}
3535
{{#isBinary}}JsonSupport.of_string{{/isBinary}}
36+
{{#isAnyType}}(fun x -> x){{/isAnyType}}

samples/client/petstore/ocaml-fake-petstore/src/apis/another_fake_api.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ let call_123_test_special_tags ~client_t =
1111
let headers = Request.default_headers in
1212
let body = Request.
1313

14-
1514
write_as_json_body
1615

1716

@@ -21,6 +20,7 @@ let call_123_test_special_tags ~client_t =
2120

2221
Client.to_yojson
2322

23+
2424
client_t
2525
in
2626
Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) ->

samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ let fake_http_signature_test ~pet_t ?query_1 ?header_1 () =
5555
query_1 in
5656
let body = Request.
5757

58-
5958
write_as_json_body
6059

6160

@@ -65,6 +64,7 @@ let fake_http_signature_test ~pet_t ?query_1 ?header_1 () =
6564

6665
Pet.to_yojson
6766

67+
6868
pet_t
6969
in
7070
Cohttp_lwt_unix.Client.call `GET uri ~headers ~body >>= fun (resp, body) ->
@@ -76,7 +76,6 @@ let fake_outer_boolean_serialize ~body () =
7676
let headers = Request.default_headers in
7777
let body = Request.
7878

79-
8079
write_as_json_body
8180

8281

@@ -85,6 +84,7 @@ let fake_outer_boolean_serialize ~body () =
8584

8685
JsonSupport.of_bool
8786

87+
8888
body
8989
in
9090
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -96,7 +96,6 @@ let fake_outer_composite_serialize ~outer_composite_t () =
9696
let headers = Request.default_headers in
9797
let body = Request.
9898

99-
10099
write_as_json_body
101100

102101

@@ -106,6 +105,7 @@ let fake_outer_composite_serialize ~outer_composite_t () =
106105

107106
Outer_composite.to_yojson
108107

108+
109109
outer_composite_t
110110
in
111111
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -117,7 +117,6 @@ let fake_outer_number_serialize ~body () =
117117
let headers = Request.default_headers in
118118
let body = Request.
119119

120-
121120
write_as_json_body
122121

123122

@@ -126,6 +125,7 @@ JsonSupport.of_float
126125

127126

128127

128+
129129
body
130130
in
131131
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -137,7 +137,6 @@ let fake_outer_string_serialize ~body () =
137137
let headers = Request.default_headers in
138138
let body = Request.
139139

140-
141140
write_as_json_body JsonSupport.of_string
142141

143142

@@ -146,6 +145,7 @@ let fake_outer_string_serialize ~body () =
146145

147146

148147

148+
149149
body
150150
in
151151
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -157,7 +157,6 @@ let fake_property_enum_integer_serialize ~outer_object_with_enum_property_t =
157157
let headers = Request.default_headers in
158158
let body = Request.
159159

160-
161160
write_as_json_body
162161

163162

@@ -167,6 +166,7 @@ let fake_property_enum_integer_serialize ~outer_object_with_enum_property_t =
167166

168167
Outer_object_with_enum_property.to_yojson
169168

169+
170170
outer_object_with_enum_property_t
171171
in
172172
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -177,9 +177,27 @@ let test_additional_properties_reference ~request_body =
177177
let uri = Request.build_uri "/fake/additionalProperties-reference" in
178178
let headers = Request.default_headers in
179179
let body = Request.
180-
write_json_body request_body
181-
182180

181+
write_as_json_body (JsonSupport.of_map_of
182+
183+
184+
185+
186+
187+
188+
189+
(fun x -> x)
190+
)
191+
192+
193+
194+
195+
196+
197+
198+
199+
200+
request_body
183201
in
184202
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
185203
Request.handle_unit_response resp
@@ -190,7 +208,6 @@ let test_body_with_binary ~body =
190208
let headers = Request.default_headers in
191209
let body = Request.
192210

193-
194211
write_as_json_body
195212

196213

@@ -199,6 +216,7 @@ let test_body_with_binary ~body =
199216

200217

201218
JsonSupport.of_string
219+
202220
body
203221
in
204222
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
@@ -210,7 +228,6 @@ let test_body_with_file_schema ~file_schema_test_class_t =
210228
let headers = Request.default_headers in
211229
let body = Request.
212230

213-
214231
write_as_json_body
215232

216233

@@ -220,6 +237,7 @@ let test_body_with_file_schema ~file_schema_test_class_t =
220237

221238
File_schema_test_class.to_yojson
222239

240+
223241
file_schema_test_class_t
224242
in
225243
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
@@ -246,7 +264,6 @@ let test_body_with_query_params ~query ~user_t =
246264
query in
247265
let body = Request.
248266

249-
250267
write_as_json_body
251268

252269

@@ -256,6 +273,7 @@ let test_body_with_query_params ~query ~user_t =
256273

257274
User.to_yojson
258275

276+
259277
user_t
260278
in
261279
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
@@ -267,7 +285,6 @@ let test_client_model ~client_t =
267285
let headers = Request.default_headers in
268286
let body = Request.
269287

270-
271288
write_as_json_body
272289

273290

@@ -277,6 +294,7 @@ let test_client_model ~client_t =
277294

278295
Client.to_yojson
279296

297+
280298
client_t
281299
in
282300
Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) ->
@@ -668,7 +686,6 @@ let test_inline_additional_properties ~request_body =
668686
let headers = Request.default_headers in
669687
let body = Request.
670688

671-
672689
write_as_json_body (JsonSupport.of_map_of JsonSupport.of_string
673690

674691

@@ -677,6 +694,7 @@ let test_inline_additional_properties ~request_body =
677694

678695

679696

697+
680698
)
681699

682700

@@ -686,6 +704,7 @@ let test_inline_additional_properties ~request_body =
686704

687705

688706

707+
689708
request_body
690709
in
691710
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -697,7 +716,6 @@ let test_inline_freeform_additional_properties ~test_inline_freeform_additional_
697716
let headers = Request.default_headers in
698717
let body = Request.
699718

700-
701719
write_as_json_body
702720

703721

@@ -707,6 +725,7 @@ let test_inline_freeform_additional_properties ~test_inline_freeform_additional_
707725

708726
Test_inline_freeform_additional_properties_request.to_yojson
709727

728+
710729
test_inline_freeform_additional_properties_request_t
711730
in
712731
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -757,7 +776,6 @@ let test_nullable ~child_with_nullable_t =
757776
let headers = Request.default_headers in
758777
let body = Request.
759778

760-
761779
write_as_json_body
762780

763781

@@ -767,6 +785,7 @@ let test_nullable ~child_with_nullable_t =
767785

768786
Child_with_nullable.to_yojson
769787

788+
770789
child_with_nullable_t
771790
in
772791
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -969,7 +988,6 @@ let test_string_map_reference ~request_body =
969988
let headers = Request.default_headers in
970989
let body = Request.
971990

972-
973991
write_as_json_body (JsonSupport.of_map_of JsonSupport.of_string
974992

975993

@@ -978,6 +996,7 @@ let test_string_map_reference ~request_body =
978996

979997

980998

999+
9811000
)
9821001

9831002

@@ -987,6 +1006,7 @@ let test_string_map_reference ~request_body =
9871006

9881007

9891008

1009+
9901010
request_body
9911011
in
9921012
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->

samples/client/petstore/ocaml-fake-petstore/src/apis/fake_classname_tags123_api.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ let test_classname ~client_t =
1212
let uri = Uri.add_query_param' uri ("api_key_query", Request.api_key) in
1313
let body = Request.
1414

15-
1615
write_as_json_body
1716

1817

@@ -22,6 +21,7 @@ let test_classname ~client_t =
2221

2322
Client.to_yojson
2423

24+
2525
client_t
2626
in
2727
Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) ->

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ let add_pet ~pet_t =
1111
let headers = Request.default_headers in
1212
let body = Request.
1313

14-
1514
write_as_json_body
1615

1716

@@ -21,6 +20,7 @@ let add_pet ~pet_t =
2120

2221
Pet.to_yojson
2322

23+
2424
pet_t
2525
in
2626
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
@@ -138,7 +138,6 @@ let update_pet ~pet_t =
138138
let headers = Request.default_headers in
139139
let body = Request.
140140

141-
142141
write_as_json_body
143142

144143

@@ -148,6 +147,7 @@ let update_pet ~pet_t =
148147

149148
Pet.to_yojson
150149

150+
151151
pet_t
152152
in
153153
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ let place_order ~order_t =
6363
let headers = Request.default_headers in
6464
let body = Request.
6565

66-
6766
write_as_json_body
6867

6968

@@ -73,6 +72,7 @@ let place_order ~order_t =
7372

7473
Order.to_yojson
7574

75+
7676
order_t
7777
in
7878
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->

0 commit comments

Comments
 (0)