diff --git a/.github/workflows/samples-ocaml.yaml b/.github/workflows/samples-ocaml.yaml index 9206c578d893..f74a736469b2 100644 --- a/.github/workflows/samples-ocaml.yaml +++ b/.github/workflows/samples-ocaml.yaml @@ -5,12 +5,14 @@ on: paths: - 'samples/client/petstore/ocaml/**' - 'samples/client/petstore/ocaml-fake-petstore/**' - - 'samples/client/petstore/ocaml-oneOf/**' + - 'samples/client/petstore/ocaml-oneOf-primitive/**' + - 'samples/client/petstore/ocaml-additional-properties/**' pull_request: paths: - 'samples/client/petstore/ocaml/**' - 'samples/client/petstore/ocaml-fake-petstore/**' - - 'samples/client/petstore/ocaml-oneOf/**' + - 'samples/client/petstore/ocaml-oneOf-primitive/**' + - 'samples/client/petstore/ocaml-additional-properties/**' jobs: build: @@ -22,7 +24,8 @@ jobs: sample: - 'samples/client/petstore/ocaml/' - 'samples/client/petstore/ocaml-fake-petstore/' - - 'samples/client/petstore/ocaml-oneOf/' + - 'samples/client/petstore/ocaml-oneOf-primitive/' + - 'samples/client/petstore/ocaml-additional-properties/' steps: - uses: actions/checkout@v5 - name: Set-up OCaml diff --git a/.gitignore b/.gitignore index 36854746a1f0..f2947eafd4a3 100644 --- a/.gitignore +++ b/.gitignore @@ -297,7 +297,8 @@ samples/openapi3/client/petstore/go/privatekey.pem ## OCaml samples/client/petstore/ocaml/_build/ samples/client/petstore/ocaml-fake-petstore/_build/ -samples/client/petstore/ocaml-oneOf/_build/ +samples/client/petstore/ocaml-oneOf-primitive/_build/ +samples/client/petstore/ocaml-additional-properties/_build/ # jetbrain http client samples/client/jetbrains/adyen/checkout71/http/client/Apis/http-client.private.env.json diff --git a/bin/configs/ocaml-additional-properties.yaml b/bin/configs/ocaml-additional-properties.yaml new file mode 100644 index 000000000000..40581bebc37d --- /dev/null +++ b/bin/configs/ocaml-additional-properties.yaml @@ -0,0 +1,6 @@ +generatorName: ocaml +outputDir: samples/client/petstore/ocaml-additional-properties +inputSpec: modules/openapi-generator/src/test/resources/3_0/ocaml/additional-properties.yaml +templateDir: modules/openapi-generator/src/main/resources/ocaml +additionalProperties: + packageName: petstore_client diff --git a/bin/configs/ocaml-oneOf.yaml b/bin/configs/ocaml-oneOf-primitive.yaml similarity index 79% rename from bin/configs/ocaml-oneOf.yaml rename to bin/configs/ocaml-oneOf-primitive.yaml index 7bd6601e2c9f..a124b41386bb 100644 --- a/bin/configs/ocaml-oneOf.yaml +++ b/bin/configs/ocaml-oneOf-primitive.yaml @@ -1,5 +1,5 @@ generatorName: ocaml -outputDir: samples/client/petstore/ocaml-oneOf +outputDir: samples/client/petstore/ocaml-oneOf-primitive inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitive.yaml templateDir: modules/openapi-generator/src/main/resources/ocaml additionalProperties: diff --git a/modules/openapi-generator/src/main/resources/ocaml/model-record.mustache b/modules/openapi-generator/src/main/resources/ocaml/model-record.mustache index 6977aed0a4ca..058c31862a22 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/model-record.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/model-record.mustache @@ -1,8 +1,5 @@ type t = { {{#vars}} - {{#description}} - (* {{{.}}} *) - {{/description}} {{#isEnum}} {{{name}}}: {{^isMap}}Enums.{{/isMap}}{{{datatypeWithEnum}}} {{^isContainer}} @@ -28,9 +25,12 @@ type t = { {{^required}} option [@default None]{{/required}} {{/isContainer}} {{#isArray}}{{^required}} [@default []]{{/required}}{{/isArray}} - {{#isMap}}{{^required}} [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: {{{items.datatypeWithEnum}}}]] [@of_yojson JsonSupport.to_map_of [%of_yojson: {{{items.datatypeWithEnum}}}]] {{/required}}{{/isMap}} + {{#isMap}}{{^required}} [@default []]{{/required}} [@to_yojson JsonSupport.of_map_of [%to_yojson: {{{items.datatypeWithEnum}}}]] [@of_yojson JsonSupport.to_map_of [%of_yojson: {{{items.datatypeWithEnum}}}]]{{/isMap}} ; [@key "{{{baseName}}}"] {{/isEnum}} + {{#description}} + (** {{{.}}} *) + {{/description}} {{/vars}} } [@@deriving yojson { strict = false }, show, eq ];; diff --git a/modules/openapi-generator/src/test/resources/3_0/ocaml/additional-properties.yaml b/modules/openapi-generator/src/test/resources/3_0/ocaml/additional-properties.yaml new file mode 100644 index 000000000000..3d09d0fd3899 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/ocaml/additional-properties.yaml @@ -0,0 +1,52 @@ +# Test various flavors of additionalProperties +openapi: 3.0.0 +info: + title: Test + version: 1.0.0 +paths: {} +components: + schemas: + SomeObject: + required: + - required_field1 + - required_field2 + - required_field3 + properties: + required_field1: + type: object + description: Required, free-form + additionalProperties: {} + required_field2: + type: object + description: Required, dictionary of strings + additionalProperties: + type: string + required_field3: + type: object + description: Required, dictionary of objects + additionalProperties: + type: object + properties: + sub_field1: + type: number + sub_field2: + type: boolean + optional_field1: + type: object + description: Optional, free-form + additionalProperties: {} + optional_field2: + type: object + description: Optional, dictionary of strings + additionalProperties: + type: string + optional_field3: + type: object + description: Optional, dictionary of objects + additionalProperties: + type: object + properties: + sub_field1: + type: number + sub_field2: + type: boolean diff --git a/samples/client/petstore/ocaml-oneOf/.ocamlformat b/samples/client/petstore/ocaml-additional-properties/.ocamlformat similarity index 100% rename from samples/client/petstore/ocaml-oneOf/.ocamlformat rename to samples/client/petstore/ocaml-additional-properties/.ocamlformat diff --git a/samples/client/petstore/ocaml-oneOf/.openapi-generator-ignore b/samples/client/petstore/ocaml-additional-properties/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/ocaml-oneOf/.openapi-generator-ignore rename to samples/client/petstore/ocaml-additional-properties/.openapi-generator-ignore diff --git a/samples/client/petstore/ocaml-additional-properties/.openapi-generator/FILES b/samples/client/petstore/ocaml-additional-properties/.openapi-generator/FILES new file mode 100644 index 000000000000..6d2323cbcd30 --- /dev/null +++ b/samples/client/petstore/ocaml-additional-properties/.openapi-generator/FILES @@ -0,0 +1,10 @@ +.ocamlformat +README.md +dune +dune-project +petstore_client.opam +src/models/some_object.ml +src/models/some_object_required_field3_value.ml +src/support/enums.ml +src/support/jsonSupport.ml +src/support/request.ml diff --git a/samples/client/petstore/ocaml-oneOf/.openapi-generator/VERSION b/samples/client/petstore/ocaml-additional-properties/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/ocaml-oneOf/.openapi-generator/VERSION rename to samples/client/petstore/ocaml-additional-properties/.openapi-generator/VERSION diff --git a/samples/client/petstore/ocaml-oneOf/README.md b/samples/client/petstore/ocaml-additional-properties/README.md similarity index 100% rename from samples/client/petstore/ocaml-oneOf/README.md rename to samples/client/petstore/ocaml-additional-properties/README.md diff --git a/samples/client/petstore/ocaml-oneOf/dune b/samples/client/petstore/ocaml-additional-properties/dune similarity index 100% rename from samples/client/petstore/ocaml-oneOf/dune rename to samples/client/petstore/ocaml-additional-properties/dune diff --git a/samples/client/petstore/ocaml-oneOf/dune-project b/samples/client/petstore/ocaml-additional-properties/dune-project similarity index 100% rename from samples/client/petstore/ocaml-oneOf/dune-project rename to samples/client/petstore/ocaml-additional-properties/dune-project diff --git a/samples/client/petstore/ocaml-oneOf/petstore_client.opam b/samples/client/petstore/ocaml-additional-properties/petstore_client.opam similarity index 100% rename from samples/client/petstore/ocaml-oneOf/petstore_client.opam rename to samples/client/petstore/ocaml-additional-properties/petstore_client.opam diff --git a/samples/client/petstore/ocaml-additional-properties/src/models/some_object.ml b/samples/client/petstore/ocaml-additional-properties/src/models/some_object.ml new file mode 100644 index 000000000000..fe3c58d8c100 --- /dev/null +++ b/samples/client/petstore/ocaml-additional-properties/src/models/some_object.ml @@ -0,0 +1,53 @@ +(* + * This file has been generated by the OCamlClientCodegen generator for openapi-generator. + * + * Generated by: https://openapi-generator.tech + * + *) + + + + + type t = { + required_field1: (string * Yojson.Safe.t) list + + [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + ; [@key "required_field1"] + (** Required, free-form *) + required_field2: (string * string) list + + [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] + ; [@key "required_field2"] + (** Required, dictionary of strings *) + required_field3: (string * Some_object_required_field3_value.t) list + + [@to_yojson JsonSupport.of_map_of [%to_yojson: Some_object_required_field3_value.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Some_object_required_field3_value.t]] + ; [@key "required_field3"] + (** Required, dictionary of objects *) + optional_field1: (string * Yojson.Safe.t) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + ; [@key "optional_field1"] + (** Optional, free-form *) + optional_field2: (string * string) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] + ; [@key "optional_field2"] + (** Optional, dictionary of strings *) + optional_field3: (string * Some_object_required_field3_value.t) list + + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Some_object_required_field3_value.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Some_object_required_field3_value.t]] + ; [@key "optional_field3"] + (** Optional, dictionary of objects *) + } [@@deriving yojson { strict = false }, show, eq ];; + + let create (required_field1 : (string * Yojson.Safe.t) list) (required_field2 : (string * string) list) (required_field3 : (string * Some_object_required_field3_value.t) list) : t = { + required_field1 = required_field1; + required_field2 = required_field2; + required_field3 = required_field3; + optional_field1 = []; + optional_field2 = []; + optional_field3 = []; + } + + diff --git a/samples/client/petstore/ocaml-additional-properties/src/models/some_object_required_field3_value.ml b/samples/client/petstore/ocaml-additional-properties/src/models/some_object_required_field3_value.ml new file mode 100644 index 000000000000..298c6861909a --- /dev/null +++ b/samples/client/petstore/ocaml-additional-properties/src/models/some_object_required_field3_value.ml @@ -0,0 +1,31 @@ +(* + * This file has been generated by the OCamlClientCodegen generator for openapi-generator. + * + * Generated by: https://openapi-generator.tech + * + *) + + + + + type t = { + sub_field1: float + + option [@default None] + + + ; [@key "sub_field1"] + sub_field2: bool + + option [@default None] + + + ; [@key "sub_field2"] + } [@@deriving yojson { strict = false }, show, eq ];; + + let create () : t = { + sub_field1 = None; + sub_field2 = None; + } + + diff --git a/samples/client/petstore/ocaml-oneOf/src/support/enums.ml b/samples/client/petstore/ocaml-additional-properties/src/support/enums.ml similarity index 100% rename from samples/client/petstore/ocaml-oneOf/src/support/enums.ml rename to samples/client/petstore/ocaml-additional-properties/src/support/enums.ml diff --git a/samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml b/samples/client/petstore/ocaml-additional-properties/src/support/jsonSupport.ml similarity index 100% rename from samples/client/petstore/ocaml-oneOf/src/support/jsonSupport.ml rename to samples/client/petstore/ocaml-additional-properties/src/support/jsonSupport.ml diff --git a/samples/client/petstore/ocaml-additional-properties/src/support/request.ml b/samples/client/petstore/ocaml-additional-properties/src/support/request.ml new file mode 100644 index 000000000000..e83aaa36c6f3 --- /dev/null +++ b/samples/client/petstore/ocaml-additional-properties/src/support/request.ml @@ -0,0 +1,110 @@ +let api_key = "" +let base_url = "http://localhost" +let default_headers = Cohttp.Header.init_with "Content-Type" "application/json" + +let option_fold f default o = + match o with + | Some v -> f v + | None -> default + +let build_uri operation_path = Uri.of_string (base_url ^ operation_path) + +let add_string_header headers key value = + Cohttp.Header.add headers key value + +let add_string_header_multi headers key values = + Cohttp.Header.add_multi headers key values + +let add_header headers key to_string value = + Cohttp.Header.add headers key (to_string value) + +let add_header_multi headers key to_string value = + Cohttp.Header.add_multi headers key (to_string value) + +let maybe_add_header headers key to_string value = + option_fold (add_header headers key to_string) headers value + +let maybe_add_header_multi headers key to_string value = + option_fold (add_header_multi headers key to_string) headers value + +let write_string_body s = Cohttp_lwt.Body.of_string s + +let write_json_body payload = + Cohttp_lwt.Body.of_string (Yojson.Safe.to_string payload ~std:true) + +let write_as_json_body to_json payload = write_json_body (to_json payload) + +let handle_response resp on_success_handler = + match Cohttp.Response.status resp with + | #Cohttp.Code.success_status -> on_success_handler () + | s -> failwith ("Server responded with status " ^ Cohttp.Code.(reason_phrase_of_code (code_of_status s))) + +let handle_unit_response resp = handle_response resp (fun () -> Lwt.return ()) + +let read_json_body resp body = + handle_response resp (fun () -> + (Lwt.(Cohttp_lwt.Body.to_string body >|= Yojson.Safe.from_string))) + +let read_json_body_as of_json resp body = + Lwt.(read_json_body resp body >|= of_json) + +let read_json_body_as_list resp body = + Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_list) + +let read_json_body_as_list_of of_json resp body = + Lwt.(read_json_body_as_list resp body >|= Stdlib.List.map of_json) + +let read_json_body_as_map resp body = + Lwt.(read_json_body resp body >|= Yojson.Safe.Util.to_assoc) + +let read_json_body_as_map_of of_json resp body = + Lwt.(read_json_body_as_map resp body >|= Stdlib.List.map (fun (s, v) -> (s, of_json v))) + +let replace_string_path_param uri param_name param_value = + let regexp = Str.regexp (Str.quote ("{" ^ param_name ^ "}")) in + let path = Str.global_replace regexp param_value (Uri.pct_decode (Uri.path uri)) in + Uri.with_path uri path + +let replace_path_param uri param_name to_string param_value = + replace_string_path_param uri param_name (to_string param_value) + +let maybe_replace_path_param uri param_name to_string param_value = + option_fold (replace_path_param uri param_name to_string) uri param_value + +let add_query_param uri param_name to_string param_value = + Uri.add_query_param' uri (param_name, to_string param_value) + +let add_query_param_list uri param_name to_string param_value = + Uri.add_query_param uri (param_name, to_string param_value) + +let maybe_add_query_param uri param_name to_string param_value = + option_fold (add_query_param uri param_name to_string) uri param_value + +(** Corresponds to: + - [style = form] + - [explode = true] + - type [object] + + See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters +*) +let add_query_param_exploded_form_object uri _param_name to_string param_value = +Stdlib.List.fold_left + (fun uri (param_name, param_value) -> add_query_param uri param_name to_string param_value) + uri + param_value + +let init_form_encoded_body () = "" + +let add_form_encoded_body_param params param_name to_string param_value = + let new_param_enc = Printf.sprintf {|%s=%s|} (Uri.pct_encode param_name) (Uri.pct_encode (to_string param_value)) in + if params = "" + then new_param_enc + else Printf.sprintf {|%s&%s|} params new_param_enc + +let add_form_encoded_body_param_list params param_name to_string new_params = + add_form_encoded_body_param params param_name (String.concat ",") (to_string new_params) + +let maybe_add_form_encoded_body_param params param_name to_string param_value = + option_fold (add_form_encoded_body_param params param_name to_string) params param_value + +let finalize_form_encoded_body body = Cohttp_lwt.Body.of_string body diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml index 1070136f5dec..5063fff18cb2 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/additional_properties_class.ml @@ -9,15 +9,15 @@ type t = { - map_property: (string * string) list + map_property: (string * string) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: string]] [@of_yojson JsonSupport.to_map_of [%of_yojson: string]] ; [@key "map_property"] map_of_map_property: (string * (string * string) list) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] ; [@key "map_of_map_property"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { map_property = []; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml index 8824bf45851d..e9fbc6974d08 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/all_of_with_single_ref.ml @@ -9,7 +9,7 @@ type t = { - username: string + username: string option [@default None] @@ -21,7 +21,7 @@ ; [@key "SingleRefType"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { username = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml index bb9694548e1e..4f260d50deff 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/animal.ml @@ -9,7 +9,7 @@ type t = { - class_name: string + class_name: string @@ -21,7 +21,7 @@ ; [@key "color"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create (class_name : string) : t = { class_name = class_name; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml index 38c83657c392..bb32c58b4a94 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/api_response.ml @@ -9,7 +9,7 @@ type t = { - code: int32 + code: int32 option [@default None] @@ -27,7 +27,7 @@ ; [@key "message"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { code = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml index 17d2b550a3dc..ffbaf0f79799 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_array_of_number_only.ml @@ -9,11 +9,11 @@ type t = { - array_array_number: float list list + array_array_number: float list list [@default []] ; [@key "ArrayArrayNumber"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { array_array_number = []; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml index e4ea0cc597d1..3b120d64fcc0 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_of_number_only.ml @@ -9,11 +9,11 @@ type t = { - array_number: float list + array_number: float list [@default []] ; [@key "ArrayNumber"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { array_number = []; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml index 850e8d6d7197..86c856a7a52d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/array_test.ml @@ -9,7 +9,7 @@ type t = { - array_of_string: string list + array_of_string: string list [@default []] ; [@key "array_of_string"] @@ -21,7 +21,7 @@ [@default []] ; [@key "array_array_of_model"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { array_of_string = []; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml index 2725a870b917..a84e29517f4e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/capitalization.ml @@ -9,7 +9,7 @@ type t = { - small_camel: string + small_camel: string option [@default None] @@ -39,13 +39,13 @@ ; [@key "SCA_ETH_Flow_Points"] - (* Name of the pet *) - att_name: string + att_name: string option [@default None] ; [@key "ATT_NAME"] + (** Name of the pet *) } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml index d9dcd55ac0af..fd46380d6264 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/cat.ml @@ -9,7 +9,7 @@ type t = { - class_name: string + class_name: string @@ -27,7 +27,7 @@ ; [@key "declawed"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create (class_name : string) : t = { class_name = class_name; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml index 95e0b50ee994..4ca36aad1877 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/category.ml @@ -9,7 +9,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -21,7 +21,7 @@ ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create (name : string) : t = { id = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml index 61eba92d86ce..140de192fea2 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/child_with_nullable.ml @@ -9,7 +9,7 @@ type t = { - _type: Enums.parentwithnullable_type + _type: Enums.parentwithnullable_type option [@default Some(`ChildWithNullable) @@ -27,7 +27,7 @@ ; [@key "otherProperty"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { _type = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml index f63be054b150..87293dcf5e18 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/class_model.ml @@ -10,13 +10,13 @@ type t = { - _class: string + _class: string option [@default None] ; [@key "_class"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** Model for testing model with \''_class\'' property *) let create () : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml index d3b578e2509f..4042024bf7b9 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/client.ml @@ -9,13 +9,13 @@ type t = { - client: string + client: string option [@default None] ; [@key "client"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { client = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml index ff9a12f2eb4d..82ae75ff45b1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/deprecated_object.ml @@ -9,13 +9,13 @@ type t = { - name: string + name: string option [@default None] ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { name = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml index 004e9bb56406..d09cd17c78f5 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/dog.ml @@ -9,7 +9,7 @@ type t = { - class_name: string + class_name: string @@ -27,7 +27,7 @@ ; [@key "breed"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create (class_name : string) : t = { class_name = class_name; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml index 612cdf25beba..f7bacd12eddc 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_arrays.ml @@ -9,7 +9,7 @@ type t = { - just_symbol: Enums.just_symbol + just_symbol: Enums.just_symbol option [@default None @@ -17,7 +17,7 @@ ; [@key "just_symbol"] array_enum: Enums.array_enum list ; [@key "array_enum"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { just_symbol = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml index e9df9f2fec4e..723762807e17 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/enum_test.ml @@ -9,7 +9,7 @@ type t = { - enum_string: Enums.enum_string + enum_string: Enums.enum_string option [@default None @@ -54,7 +54,7 @@ ; [@key "outerEnumIntegerDefaultValue"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create (enum_string_required : Enums.enum_string) : t = { enum_string = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml index 6abba727a131..cb93e736d034 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/fake_big_decimal_map_200_response.ml @@ -9,7 +9,7 @@ type t = { - some_id: float + some_id: float option [@default None] @@ -17,9 +17,9 @@ ; [@key "someId"] some_map: (string * float) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: float]] [@of_yojson JsonSupport.to_map_of [%of_yojson: float]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: float]] [@of_yojson JsonSupport.to_map_of [%of_yojson: float]] ; [@key "someMap"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { some_id = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml index e02dec2b6bde..13edca85cfd5 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/file.ml @@ -10,13 +10,13 @@ type t = { - (* Test capitalization *) source_uri: string option [@default None] ; [@key "sourceURI"] + (** Test capitalization *) } [@@deriving yojson { strict = false }, show, eq ];; (** Must be named `File` for test. *) diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml index e9bb0b52c6b6..260221bc61f0 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/file_schema_test_class.ml @@ -9,7 +9,7 @@ type t = { - file: File.t + file: File.t option [@default None] @@ -19,7 +19,7 @@ [@default []] ; [@key "files"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { file = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml index a3f48385e0d7..c8318e946428 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/foo.ml @@ -9,13 +9,13 @@ type t = { - bar: string + bar: string option [@default None] ; [@key "bar"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { bar = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml index 03631a54e643..fef6fc57bf8f 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/format_test.ml @@ -9,7 +9,7 @@ type t = { - integer: int32 + integer: int32 option [@default None] @@ -93,20 +93,20 @@ ; [@key "password"] - (* A string that is a 10 digit number. Can have leading zeros. *) - pattern_with_digits: string + pattern_with_digits: string option [@default None] ; [@key "pattern_with_digits"] - (* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. *) - pattern_with_digits_and_delimiter: string + (** A string that is a 10 digit number. Can have leading zeros. *) + pattern_with_digits_and_delimiter: string option [@default None] ; [@key "pattern_with_digits_and_delimiter"] + (** A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. *) } [@@deriving yojson { strict = false }, show, eq ];; let create (number : float) (byte : string) (date : string) (password : string) : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml index cebf14ba37f9..f70fe56e0e7d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/has_only_read_only.ml @@ -9,7 +9,7 @@ type t = { - bar: string + bar: string option [@default None] @@ -21,7 +21,7 @@ ; [@key "foo"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { bar = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml index b58d7cd6cfeb..31dcc6713339 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/health_check_result.ml @@ -10,13 +10,13 @@ type t = { - nullable_message: string + nullable_message: string option [@default None] ; [@key "NullableMessage"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. *) let create () : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml index 13e71de7e641..075df435a5c2 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/list.ml @@ -9,13 +9,13 @@ type t = { - var_123_list: string + var_123_list: string option [@default None] ; [@key "123-list"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { var_123_list = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml index 22a05cd8e6d1..1ce39f20a3fe 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/map_test.ml @@ -9,21 +9,21 @@ type t = { - map_map_of_string: (string * (string * string) list) list + map_map_of_string: (string * (string * string) list) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: (string * string) list]] [@of_yojson JsonSupport.to_map_of [%of_yojson: (string * string) list]] ; [@key "map_map_of_string"] map_of_enum_string: (string * Enums.map_of_enum_string) list ; [@key "map_of_enum_string"] direct_map: (string * bool) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] ; [@key "direct_map"] indirect_map: (string * bool) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: bool]] [@of_yojson JsonSupport.to_map_of [%of_yojson: bool]] ; [@key "indirect_map"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { map_map_of_string = []; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml index b3c6cedecc23..bc74b4e109ca 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/mixed_properties_and_additional_properties_class.ml @@ -9,7 +9,7 @@ type t = { - uuid: string + uuid: string option [@default None] @@ -23,9 +23,9 @@ ; [@key "dateTime"] map: (string * Animal.t) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Animal.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Animal.t]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Animal.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Animal.t]] ; [@key "map"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { uuid = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml index 06031bb76b08..e5148e96326e 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model_200_response.ml @@ -10,7 +10,7 @@ type t = { - name: int32 + name: int32 option [@default None] @@ -22,7 +22,7 @@ ; [@key "class"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** Model for testing model name starting with number *) let create () : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml index 3231ca32596c..3edbccbcade1 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model__foo_get_default_response.ml @@ -9,13 +9,13 @@ type t = { - string: Foo.t + string: Foo.t option [@default None] ; [@key "string"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { string = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml index ae3b926c52b1..c6cca5f42cc3 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/model__special_model_name_.ml @@ -9,13 +9,13 @@ type t = { - special_property_name: int64 + special_property_name: int64 option [@default None] ; [@key "$special[property.name]"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { special_property_name = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml index 4b1861ea51ad..1323a552a0fd 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/name.ml @@ -10,7 +10,7 @@ type t = { - name: int32 + name: int32 @@ -34,7 +34,7 @@ ; [@key "123Number"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** Model for testing model name same as property name *) let create (name : int32) : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml index 690eb51db5e7..644dccc0f46d 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/nullable_class.ml @@ -9,7 +9,7 @@ type t = { - integer_prop: int32 + integer_prop: int32 option [@default None] @@ -59,17 +59,17 @@ ; [@key "array_items_nullable"] object_nullable_prop: (string * Yojson.Safe.t) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] ; [@key "object_nullable_prop"] object_and_items_nullable_prop: (string * Yojson.Safe.t) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] ; [@key "object_and_items_nullable_prop"] object_items_nullable: (string * Yojson.Safe.t) list - [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] + [@default []] [@to_yojson JsonSupport.of_map_of [%to_yojson: Yojson.Safe.t]] [@of_yojson JsonSupport.to_map_of [%of_yojson: Yojson.Safe.t]] ; [@key "object_items_nullable"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { integer_prop = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml index 2ca1bb224c58..478c613d73d9 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/number_only.ml @@ -9,13 +9,13 @@ type t = { - just_number: float + just_number: float option [@default None] ; [@key "JustNumber"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { just_number = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml index 93bb27889b10..2c0be1857a17 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/object_with_deprecated_fields.ml @@ -9,7 +9,7 @@ type t = { - uuid: string + uuid: string option [@default None] @@ -31,7 +31,7 @@ [@default []] ; [@key "bars"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { uuid = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml index edeb14daf189..3d40c904734f 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/order.ml @@ -9,7 +9,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -33,20 +33,20 @@ ; [@key "shipDate"] - (* Order Status *) - status: Enums.order_status + status: Enums.order_status option [@default None ] ; [@key "status"] - complete: bool + (** Order Status *) + complete: bool option [@default None] ; [@key "complete"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { id = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml index 5ab6dc894cfc..7bb78d39ed27 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_composite.ml @@ -9,7 +9,7 @@ type t = { - my_number: float + my_number: float option [@default None] @@ -27,7 +27,7 @@ ; [@key "my_boolean"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { my_number = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml index defddabc9421..7fd49f2f6a6b 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/outer_object_with_enum_property.ml @@ -9,13 +9,13 @@ type t = { - value: Enums.outerenuminteger + value: Enums.outerenuminteger ; [@key "value"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create (value : Enums.outerenuminteger) : t = { value = value; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml index 0a82027599dc..442653df3861 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/parent_with_nullable.ml @@ -9,7 +9,7 @@ type t = { - _type: Enums.parentwithnullable_type + _type: Enums.parentwithnullable_type option [@default Some(`ChildWithNullable) @@ -21,7 +21,7 @@ ; [@key "nullableProperty"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { _type = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml index bf5b6f289e3c..f14dec068f53 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/pet.ml @@ -9,7 +9,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -35,14 +35,14 @@ [@default []] ; [@key "tags"] - (* pet status in the store *) - status: Enums.status + status: Enums.status option [@default None ] ; [@key "status"] - } [@@deriving yojson { strict = false }, show, eq ];; + (** pet status in the store *) + } [@@deriving yojson { strict = false }, show, eq ];; let create (name : string) (photo_urls : string list) : t = { id = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml index 42764810c586..ab6a9d232427 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/read_only_first.ml @@ -9,7 +9,7 @@ type t = { - bar: string + bar: string option [@default None] @@ -21,7 +21,7 @@ ; [@key "baz"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { bar = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml index 1b27a9c0c5b5..c3ab65fa9041 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/return.ml @@ -10,13 +10,13 @@ type t = { - return: int32 + return: int32 option [@default None] ; [@key "return"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** Model for testing reserved words *) let create () : t = { diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml index 01467b5e0745..330b39265760 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/tag.ml @@ -9,7 +9,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -21,7 +21,7 @@ ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { id = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml index 9aa631abe7bc..61dc0407ac2a 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/test_inline_freeform_additional_properties_request.ml @@ -9,13 +9,13 @@ type t = { - some_property: string + some_property: string option [@default None] ; [@key "someProperty"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { some_property = None; diff --git a/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml b/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml index 4582d3115276..bfe2ad9b7656 100644 --- a/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml +++ b/samples/client/petstore/ocaml-fake-petstore/src/models/user.ml @@ -9,7 +9,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -51,13 +51,13 @@ ; [@key "phone"] - (* User Status *) - user_status: int32 + user_status: int32 option [@default None] ; [@key "userStatus"] + (** User Status *) } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { diff --git a/samples/client/petstore/ocaml-oneOf-primitive/.ocamlformat b/samples/client/petstore/ocaml-oneOf-primitive/.ocamlformat new file mode 100644 index 000000000000..402c7252e5f9 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/.ocamlformat @@ -0,0 +1,2 @@ +version=0.27.0 +ocaml-version=4.14.0 diff --git a/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator-ignore b/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES b/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator/FILES similarity index 100% rename from samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES rename to samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator/FILES diff --git a/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator/VERSION b/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator/VERSION new file mode 100644 index 000000000000..5e5282953086 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.16.0-SNAPSHOT diff --git a/samples/client/petstore/ocaml-oneOf-primitive/README.md b/samples/client/petstore/ocaml-oneOf-primitive/README.md new file mode 100644 index 000000000000..d33f72445fdf --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/README.md @@ -0,0 +1,33 @@ +# +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +This OCaml package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.16.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.OCamlClientCodegen + +## Requirements. + +OCaml 5.x + +## Installation + +Please run the following commands to build the package `petstore_client`: + +```sh +opam install . --deps-only --with-test +eval $(opam env) +dune build +``` + +## Getting Started + +The generated directory structure is: +- `src/apis`: contains several modules, each with several functions. Each function is an API endpoint. +- `src/models`: contains several modules. Each module contains: + - a type `t` representing an input and/or output schema of the OpenAPI spec + - a smart constructor `create` for this type +- `src/support`: various modules used by the generated APIs and Models + diff --git a/samples/client/petstore/ocaml-oneOf-primitive/dune b/samples/client/petstore/ocaml-oneOf-primitive/dune new file mode 100644 index 000000000000..ed1c4d90e3df --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/dune @@ -0,0 +1,9 @@ +(include_subdirs unqualified) +(library + (name petstore_client) + (public_name petstore_client) + (flags (:standard -w -27)) + (libraries str cohttp-lwt-unix lwt yojson ppx_deriving_yojson.runtime) + (preprocess (pps ppx_deriving_yojson ppx_deriving.std)) + (wrapped true) +) \ No newline at end of file diff --git a/samples/client/petstore/ocaml-oneOf-primitive/dune-project b/samples/client/petstore/ocaml-oneOf-primitive/dune-project new file mode 100644 index 000000000000..60a6d76962b7 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/dune-project @@ -0,0 +1,2 @@ +(lang dune 2.0) +(name petstore_client) diff --git a/samples/client/petstore/ocaml-oneOf-primitive/petstore_client.opam b/samples/client/petstore/ocaml-oneOf-primitive/petstore_client.opam new file mode 100644 index 000000000000..d7c41adb6a11 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/petstore_client.opam @@ -0,0 +1,25 @@ +opam-version: "2.0" +name: "petstore_client" +version: "1.0.0" +synopsis: "" +description: """ +Longer description +""" +maintainer: "Name " +authors: "Name " +license: "" +homepage: "" +bug-reports: "" +dev-repo: "" +depends: [ + "ocaml" + "ocamlfind" + "ocamlformat" {= "0.27.0"} + "dune" + "ppx_deriving_yojson" + "conf-libev" + "lwt" + "cohttp-lwt-unix" {< "6.0.0"} + "cohttp-async" {< "6.0.0"} +] +build: ["dune" "build" "-p" name] diff --git a/samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml b/samples/client/petstore/ocaml-oneOf-primitive/src/apis/default_api.ml similarity index 100% rename from samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml rename to samples/client/petstore/ocaml-oneOf-primitive/src/apis/default_api.ml diff --git a/samples/client/petstore/ocaml-oneOf/src/apis/default_api.mli b/samples/client/petstore/ocaml-oneOf-primitive/src/apis/default_api.mli similarity index 100% rename from samples/client/petstore/ocaml-oneOf/src/apis/default_api.mli rename to samples/client/petstore/ocaml-oneOf-primitive/src/apis/default_api.mli diff --git a/samples/client/petstore/ocaml-oneOf/src/models/child.ml b/samples/client/petstore/ocaml-oneOf-primitive/src/models/child.ml similarity index 76% rename from samples/client/petstore/ocaml-oneOf/src/models/child.ml rename to samples/client/petstore/ocaml-oneOf-primitive/src/models/child.ml index ff9a12f2eb4d..82ae75ff45b1 100644 --- a/samples/client/petstore/ocaml-oneOf/src/models/child.ml +++ b/samples/client/petstore/ocaml-oneOf-primitive/src/models/child.ml @@ -9,13 +9,13 @@ type t = { - name: string + name: string option [@default None] ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; let create () : t = { name = None; diff --git a/samples/client/petstore/ocaml-oneOf/src/models/example.ml b/samples/client/petstore/ocaml-oneOf-primitive/src/models/example.ml similarity index 100% rename from samples/client/petstore/ocaml-oneOf/src/models/example.ml rename to samples/client/petstore/ocaml-oneOf-primitive/src/models/example.ml diff --git a/samples/client/petstore/ocaml-oneOf-primitive/src/support/enums.ml b/samples/client/petstore/ocaml-oneOf-primitive/src/support/enums.ml new file mode 100644 index 000000000000..b30c42f110c6 --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/src/support/enums.ml @@ -0,0 +1,6 @@ +(* + * This file has been generated by the OCamlClientCodegen generator for openapi-generator. + * + * Generated by: https://openapi-generator.tech + * + *) diff --git a/samples/client/petstore/ocaml-oneOf-primitive/src/support/jsonSupport.ml b/samples/client/petstore/ocaml-oneOf-primitive/src/support/jsonSupport.ml new file mode 100644 index 000000000000..0af0c25e759a --- /dev/null +++ b/samples/client/petstore/ocaml-oneOf-primitive/src/support/jsonSupport.ml @@ -0,0 +1,68 @@ +open Ppx_deriving_yojson_runtime + +let unwrap to_json json = + match to_json json with + | Result.Ok json -> json + | Result.Error s -> failwith s + +let to_int json = + match json with + | `Int x -> x + | `Intlit s -> int_of_string s + | _ -> failwith "JsonSupport.to_int" + +let to_bool json = + match json with + | `Bool x -> x + | _ -> failwith "JsonSupport.to_bool" + +let to_float json = + match json with + | `Float x -> x + | _ -> failwith "JsonSupport.to_float" + +let to_string json = + match json with + | `String s -> s + | _ -> failwith "JsonSupport.to_string" + +let to_int32 json : int32 = + match json with + | `Int x -> Int32.of_int x + | `Intlit s -> Int32.of_string s + | _ -> failwith "JsonSupport.to_int32" + +let to_int64 json : int64 = + match json with + | `Int x -> Int64.of_int x + | `Intlit s -> Int64.of_string s + | _ -> failwith "JsonSupport.to_int64" + +let of_int x = `Int x + +let of_bool b = `Bool b + +let of_float x = `Float x + +let of_string s = `String s + +let of_int32 x = `Intlit (Int32.to_string x) + +let of_int64 x = `Intlit (Int64.to_string x) + +let of_list_of of_f l = `List (Stdlib.List.map of_f l) + +let of_map_of of_f l = `Assoc (Stdlib.List.map (fun (k, v) -> (k, of_f v)) l) + +let to_map_of of_f json = + match json with + | `Assoc l -> + Stdlib.List.fold_right + (fun (k, json) acc -> + match (of_f json, acc) with + | Stdlib.Result.Ok parsed_v, Stdlib.Result.Ok tl -> + Stdlib.Result.Ok ((k, parsed_v) :: tl) + | Stdlib.Result.Error e, _ -> Stdlib.Result.Error e + | _, Stdlib.Result.Error e -> Stdlib.Result.Error e) + l (Stdlib.Result.Ok []) + | _ -> Stdlib.Result.Error "Expected" diff --git a/samples/client/petstore/ocaml-oneOf/src/support/request.ml b/samples/client/petstore/ocaml-oneOf-primitive/src/support/request.ml similarity index 100% rename from samples/client/petstore/ocaml-oneOf/src/support/request.ml rename to samples/client/petstore/ocaml-oneOf-primitive/src/support/request.ml diff --git a/samples/client/petstore/ocaml/.openapi-generator-ignore b/samples/client/petstore/ocaml/.openapi-generator-ignore index daed634bb4b7..7484ee590a38 100644 --- a/samples/client/petstore/ocaml/.openapi-generator-ignore +++ b/samples/client/petstore/ocaml/.openapi-generator-ignore @@ -21,4 +21,3 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md -# diff --git a/samples/client/petstore/ocaml/src/models/api_response.ml b/samples/client/petstore/ocaml/src/models/api_response.ml index b2a6f6824638..2d1b9c262322 100644 --- a/samples/client/petstore/ocaml/src/models/api_response.ml +++ b/samples/client/petstore/ocaml/src/models/api_response.ml @@ -10,7 +10,7 @@ type t = { - code: int32 + code: int32 option [@default None] @@ -28,7 +28,7 @@ ; [@key "message"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** Describes the result of uploading an image resource *) let create () : t = { diff --git a/samples/client/petstore/ocaml/src/models/category.ml b/samples/client/petstore/ocaml/src/models/category.ml index cb63d1c6ff83..924145f28855 100644 --- a/samples/client/petstore/ocaml/src/models/category.ml +++ b/samples/client/petstore/ocaml/src/models/category.ml @@ -10,7 +10,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -22,7 +22,7 @@ ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** A category for a pet *) let create () : t = { diff --git a/samples/client/petstore/ocaml/src/models/inline_object.ml b/samples/client/petstore/ocaml/src/models/inline_object.ml deleted file mode 100644 index 90970779f5a5..000000000000 --- a/samples/client/petstore/ocaml/src/models/inline_object.ml +++ /dev/null @@ -1,16 +0,0 @@ -(* - * 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 } diff --git a/samples/client/petstore/ocaml/src/models/inline_object_1.ml b/samples/client/petstore/ocaml/src/models/inline_object_1.ml deleted file mode 100644 index 893ae9b6b989..000000000000 --- a/samples/client/petstore/ocaml/src/models/inline_object_1.ml +++ /dev/null @@ -1,16 +0,0 @@ -(* - * 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 } diff --git a/samples/client/petstore/ocaml/src/models/order.ml b/samples/client/petstore/ocaml/src/models/order.ml index 3e4e63cda43d..736c9231432b 100644 --- a/samples/client/petstore/ocaml/src/models/order.ml +++ b/samples/client/petstore/ocaml/src/models/order.ml @@ -10,7 +10,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -34,20 +34,20 @@ ; [@key "shipDate"] - (* Order Status *) - status: Enums.status + status: Enums.status option [@default None ] ; [@key "status"] - complete: bool + (** Order Status *) + complete: bool option [@default None] ; [@key "complete"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** An order for a pets from the pet store *) let create () : t = { diff --git a/samples/client/petstore/ocaml/src/models/pet.ml b/samples/client/petstore/ocaml/src/models/pet.ml index af5288538870..7769c4255f1e 100644 --- a/samples/client/petstore/ocaml/src/models/pet.ml +++ b/samples/client/petstore/ocaml/src/models/pet.ml @@ -10,7 +10,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -36,14 +36,14 @@ [@default []] ; [@key "tags"] - (* pet status in the store *) - status: Enums.pet_status + status: Enums.pet_status option [@default None ] ; [@key "status"] - } [@@deriving yojson { strict = false }, show, eq ];; + (** pet status in the store *) + } [@@deriving yojson { strict = false }, show, eq ];; (** A pet for sale in the pet store *) let create (name : string) (photo_urls : string list) : t = { diff --git a/samples/client/petstore/ocaml/src/models/tag.ml b/samples/client/petstore/ocaml/src/models/tag.ml index 8a4cd6418109..4250102dbc42 100644 --- a/samples/client/petstore/ocaml/src/models/tag.ml +++ b/samples/client/petstore/ocaml/src/models/tag.ml @@ -10,7 +10,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -22,7 +22,7 @@ ; [@key "name"] - } [@@deriving yojson { strict = false }, show, eq ];; + } [@@deriving yojson { strict = false }, show, eq ];; (** A tag for a pet *) let create () : t = { diff --git a/samples/client/petstore/ocaml/src/models/user.ml b/samples/client/petstore/ocaml/src/models/user.ml index 4f79bf2b71c0..8977fe71900d 100644 --- a/samples/client/petstore/ocaml/src/models/user.ml +++ b/samples/client/petstore/ocaml/src/models/user.ml @@ -10,7 +10,7 @@ type t = { - id: int64 + id: int64 option [@default None] @@ -52,13 +52,13 @@ ; [@key "phone"] - (* User Status *) - user_status: int32 + user_status: int32 option [@default None] ; [@key "userStatus"] + (** User Status *) } [@@deriving yojson { strict = false }, show, eq ];; (** A User who is purchasing from the pet store *)