Skip to content

Commit fbb46ed

Browse files
committed
Add OCaml fake-petstore to test corner cases
1 parent 490de02 commit fbb46ed

70 files changed

Lines changed: 2471 additions & 0 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ samples/openapi3/client/petstore/go/privatekey.pem
296296

297297
## OCaml
298298
samples/client/petstore/ocaml/_build/
299+
samples/client/petstore/ocaml-fake-petstore/_build/
299300

300301
# jetbrain http client
301302
samples/client/jetbrains/adyen/checkout71/http/client/Apis/http-client.private.env.json
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: ocaml
2+
outputDir: samples/client/petstore/ocaml-fake-petstore
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/ocaml
5+
additionalProperties:
6+
packageName: petstore_client
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
README.md
2+
dune
3+
dune-project
4+
petstore_client.opam
5+
src/apis/another_fake_api.ml
6+
src/apis/another_fake_api.mli
7+
src/apis/default_api.ml
8+
src/apis/default_api.mli
9+
src/apis/fake_api.ml
10+
src/apis/fake_api.mli
11+
src/apis/fake_classname_tags123_api.ml
12+
src/apis/fake_classname_tags123_api.mli
13+
src/apis/pet_api.ml
14+
src/apis/pet_api.mli
15+
src/apis/store_api.ml
16+
src/apis/store_api.mli
17+
src/apis/user_api.ml
18+
src/apis/user_api.mli
19+
src/models/additional_properties_class.ml
20+
src/models/all_of_with_single_ref.ml
21+
src/models/animal.ml
22+
src/models/api_response.ml
23+
src/models/array_of_array_of_number_only.ml
24+
src/models/array_of_number_only.ml
25+
src/models/array_test.ml
26+
src/models/capitalization.ml
27+
src/models/cat.ml
28+
src/models/category.ml
29+
src/models/child_with_nullable.ml
30+
src/models/class_model.ml
31+
src/models/client.ml
32+
src/models/deprecated_object.ml
33+
src/models/dog.ml
34+
src/models/enum_arrays.ml
35+
src/models/enum_test.ml
36+
src/models/fake_big_decimal_map_200_response.ml
37+
src/models/file.ml
38+
src/models/file_schema_test_class.ml
39+
src/models/foo.ml
40+
src/models/format_test.ml
41+
src/models/has_only_read_only.ml
42+
src/models/health_check_result.ml
43+
src/models/list.ml
44+
src/models/map_test.ml
45+
src/models/mixed_properties_and_additional_properties_class.ml
46+
src/models/model_200_response.ml
47+
src/models/model__foo_get_default_response.ml
48+
src/models/model__special_model_name_.ml
49+
src/models/name.ml
50+
src/models/nullable_class.ml
51+
src/models/number_only.ml
52+
src/models/object_with_deprecated_fields.ml
53+
src/models/order.ml
54+
src/models/outer_composite.ml
55+
src/models/outer_object_with_enum_property.ml
56+
src/models/parent_with_nullable.ml
57+
src/models/pet.ml
58+
src/models/read_only_first.ml
59+
src/models/return.ml
60+
src/models/tag.ml
61+
src/models/test_inline_freeform_additional_properties_request.ml
62+
src/models/user.ml
63+
src/support/enums.ml
64+
src/support/jsonSupport.ml
65+
src/support/request.ml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.15.0-SNAPSHOT
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \'' \\
3+
4+
This OCaml package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
5+
6+
- API version: 1.0.0
7+
- Package version: 1.0.0
8+
- Generator version: 7.15.0-SNAPSHOT
9+
- Build package: org.openapitools.codegen.languages.OCamlClientCodegen
10+
11+
## Requirements.
12+
13+
OCaml 5.x
14+
15+
## Installation
16+
17+
Please run the following commands to build the package `petstore_client`:
18+
19+
```sh
20+
opam install . --deps-only --with-test
21+
eval $(opam env)
22+
dune build
23+
```
24+
25+
## Getting Started
26+
27+
The generated directory structure is:
28+
- `src/apis`: contains several modules, each with several functions. Each function is an API endpoint.
29+
- `src/models`: contains several modules. Each module contains:
30+
- a type `t` representing an input and/or output schema of the OpenAPI spec
31+
- a smart constructor `create` for this type
32+
- `src/support`: various modules used by the generated APIs and Models
33+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(include_subdirs unqualified)
2+
(library
3+
(name petstore_client)
4+
(public_name petstore_client)
5+
(flags (:standard -w -27))
6+
(libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime)
7+
(preprocess (pps ppx_deriving_yojson ppx_deriving.std))
8+
(wrapped true)
9+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(lang dune 1.10)
2+
(name petstore_client)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
opam-version: "2.0"
2+
name: "petstore_client"
3+
version: "1.0.0"
4+
synopsis: ""
5+
description: """
6+
Longer description
7+
"""
8+
maintainer: "Name <email>"
9+
authors: "Name <email>"
10+
license: ""
11+
homepage: ""
12+
bug-reports: ""
13+
dev-repo: ""
14+
depends: [
15+
"ocaml"
16+
"ocamlfind"
17+
"dune"
18+
"ppx_deriving_yojson"
19+
"conf-libev"
20+
"lwt"
21+
"cohttp-lwt-unix" {< "6.0.0"}
22+
"cohttp-async" {< "6.0.0"}
23+
]
24+
build: ["dune" "build" "-p" name]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(*
2+
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
3+
*
4+
* Generated by: https://openapi-generator.tech
5+
*
6+
*)
7+
8+
let call_123_test_special_tags ~client_t =
9+
let open Lwt.Infix in
10+
let uri = Request.build_uri "/another-fake/dummy" in
11+
let headers = Request.default_headers in
12+
let body = Request.write_as_json_body Client.to_yojson client_t in
13+
Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) ->
14+
Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body
15+

0 commit comments

Comments
 (0)