File tree Expand file tree Collapse file tree
modules/openapi-generator/src/test/resources/3_0/ocaml
ocaml-additional-properties/.openapi-generator
ocaml-enum-in-composed-schema/.openapi-generator
ocaml-fake-petstore/.openapi-generator
ocaml-oneOf-primitive/.openapi-generator Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11generatorName : ocaml
22outputDir : samples/client/petstore/ocaml-recursion-test
3- inputSpec : modules/openapi-generator/src/test/resources/3_0/recursion.yaml
3+ inputSpec : modules/openapi-generator/src/test/resources/3_0/ocaml/direct- recursion.yaml
44templateDir : modules/openapi-generator/src/main/resources/ocaml
55additionalProperties :
66 packageName : recursion_test
Original file line number Diff line number Diff line change 1+ openapi : 3.0.0
2+ info :
3+ description : |
4+ Test for direct recursive types in OCaml generator.
5+
6+ This spec only tests direct recursion (A -> A) and NOT mutual recursion (A -> B -> A).
7+
8+ The OCaml generator does not support mutual recursion because OCaml requires mutually
9+ recursive types to be declared together in the same file using "type a = ... and b = ..."
10+ syntax. The generator's architecture uses one model per file, making this infeasible.
11+
12+ Note: The generic test file modules/openapi-generator/src/test/resources/3_0/recursion.yaml
13+ contains both Foo (direct recursion) and Bar/Baz (mutual recursion), which is why we
14+ cannot use it for OCaml testing.
15+ version : 1.0.0
16+ title : OCaml Direct Recursion Test
17+ paths :
18+ /tree :
19+ get :
20+ operationId : getTree
21+ description : Get a tree structure
22+ responses :
23+ ' 200 ' :
24+ description : Success
25+ content :
26+ application/json :
27+ schema :
28+ $ref : ' #/components/schemas/Tree'
29+ /node :
30+ post :
31+ operationId : createNode
32+ description : Create a node
33+ requestBody :
34+ required : true
35+ content :
36+ application/json :
37+ schema :
38+ $ref : ' #/components/schemas/Node'
39+ responses :
40+ ' 201 ' :
41+ description : Created
42+ content :
43+ application/json :
44+ schema :
45+ $ref : ' #/components/schemas/Node'
46+ components :
47+ schemas :
48+ Tree :
49+ type : object
50+ description : A tree with optional children (direct self-reference)
51+ properties :
52+ value :
53+ type : integer
54+ format : int32
55+ children :
56+ type : array
57+ items :
58+ $ref : ' #/components/schemas/Tree'
59+ required :
60+ - value
61+
62+ Node :
63+ type : object
64+ description : A node with an optional self-reference
65+ properties :
66+ id :
67+ type : string
68+ next :
69+ $ref : ' #/components/schemas/Node'
70+ required :
71+ - id
Original file line number Diff line number Diff line change 11.ocamlformat
2+ .openapi-generator-ignore
23README.md
34dune
45dune-project
Original file line number Diff line number Diff line change 11.ocamlformat
2+ .openapi-generator-ignore
23README.md
34dune
45dune-project
Original file line number Diff line number Diff line change 11.ocamlformat
2+ .openapi-generator-ignore
23README.md
34dune
45dune-project
Original file line number Diff line number Diff line change 11.ocamlformat
2+ .openapi-generator-ignore
23README.md
34dune
45dune-project
Original file line number Diff line number Diff line change 11.ocamlformat
2+ .openapi-generator-ignore
23README.md
34dune
45dune-project
56recursion_test.opam
67src/apis/default_api.ml
78src/apis/default_api.mli
8- src/models/bar.ml
9- src/models/baz.ml
10- src/models/foo.ml
9+ src/models/node.ml
10+ src/models/tree.ml
1111src/support/enums.ml
1212src/support/jsonSupport.ml
1313src/support/request.ml
Original file line number Diff line number Diff line change 11#
2- Test
2+ Test for direct recursive types in OCaml generator.
3+
4+ This spec only tests direct recursion (A -> A) and NOT mutual recursion (A -> B -> A).
5+
6+ The OCaml generator does not support mutual recursion because OCaml requires mutually
7+ recursive types to be declared together in the same file using \' 'type a = ... and b = ...\' '
8+ syntax. The generator's architecture uses one model per file, making this infeasible.
9+
10+ Note: The generic test file modules/openapi-generator/src/test/resources/3_0/recursion.yaml
11+ contains both Foo (direct recursion) and Bar/Baz (mutual recursion), which is why we
12+ cannot use it for OCaml testing.
13+
314
415This OCaml package is automatically generated by the [ OpenAPI Generator] ( https://openapi-generator.tech ) project:
516
Original file line number Diff line number Diff line change 55 *
66 *)
77
8- let foo_post () =
8+ let create_node ~ node_t =
99 let open Lwt.Infix in
10- let uri = Request. build_uri " /foo " in
10+ let uri = Request. build_uri " /node " in
1111 let headers = Request. default_headers in
12- Cohttp_lwt_unix.Client. call `POST uri ~headers >> = fun (resp , body ) ->
13- Request. read_json_body_as (JsonSupport. unwrap Foo. of_yojson) resp body
12+ let body = Request.
13+
14+ write_as_json_body
15+
16+
17+
18+
19+
20+
21+ Node. to_yojson
22+
23+
24+
25+ node_t
26+ in
27+ Cohttp_lwt_unix.Client. call `POST uri ~headers ~body >> = fun (resp , body ) ->
28+ Request. read_json_body_as (JsonSupport. unwrap Node. of_yojson) resp body
29+
30+ let get_tree () =
31+ let open Lwt.Infix in
32+ let uri = Request. build_uri " /tree" in
33+ let headers = Request. default_headers in
34+ Cohttp_lwt_unix.Client. call `GET uri ~headers >> = fun (resp , body ) ->
35+ Request. read_json_body_as (JsonSupport. unwrap Tree. of_yojson) resp body
1436
Original file line number Diff line number Diff line change 55 *
66 *)
77
8- val foo_post : unit -> Foo .t Lwt .t
8+ val create_node : node_t :Node .t -> Node .t Lwt .t
9+ val get_tree : unit -> Tree .t Lwt .t
You can’t perform that action at this time.
0 commit comments