diff --git a/modules/openapi-generator/src/main/resources/ocaml/model.mustache b/modules/openapi-generator/src/main/resources/ocaml/model.mustache index 43518c27d96..161a2129d46 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/model.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/model.mustache @@ -16,10 +16,31 @@ type t = { (* {{{.}}} *) {{/description}} {{#isEnum}} - {{{name}}}: {{^isMap}}Enums.{{/isMap}}{{{datatypeWithEnum}}}{{^isContainer}}{{#required}}{{#defaultValue}}[@default {{{.}}}]{{/defaultValue}}{{/required}}{{/isContainer}}{{^isContainer}}{{#required}}{{#isNullable}} option [@default {{#defaultValue}}Some({{{.}}}){{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}]{{/isNullable}}{{/required}}{{/isContainer}}{{^isContainer}}{{^required}} option [@default {{#defaultValue}}Some({{{.}}}){{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}]{{/required}}{{/isContainer}}; [@key "{{{baseName}}}"] + {{{name}}}: {{^isMap}}Enums.{{/isMap}}{{{datatypeWithEnum}}} + {{^isContainer}} + {{#required}} + {{#defaultValue}}[@default {{{.}}}]{{/defaultValue}} + {{#isNullable}} option [@default + {{#defaultValue}}Some({{{.}}}){{/defaultValue}} + {{^defaultValue}}None{{/defaultValue}} + ] + {{/isNullable}} + {{/required}} + {{^required}} option [@default + {{#defaultValue}}Some({{{.}}}){{/defaultValue}} + {{^defaultValue}}None{{/defaultValue}} + ] + {{/required}} + {{/isContainer}}; [@key "{{{baseName}}}"] {{/isEnum}} {{^isEnum}} - {{{name}}}: {{{datatypeWithEnum}}}{{^isContainer}}{{#required}}{{#isNullable}} option{{/isNullable}}{{/required}}{{/isContainer}}{{^isContainer}}{{^required}} option [@default None]{{/required}}{{/isContainer}}; [@key "{{{baseName}}}"] + {{{name}}}: {{{datatypeWithEnum}}} + {{^isContainer}} + {{#required}}{{#isNullable}} option{{/isNullable}}{{/required}} + {{^required}} option [@default None]{{/required}} + {{/isContainer}} + {{#isArray}}{{^required}} [@default []]{{/required}}{{/isArray}} + ; [@key "{{{baseName}}}"] {{/isEnum}} {{/vars}} } [@@deriving yojson { strict = false }, show ];; diff --git a/samples/client/petstore/ocaml/src/models/api_response.ml b/samples/client/petstore/ocaml/src/models/api_response.ml index c0e9f89438e..a656e6996a0 100644 --- a/samples/client/petstore/ocaml/src/models/api_response.ml +++ b/samples/client/petstore/ocaml/src/models/api_response.ml @@ -7,9 +7,21 @@ *) type t = { - code: int32 option [@default None]; [@key "code"] - _type: string option [@default None]; [@key "type"] - message: string option [@default None]; [@key "message"] + code: int32 + + option [@default None] + + ; [@key "code"] + _type: string + + option [@default None] + + ; [@key "type"] + message: string + + option [@default None] + + ; [@key "message"] } [@@deriving yojson { strict = false }, show ];; (** Describes the result of uploading an image resource *) diff --git a/samples/client/petstore/ocaml/src/models/category.ml b/samples/client/petstore/ocaml/src/models/category.ml index 6360bbbda49..c5edc5108e1 100644 --- a/samples/client/petstore/ocaml/src/models/category.ml +++ b/samples/client/petstore/ocaml/src/models/category.ml @@ -7,8 +7,16 @@ *) type t = { - id: int64 option [@default None]; [@key "id"] - name: string option [@default None]; [@key "name"] + id: int64 + + option [@default None] + + ; [@key "id"] + name: string + + option [@default None] + + ; [@key "name"] } [@@deriving yojson { strict = false }, show ];; (** A category for a pet *) diff --git a/samples/client/petstore/ocaml/src/models/order.ml b/samples/client/petstore/ocaml/src/models/order.ml index 594d69278d7..2849bc75a7e 100644 --- a/samples/client/petstore/ocaml/src/models/order.ml +++ b/samples/client/petstore/ocaml/src/models/order.ml @@ -7,13 +7,38 @@ *) type t = { - id: int64 option [@default None]; [@key "id"] - pet_id: int64 option [@default None]; [@key "petId"] - quantity: int32 option [@default None]; [@key "quantity"] - ship_date: string option [@default None]; [@key "shipDate"] + id: int64 + + option [@default None] + + ; [@key "id"] + pet_id: int64 + + option [@default None] + + ; [@key "petId"] + quantity: int32 + + option [@default None] + + ; [@key "quantity"] + ship_date: string + + option [@default None] + + ; [@key "shipDate"] (* Order Status *) - status: Enums.status option [@default None]; [@key "status"] - complete: bool option [@default None]; [@key "complete"] + status: Enums.status + option [@default + + None + ] + ; [@key "status"] + complete: bool + + option [@default None] + + ; [@key "complete"] } [@@deriving yojson { strict = false }, show ];; (** An order for a pets from the pet store *) diff --git a/samples/client/petstore/ocaml/src/models/pet.ml b/samples/client/petstore/ocaml/src/models/pet.ml index 34dcf0cd43c..fb3972dd65a 100644 --- a/samples/client/petstore/ocaml/src/models/pet.ml +++ b/samples/client/petstore/ocaml/src/models/pet.ml @@ -7,13 +7,34 @@ *) type t = { - id: int64 option [@default None]; [@key "id"] - category: Category.t option [@default None]; [@key "category"] - name: string; [@key "name"] - photo_urls: string list; [@key "photoUrls"] - tags: Tag.t list; [@key "tags"] + id: int64 + + option [@default None] + + ; [@key "id"] + category: Category.t + + option [@default None] + + ; [@key "category"] + name: string + + + + ; [@key "name"] + photo_urls: string list + + ; [@key "photoUrls"] + tags: Tag.t list + [@default []] + ; [@key "tags"] (* pet status in the store *) - status: Enums.pet_status option [@default None]; [@key "status"] + status: Enums.pet_status + option [@default + + None + ] + ; [@key "status"] } [@@deriving yojson { strict = false }, show ];; (** A pet for sale in the pet store *) diff --git a/samples/client/petstore/ocaml/src/models/tag.ml b/samples/client/petstore/ocaml/src/models/tag.ml index 36e5114e9af..349b43829fb 100644 --- a/samples/client/petstore/ocaml/src/models/tag.ml +++ b/samples/client/petstore/ocaml/src/models/tag.ml @@ -7,8 +7,16 @@ *) type t = { - id: int64 option [@default None]; [@key "id"] - name: string option [@default None]; [@key "name"] + id: int64 + + option [@default None] + + ; [@key "id"] + name: string + + option [@default None] + + ; [@key "name"] } [@@deriving yojson { strict = false }, show ];; (** A tag for a pet *) diff --git a/samples/client/petstore/ocaml/src/models/user.ml b/samples/client/petstore/ocaml/src/models/user.ml index 39a6be65f06..342089254b8 100644 --- a/samples/client/petstore/ocaml/src/models/user.ml +++ b/samples/client/petstore/ocaml/src/models/user.ml @@ -7,15 +7,47 @@ *) type t = { - id: int64 option [@default None]; [@key "id"] - username: string option [@default None]; [@key "username"] - first_name: string option [@default None]; [@key "firstName"] - last_name: string option [@default None]; [@key "lastName"] - email: string option [@default None]; [@key "email"] - password: string option [@default None]; [@key "password"] - phone: string option [@default None]; [@key "phone"] + id: int64 + + option [@default None] + + ; [@key "id"] + username: string + + option [@default None] + + ; [@key "username"] + first_name: string + + option [@default None] + + ; [@key "firstName"] + last_name: string + + option [@default None] + + ; [@key "lastName"] + email: string + + option [@default None] + + ; [@key "email"] + password: string + + option [@default None] + + ; [@key "password"] + phone: string + + option [@default None] + + ; [@key "phone"] (* User Status *) - user_status: int32 option [@default None]; [@key "userStatus"] + user_status: int32 + + option [@default None] + + ; [@key "userStatus"] } [@@deriving yojson { strict = false }, show ];; (** A User who is purchasing from the pet store *)