mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-13 16:03:43 +00:00
[OCaml] Introduce support for oneOf
/anyOf
, fix default value for non-required maps (#21798)
* Add OCaml fake-petstore to test corner cases * Prefix List functions with Stdlib as the fake petstore generates a List module * Handle decimal and any types * Indent to_json.mustache for easier maintenance * Indent api-impl.mustache a bit more for readability before fix * Fix: do not call `to_json` for free forms and byte arrays Fixes https://github.com/OpenAPITools/openapi-generator/issues/21312 * Fix compilation for binary types The implementation may not be correct, but at least it compiles. To be checked if someday someone actually uses it/complains. * Indent to_string.mustache * Add support for exploded form-style object query params Fixes https://github.com/OpenAPITools/openapi-generator/issues/21307 * Add ocaml-fake-petstore to CI * Fix free-form body params * Cohttp_lwt.Response is deprecated, use Cohttp.Response instead * Safe Java code cleanup * Split into model-record.mustache * Add some support for oneOf/anyOf * Re-generate all OCaml samples * Fix: correctly mark non-required maps with default empty list * Fix: Correctly encode/decode maps * Refresh documentation * Refresh after merging master
This commit is contained in:
parent
cd7fe341d3
commit
dc8fac21d9
6
.github/workflows/samples-ocaml.yaml
vendored
6
.github/workflows/samples-ocaml.yaml
vendored
@ -4,9 +4,13 @@ on:
|
||||
push:
|
||||
paths:
|
||||
- 'samples/client/petstore/ocaml/**'
|
||||
- 'samples/client/petstore/ocaml-fake-petstore/**'
|
||||
- 'samples/client/petstore/ocaml-oneOf/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/petstore/ocaml/**'
|
||||
- 'samples/client/petstore/ocaml-fake-petstore/**'
|
||||
- 'samples/client/petstore/ocaml-oneOf/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -17,6 +21,8 @@ jobs:
|
||||
matrix:
|
||||
sample:
|
||||
- 'samples/client/petstore/ocaml/'
|
||||
- 'samples/client/petstore/ocaml-fake-petstore/'
|
||||
- 'samples/client/petstore/ocaml-oneOf/'
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Set-up OCaml
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -296,6 +296,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/
|
||||
|
||||
# jetbrain http client
|
||||
samples/client/jetbrains/adyen/checkout71/http/client/Apis/http-client.private.env.json
|
||||
|
6
bin/configs/ocaml-fake-petstore.yaml
Normal file
6
bin/configs/ocaml-fake-petstore.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
generatorName: ocaml
|
||||
outputDir: samples/client/petstore/ocaml-fake-petstore
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/ocaml
|
||||
additionalProperties:
|
||||
packageName: petstore_client
|
6
bin/configs/ocaml-oneOf.yaml
Normal file
6
bin/configs/ocaml-oneOf.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
generatorName: ocaml
|
||||
outputDir: samples/client/petstore/ocaml-oneOf
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitive.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/ocaml
|
||||
additionalProperties:
|
||||
packageName: petstore_client
|
@ -209,8 +209,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|anyOf|✓|OAS3
|
||||
|oneOf|✓|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
|
@ -51,8 +51,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
static final String X_MODEL_MODULE = "x-model-module";
|
||||
|
||||
public static final String CO_HTTP = "cohttp";
|
||||
|
||||
@Setter protected String packageName = "openapi";
|
||||
@Setter protected String packageVersion = "1.0.0";
|
||||
protected String apiDocPath = "docs/";
|
||||
@ -97,12 +95,15 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
.excludeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism
|
||||
)
|
||||
.includeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.oneOf,
|
||||
SchemaSupportFeature.anyOf
|
||||
)
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.BasePath
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
outputFolder = "generated-code/ocaml";
|
||||
modelTemplateFiles.put("model.mustache", ".ml");
|
||||
|
||||
@ -171,6 +172,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("short", "int");
|
||||
typeMapping.put("char", "char");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("decimal", "string");
|
||||
typeMapping.put("double", "float");
|
||||
typeMapping.put("integer", "int32");
|
||||
typeMapping.put("number", "float");
|
||||
@ -179,6 +181,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("any", "Yojson.Safe.t");
|
||||
typeMapping.put("file", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("AnyType", "Yojson.Safe.t");
|
||||
// lib
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
@ -186,15 +189,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("set", "`Set");
|
||||
typeMapping.put("password", "string");
|
||||
typeMapping.put("DateTime", "string");
|
||||
|
||||
// supportedLibraries.put(CO_HTTP, "HTTP client: CoHttp.");
|
||||
//
|
||||
// CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use.");
|
||||
// libraryOption.setEnum(supportedLibraries);
|
||||
// // set hyper as the default
|
||||
// libraryOption.setDefault(CO_HTTP);
|
||||
// cliOptions.add(libraryOption);
|
||||
// setLibrary(CO_HTTP);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -202,13 +196,12 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
List<String> toRemove = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, ModelsMap> modelEntry : superobjs.entrySet()) {
|
||||
// process enum in models
|
||||
List<ModelMap> models = modelEntry.getValue().getModels();
|
||||
for (ModelMap mo : models) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
|
||||
// for enum model
|
||||
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
|
||||
if (cm.isEnum && cm.allowableValues != null) {
|
||||
toRemove.add(modelEntry.getKey());
|
||||
} else {
|
||||
enrichPropertiesWithEnumDefaultValues(cm.getAllVars());
|
||||
@ -219,6 +212,15 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
enrichPropertiesWithEnumDefaultValues(cm.getVars());
|
||||
enrichPropertiesWithEnumDefaultValues(cm.getParentVars());
|
||||
}
|
||||
|
||||
if (!cm.oneOf.isEmpty()) {
|
||||
// Add a boolean if it is a `oneOf`, because Mustache does not let us check if a list is non-empty
|
||||
cm.getVendorExtensions().put("x-ocaml-isOneOf", true);
|
||||
}
|
||||
if (!cm.anyOf.isEmpty()) {
|
||||
// Add a boolean if it is a `anyOf`, because Mustache does not let us check if a list is non-empty
|
||||
cm.getVendorExtensions().put("x-ocaml-isAnyOf", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,8 +244,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
@Override
|
||||
protected void updateDataTypeWithEnumForMap(CodegenProperty property) {
|
||||
CodegenProperty baseItem = property.items;
|
||||
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|
||||
|| Boolean.TRUE.equals(baseItem.isArray))) {
|
||||
while (baseItem != null && (baseItem.isMap || baseItem.isArray)) {
|
||||
baseItem = baseItem.items;
|
||||
}
|
||||
|
||||
@ -260,8 +261,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
@Override
|
||||
protected void updateDataTypeWithEnumForArray(CodegenProperty property) {
|
||||
CodegenProperty baseItem = property.items;
|
||||
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|
||||
|| Boolean.TRUE.equals(baseItem.isArray))) {
|
||||
while (baseItem != null && (baseItem.isMap || baseItem.isArray)) {
|
||||
baseItem = baseItem.items;
|
||||
}
|
||||
if (baseItem != null) {
|
||||
@ -312,19 +312,17 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
collectEnumSchemas(parentName, sName, schema);
|
||||
|
||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
||||
if (schema.getProperties() != null) {
|
||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
||||
collectEnumSchemas(pName, schema.getProperties());
|
||||
}
|
||||
|
||||
if (schema.getAdditionalProperties() != null && schema.getAdditionalProperties() instanceof Schema) {
|
||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
||||
collectEnumSchemas(pName, (Schema) schema.getAdditionalProperties());
|
||||
}
|
||||
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
if (ModelUtils.getSchemaItems(schema) != null) {
|
||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
||||
collectEnumSchemas(pName, ModelUtils.getSchemaItems(schema));
|
||||
}
|
||||
}
|
||||
@ -677,7 +675,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
public String toEnumValueName(String name) {
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
|
||||
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
|
||||
return escape(name, specialCharReplacements, Collections.singletonList("_"), null);
|
||||
} else {
|
||||
return name;
|
||||
@ -723,8 +721,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
|
||||
//if (CO_HTTP.equals(getLibrary())) {
|
||||
for (CodegenParameter param : operation.bodyParams) {
|
||||
if (param.isModel && param.dataType.endsWith(".t")) {
|
||||
param.vendorExtensions.put(X_MODEL_MODULE, param.dataType.substring(0, param.dataType.lastIndexOf('.')));
|
||||
|
@ -30,7 +30,7 @@ let {{{operationId}}} {{^hasParams}}(){{/hasParams}}{{#allParams}}{{> to_param}}
|
||||
let uri = Request.{{> to_optional_prefix}}replace_path_param uri "{{{baseName}}}" {{> to_string}} {{{paramName}}} in
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}
|
||||
let uri = Request.{{> to_optional_prefix}}add_query_param{{#isArray}}_list{{/isArray}} uri "{{{baseName}}}" {{> to_string}} {{{paramName}}} in
|
||||
let uri = Request.{{> to_optional_prefix}}add_query_param{{#isArray}}_list{{/isArray}}{{#isExplode}}{{#isFormStyle}}{{#isMap}}_exploded_form_object{{/isMap}}{{/isFormStyle}}{{/isExplode}} uri "{{{baseName}}}" {{> to_string}} {{{paramName}}} in
|
||||
{{/queryParams}}
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
@ -42,7 +42,10 @@ let {{{operationId}}} {{^hasParams}}(){{/hasParams}}{{#allParams}}{{> to_param}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
{{#bodyParams}}
|
||||
let body = Request.{{#isFreeFormObject}}write_json_body{{/isFreeFormObject}}{{#isByteArray}}write_string_body{{/isByteArray}}{{^isFreeFormObject}}{{^isByteArray}}write_as_json_body{{/isByteArray}}{{/isFreeFormObject}} {{> to_json}} {{{paramName}}} in
|
||||
let body = Request.
|
||||
{{#isByteArray}}write_string_body {{{paramName}}}{{/isByteArray}}
|
||||
{{^isByteArray}}write_as_json_body {{> to_json}} {{{paramName}}}{{/isByteArray}}
|
||||
in
|
||||
{{/bodyParams}}
|
||||
{{^hasBodyParam}}
|
||||
{{#hasFormParams}}
|
||||
|
@ -50,6 +50,19 @@ 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 (List.map of_f l)
|
||||
let of_list_of of_f l = `List (Stdlib.List.map of_f l)
|
||||
|
||||
let of_map_of of_f l = `Assoc (List.map (fun (k, v) -> (k, of_f v)) 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"
|
||||
|
25
modules/openapi-generator/src/main/resources/ocaml/model-any-of.mustache
vendored
Normal file
25
modules/openapi-generator/src/main/resources/ocaml/model-any-of.mustache
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
type t =
|
||||
{{#composedSchemas.anyOf}}
|
||||
| {{{nameInPascalCase}}} of {{{dataType}}}
|
||||
{{/composedSchemas.anyOf}}
|
||||
[@@deriving show, eq];;
|
||||
|
||||
let to_yojson = function
|
||||
{{#composedSchemas.anyOf}}
|
||||
| {{{nameInPascalCase}}} v -> [%to_yojson: {{{ datatypeWithEnum }}}] v
|
||||
{{/composedSchemas.anyOf}}
|
||||
|
||||
(* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *)
|
||||
|
||||
let of_yojson json =
|
||||
[
|
||||
{{#composedSchemas.anyOf}}
|
||||
[%of_yojson: {{{ datatypeWithEnum }}}] json
|
||||
|> Stdlib.Result.to_option
|
||||
|> Stdlib.Option.map (fun v -> {{{nameInPascalCase}}} v);
|
||||
{{/composedSchemas.anyOf}}
|
||||
]
|
||||
|> Stdlib.List.filter_map (Fun.id)
|
||||
|> function
|
||||
| t :: _ -> Ok t (* Return the first successful parsing. *)
|
||||
| [] -> Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type {{{ classname }}}")
|
29
modules/openapi-generator/src/main/resources/ocaml/model-one-of.mustache
vendored
Normal file
29
modules/openapi-generator/src/main/resources/ocaml/model-one-of.mustache
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
type t =
|
||||
{{#composedSchemas.oneOf}}
|
||||
| {{{nameInPascalCase}}} of {{{dataType}}}
|
||||
{{/composedSchemas.oneOf}}
|
||||
[@@deriving show, eq];;
|
||||
|
||||
let to_yojson = function
|
||||
{{#composedSchemas.oneOf}}
|
||||
| {{{nameInPascalCase}}} v -> [%to_yojson: {{{ datatypeWithEnum }}}] v
|
||||
{{/composedSchemas.oneOf}}
|
||||
|
||||
(* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *)
|
||||
|
||||
let of_yojson json =
|
||||
[
|
||||
{{#composedSchemas.oneOf}}
|
||||
[%of_yojson: {{{ datatypeWithEnum }}}] json
|
||||
|> Stdlib.Result.to_option
|
||||
|> Stdlib.Option.map (fun v -> {{{nameInPascalCase}}} v);
|
||||
{{/composedSchemas.oneOf}}
|
||||
]
|
||||
|> Stdlib.List.filter_map (Fun.id)
|
||||
|> function
|
||||
| [t] -> Ok t
|
||||
| [] -> Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type {{{ classname }}}")
|
||||
| ts -> let parsed_ts = ts
|
||||
|> Stdlib.List.map show
|
||||
|> Stdlib.String.concat " | "
|
||||
in Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type {{{ classname }}}: oneOf should only succeed on one parser, but the JSON was parsed into [" ^ parsed_ts ^ "]")
|
44
modules/openapi-generator/src/main/resources/ocaml/model-record.mustache
vendored
Normal file
44
modules/openapi-generator/src/main/resources/ocaml/model-record.mustache
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
type t = {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
(* {{{.}}} *)
|
||||
{{/description}}
|
||||
{{#isEnum}}
|
||||
{{{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}}
|
||||
{{^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}}
|
||||
; [@key "{{{baseName}}}"]
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
{{#description}}
|
||||
(** {{{.}}} *)
|
||||
{{/description}}
|
||||
let create {{#requiredVars}}({{{name}}} : {{#isEnum}}Enums.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} option{{/isNullable}}){{^-last}} {{/-last}}{{/requiredVars}}{{^hasRequired}}(){{/hasRequired}} : t = {
|
||||
{{#vars}}
|
||||
{{{name}}} = {{#required}}{{{name}}}{{/required}}{{^required}}{{#isContainer}}[]{{/isContainer}}{{^isContainer}}None{{/isContainer}}{{/required}};
|
||||
{{/vars}}
|
||||
}
|
@ -10,49 +10,17 @@
|
||||
{{/description}}
|
||||
|
||||
{{^isEnum}}
|
||||
type t = {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
(* {{{.}}} *)
|
||||
{{/description}}
|
||||
{{#isEnum}}
|
||||
{{{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}}
|
||||
{{^required}} option [@default None]{{/required}}
|
||||
{{/isContainer}}
|
||||
{{#isArray}}{{^required}} [@default []]{{/required}}{{/isArray}}
|
||||
; [@key "{{{baseName}}}"]
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
{{#vendorExtensions.x-ocaml-isOneOf}}
|
||||
{{>model-one-of}}
|
||||
{{/vendorExtensions.x-ocaml-isOneOf}}
|
||||
|
||||
{{#description}}
|
||||
(** {{{.}}} *)
|
||||
{{/description}}
|
||||
let create {{#requiredVars}}({{{name}}} : {{#isEnum}}Enums.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} option{{/isNullable}}){{^-last}} {{/-last}}{{/requiredVars}}{{^hasRequired}}(){{/hasRequired}} : t = {
|
||||
{{#vars}}
|
||||
{{{name}}} = {{#required}}{{{name}}}{{/required}}{{^required}}{{#isContainer}}[]{{/isContainer}}{{^isContainer}}None{{/isContainer}}{{/required}};
|
||||
{{/vars}}
|
||||
}
|
||||
{{#vendorExtensions.x-ocaml-isAnyOf}}
|
||||
{{>model-any-of}}
|
||||
{{/vendorExtensions.x-ocaml-isAnyOf}}
|
||||
|
||||
{{^vendorExtensions.x-ocaml-isOneOf}}{{^vendorExtensions.x-ocaml-isAnyOf}}
|
||||
{{>model-record}}
|
||||
{{/vendorExtensions.x-ocaml-isAnyOf}}{{/vendorExtensions.x-ocaml-isOneOf}}
|
||||
{{/isEnum}}
|
||||
|
||||
{{/model}}
|
||||
|
@ -35,7 +35,7 @@ let write_json_body payload =
|
||||
let write_as_json_body to_json payload = write_json_body (to_json payload)
|
||||
|
||||
let handle_response resp on_success_handler =
|
||||
match Cohttp_lwt.Response.status resp with
|
||||
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)))
|
||||
|
||||
@ -52,13 +52,13 @@ 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 >|= List.map of_json)
|
||||
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 >|= List.map (fun (s, v) -> (s, of_json v)))
|
||||
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
|
||||
@ -80,6 +80,19 @@ let add_query_param_list 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 =
|
||||
|
@ -1 +1,39 @@
|
||||
{{#isArray}}{{#items}}(JsonSupport.of_list_of {{> to_json}}){{/items}}{{/isArray}}{{#isMap}}{{#items}}(JsonSupport.of_map_of {{> to_json}}){{/items}}{{/isMap}}{{#isString}}JsonSupport.of_string{{/isString}}{{#isLong}}JsonSupport.of_int64{{/isLong}}{{#isInteger}}JsonSupport.of_int32{{/isInteger}}{{#isFloat}}JsonSupport.of_float{{/isFloat}}{{#isNumber}}JsonSupport.of_float{{/isNumber}}{{#isDouble}}JsonSupport.of_float{{/isDouble}}{{#isBoolean}}JsonSupport.of_bool{{/isBoolean}}{{^isEnum}}{{#isModel}}{{#vendorExtensions.x-model-module}}{{{vendorExtensions.x-model-module}}}.to_yojson{{/vendorExtensions.x-model-module}}{{^vendorExtensions.x-model-module}}{{{baseType}}}.to_yojson{{/vendorExtensions.x-model-module}}{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.{{{datatypeWithEnum}}}_to_yojson{{/isEnum}}{{/isContainer}}{{/isModel}}
|
||||
{{#isArray}}
|
||||
{{#items}}
|
||||
(JsonSupport.of_list_of {{> to_json}})
|
||||
{{/items}}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
{{#items}}
|
||||
(JsonSupport.of_map_of {{> to_json}})
|
||||
{{/items}}
|
||||
{{/isMap}}
|
||||
{{^isContainer}}
|
||||
{{#isString}}JsonSupport.of_string{{/isString}}
|
||||
{{#isLong}}JsonSupport.of_int64{{/isLong}}
|
||||
{{#isInteger}}JsonSupport.of_int32{{/isInteger}}
|
||||
{{#isFloat}}JsonSupport.of_float{{/isFloat}}
|
||||
{{#isNumber}}JsonSupport.of_float{{/isNumber}}
|
||||
{{#isDouble}}JsonSupport.of_float{{/isDouble}}
|
||||
{{#isBoolean}}JsonSupport.of_bool{{/isBoolean}}
|
||||
{{^isEnum}}
|
||||
{{#isModel}}
|
||||
{{#vendorExtensions.x-model-module}}
|
||||
{{{vendorExtensions.x-model-module}}}.to_yojson
|
||||
{{/vendorExtensions.x-model-module}}
|
||||
{{^vendorExtensions.x-model-module}}
|
||||
{{{baseType}}}.to_yojson
|
||||
{{/vendorExtensions.x-model-module}}
|
||||
{{/isModel}}
|
||||
{{/isEnum}}
|
||||
{{^isModel}}
|
||||
{{^isContainer}}
|
||||
{{#isEnum}}
|
||||
Enums.{{{datatypeWithEnum}}}_to_yojson
|
||||
{{/isEnum}}
|
||||
{{/isContainer}}
|
||||
{{/isModel}}
|
||||
{{#isBinary}}JsonSupport.of_string{{/isBinary}}
|
||||
{{#isAnyType}}(fun x -> x){{/isAnyType}}
|
||||
{{#isFreeFormObject}}(fun x -> x){{/isFreeFormObject}}
|
||||
{{/isContainer}}
|
||||
|
@ -1 +1,26 @@
|
||||
{{#isContainer}}{{#items}}(List.map {{> to_string}}){{/items}}{{/isContainer}}{{^isEnum}}{{#isLong}}Int64.to_string{{/isLong}}{{#isInteger}}Int32.to_string{{/isInteger}}{{#isFloat}}string_of_float{{/isFloat}}{{#isNumber}}string_of_float{{/isNumber}}{{#isDouble}}string_of_float{{/isDouble}}{{#isBoolean}}string_of_bool{{/isBoolean}}{{#isFile}}(fun x -> x){{/isFile}}{{#isDate}}(fun x -> x){{/isDate}}{{#isDateTime}}(fun x -> x){{/isDateTime}}{{#isString}}(fun x -> x){{/isString}}{{#isByteArray}}(fun x -> x){{/isByteArray}}{{#isModel}}{{{vendorExtensions.x-model-module}}}.show{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.show_{{{datatypeWithEnum}}}{{/isEnum}}{{/isContainer}}{{/isModel}}
|
||||
{{#isArray}}
|
||||
{{#items}}(Stdlib.List.map {{> to_string}}){{/items}}
|
||||
{{/isArray}}
|
||||
{{#isMap}}{{! For maps, only transform the value, the call site will take care of properly transforming the key-value pairs since it depends on the context. }}
|
||||
{{#items}}{{> to_string}}{{/items}}
|
||||
{{/isMap}}
|
||||
{{^isEnum}}
|
||||
{{#isLong}}Int64.to_string{{/isLong}}
|
||||
{{#isInteger}}Int32.to_string{{/isInteger}}
|
||||
{{#isFloat}}string_of_float{{/isFloat}}
|
||||
{{#isNumber}}string_of_float{{/isNumber}}
|
||||
{{#isDouble}}string_of_float{{/isDouble}}
|
||||
{{#isBoolean}}string_of_bool{{/isBoolean}}
|
||||
{{#isFile}}(fun x -> x){{/isFile}}
|
||||
{{#isDate}}(fun x -> x){{/isDate}}
|
||||
{{#isDateTime}}(fun x -> x){{/isDateTime}}
|
||||
{{#isString}}(fun x -> x){{/isString}}
|
||||
{{#isByteArray}}(fun x -> x){{/isByteArray}}
|
||||
{{#isModel}}{{{vendorExtensions.x-model-module}}}.show{{/isModel}}
|
||||
{{/isEnum}}
|
||||
{{^isModel}}
|
||||
{{^isContainer}}
|
||||
{{#isEnum}}Enums.show_{{{datatypeWithEnum}}}{{/isEnum}}
|
||||
{{#isEnumRef}}(failwith "Unsupported: enum reference"){{/isEnumRef}}
|
||||
{{/isContainer}}
|
||||
{{/isModel}}
|
||||
|
@ -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
|
@ -0,0 +1,65 @@
|
||||
README.md
|
||||
dune
|
||||
dune-project
|
||||
petstore_client.opam
|
||||
src/apis/another_fake_api.ml
|
||||
src/apis/another_fake_api.mli
|
||||
src/apis/default_api.ml
|
||||
src/apis/default_api.mli
|
||||
src/apis/fake_api.ml
|
||||
src/apis/fake_api.mli
|
||||
src/apis/fake_classname_tags123_api.ml
|
||||
src/apis/fake_classname_tags123_api.mli
|
||||
src/apis/pet_api.ml
|
||||
src/apis/pet_api.mli
|
||||
src/apis/store_api.ml
|
||||
src/apis/store_api.mli
|
||||
src/apis/user_api.ml
|
||||
src/apis/user_api.mli
|
||||
src/models/additional_properties_class.ml
|
||||
src/models/all_of_with_single_ref.ml
|
||||
src/models/animal.ml
|
||||
src/models/api_response.ml
|
||||
src/models/array_of_array_of_number_only.ml
|
||||
src/models/array_of_number_only.ml
|
||||
src/models/array_test.ml
|
||||
src/models/capitalization.ml
|
||||
src/models/cat.ml
|
||||
src/models/category.ml
|
||||
src/models/child_with_nullable.ml
|
||||
src/models/class_model.ml
|
||||
src/models/client.ml
|
||||
src/models/deprecated_object.ml
|
||||
src/models/dog.ml
|
||||
src/models/enum_arrays.ml
|
||||
src/models/enum_test.ml
|
||||
src/models/fake_big_decimal_map_200_response.ml
|
||||
src/models/file.ml
|
||||
src/models/file_schema_test_class.ml
|
||||
src/models/foo.ml
|
||||
src/models/format_test.ml
|
||||
src/models/has_only_read_only.ml
|
||||
src/models/health_check_result.ml
|
||||
src/models/list.ml
|
||||
src/models/map_test.ml
|
||||
src/models/mixed_properties_and_additional_properties_class.ml
|
||||
src/models/model_200_response.ml
|
||||
src/models/model__foo_get_default_response.ml
|
||||
src/models/model__special_model_name_.ml
|
||||
src/models/name.ml
|
||||
src/models/nullable_class.ml
|
||||
src/models/number_only.ml
|
||||
src/models/object_with_deprecated_fields.ml
|
||||
src/models/order.ml
|
||||
src/models/outer_composite.ml
|
||||
src/models/outer_object_with_enum_property.ml
|
||||
src/models/parent_with_nullable.ml
|
||||
src/models/pet.ml
|
||||
src/models/read_only_first.ml
|
||||
src/models/return.ml
|
||||
src/models/tag.ml
|
||||
src/models/test_inline_freeform_additional_properties_request.ml
|
||||
src/models/user.ml
|
||||
src/support/enums.ml
|
||||
src/support/jsonSupport.ml
|
||||
src/support/request.ml
|
@ -0,0 +1 @@
|
||||
7.16.0-SNAPSHOT
|
33
samples/client/petstore/ocaml-fake-petstore/README.md
Normal file
33
samples/client/petstore/ocaml-fake-petstore/README.md
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \'' \\
|
||||
|
||||
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
|
||||
|
9
samples/client/petstore/ocaml-fake-petstore/dune
Normal file
9
samples/client/petstore/ocaml-fake-petstore/dune
Normal file
@ -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)
|
||||
)
|
2
samples/client/petstore/ocaml-fake-petstore/dune-project
Normal file
2
samples/client/petstore/ocaml-fake-petstore/dune-project
Normal file
@ -0,0 +1,2 @@
|
||||
(lang dune 1.10)
|
||||
(name petstore_client)
|
@ -0,0 +1,24 @@
|
||||
opam-version: "2.0"
|
||||
name: "petstore_client"
|
||||
version: "1.0.0"
|
||||
synopsis: ""
|
||||
description: """
|
||||
Longer description
|
||||
"""
|
||||
maintainer: "Name <email>"
|
||||
authors: "Name <email>"
|
||||
license: ""
|
||||
homepage: ""
|
||||
bug-reports: ""
|
||||
dev-repo: ""
|
||||
depends: [
|
||||
"ocaml"
|
||||
"ocamlfind"
|
||||
"dune"
|
||||
"ppx_deriving_yojson"
|
||||
"conf-libev"
|
||||
"lwt"
|
||||
"cohttp-lwt-unix" {< "6.0.0"}
|
||||
"cohttp-async" {< "6.0.0"}
|
||||
]
|
||||
build: ["dune" "build" "-p" name]
|
@ -0,0 +1,29 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let call_123_test_special_tags ~client_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/another-fake/dummy" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Client.to_yojson
|
||||
|
||||
|
||||
|
||||
client_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body
|
||||
|
@ -0,0 +1,8 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val call_123_test_special_tags : client_t:Client.t -> Client.t Lwt.t
|
@ -0,0 +1,14 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let foo_get () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/foo" in
|
||||
let headers = Request.default_headers in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Model__foo_get_default_response.of_yojson) resp body
|
||||
|
@ -0,0 +1,8 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val foo_get : unit -> Model__foo_get_default_response.t Lwt.t
|
1002
samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml
Normal file
1002
samples/client/petstore/ocaml-fake-petstore/src/apis/fake_api.ml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val fake_big_decimal_map : unit -> Fake_big_decimal_map_200_response.t Lwt.t
|
||||
val fake_health_get : unit -> Health_check_result.t Lwt.t
|
||||
val fake_http_signature_test : pet_t:Pet.t -> ?query_1:string -> ?header_1:string -> unit -> unit Lwt.t
|
||||
val fake_outer_boolean_serialize : body:bool -> unit -> bool Lwt.t
|
||||
val fake_outer_composite_serialize : outer_composite_t:Outer_composite.t -> unit -> Outer_composite.t Lwt.t
|
||||
val fake_outer_number_serialize : body:float -> unit -> float Lwt.t
|
||||
val fake_outer_string_serialize : body:string -> unit -> string Lwt.t
|
||||
val fake_property_enum_integer_serialize : outer_object_with_enum_property_t:Outer_object_with_enum_property.t -> Outer_object_with_enum_property.t Lwt.t
|
||||
val test_additional_properties_reference : request_body:(string * Yojson.Safe.t) list -> unit Lwt.t
|
||||
val test_body_with_binary : body:string -> unit Lwt.t
|
||||
val test_body_with_file_schema : file_schema_test_class_t:File_schema_test_class.t -> unit Lwt.t
|
||||
val test_body_with_query_params : query:string -> user_t:User.t -> unit Lwt.t
|
||||
val test_client_model : client_t:Client.t -> Client.t Lwt.t
|
||||
val test_endpoint_parameters : number:float -> double:float -> pattern_without_delimiter:string -> byte:string -> ?integer:int32 -> ?int32:int32 -> ?int64:int64 -> ?float:float -> ?string:string -> ?binary:string -> ?date:string -> ?date_time:string -> ?password:string -> ?callback:string -> unit -> unit Lwt.t
|
||||
val test_enum_parameters : ?enum_header_string_array:Enums.enum_form_string_array list -> ?enum_header_string:Enums.enumclass -> ?enum_query_string_array:Enums.enum_form_string_array list -> ?enum_query_string:Enums.enumclass -> ?enum_query_integer:Enums.enum_query_integer -> ?enum_query_double:Enums.enum_number -> ?enum_query_model_array:Enums.enumclass list -> ?enum_form_string_array:Enums.enum_form_string_array list -> ?enum_form_string:Enums.enumclass -> unit -> unit Lwt.t
|
||||
val test_group_parameters : required_string_group:int32 -> required_boolean_group:bool -> required_int64_group:int64 -> ?string_group:int32 -> ?boolean_group:bool -> ?int64_group:int64 -> unit -> unit Lwt.t
|
||||
val test_inline_additional_properties : request_body:(string * string) list -> unit Lwt.t
|
||||
val test_inline_freeform_additional_properties : test_inline_freeform_additional_properties_request_t:Test_inline_freeform_additional_properties_request.t -> unit Lwt.t
|
||||
val test_json_form_data : param:string -> param2:string -> unit Lwt.t
|
||||
val test_nullable : child_with_nullable_t:Child_with_nullable.t -> unit Lwt.t
|
||||
val test_query_parameter_collection_format : pipe:string list -> ioutil:string list -> http:string list -> url:string list -> context:string list -> allow_empty:string -> ?language:(string * string) list -> unit -> unit Lwt.t
|
||||
val test_string_map_reference : request_body:(string * string) list -> unit Lwt.t
|
@ -0,0 +1,30 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let test_classname ~client_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/fake_classname_test" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Uri.add_query_param' uri ("api_key_query", Request.api_key) in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Client.to_yojson
|
||||
|
||||
|
||||
|
||||
client_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `PATCH uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Client.of_yojson) resp body
|
||||
|
@ -0,0 +1,8 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val test_classname : client_t:Client.t -> Client.t Lwt.t
|
319
samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml
Normal file
319
samples/client/petstore/ocaml-fake-petstore/src/apis/pet_api.ml
Normal file
@ -0,0 +1,319 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let add_pet ~pet_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Pet.to_yojson
|
||||
|
||||
|
||||
|
||||
pet_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let delete_pet ~pet_id ?api_key () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Request.maybe_add_header headers "api_key"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
api_key in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let find_pets_by_status ~status =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/findByStatus" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.add_query_param_list uri "status" (Stdlib.List.map Enums.show_status
|
||||
|
||||
)
|
||||
status in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let find_pets_by_tags ~tags =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/findByTags" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.add_query_param_list uri "tags" (Stdlib.List.map
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
tags in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let get_pet_by_id ~pet_id =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
let update_pet ~pet_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Pet.to_yojson
|
||||
|
||||
|
||||
|
||||
pet_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let update_pet_with_form ~pet_id ?name ?status () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
let body = Request.init_form_encoded_body () in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "name"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
name in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "status"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
status in
|
||||
let body = Request.finalize_form_encoded_body body in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let upload_file ~pet_id ?additional_metadata ?file () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}/uploadImage" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
let body = Request.init_form_encoded_body () in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "additional_metadata"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
additional_metadata in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "file"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
file in
|
||||
let body = Request.finalize_form_encoded_body body in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body
|
||||
|
||||
let upload_file_with_required_file ~pet_id ~required_file ?additional_metadata () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/fake/{petId}/uploadImageWithRequiredFile" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
let body = Request.init_form_encoded_body () in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "additional_metadata"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
additional_metadata in
|
||||
let body = Request.add_form_encoded_body_param body "required_file"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
required_file in
|
||||
let body = Request.finalize_form_encoded_body body in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body
|
||||
|
@ -0,0 +1,16 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val add_pet : pet_t:Pet.t -> unit Lwt.t
|
||||
val delete_pet : pet_id:int64 -> ?api_key:string -> unit -> unit Lwt.t
|
||||
val find_pets_by_status : status:Enums.status list -> Pet.t list Lwt.t
|
||||
val find_pets_by_tags : tags:string list -> Pet.t list Lwt.t
|
||||
val get_pet_by_id : pet_id:int64 -> Pet.t Lwt.t
|
||||
val update_pet : pet_t:Pet.t -> unit Lwt.t
|
||||
val update_pet_with_form : pet_id:int64 -> ?name:string -> ?status:string -> unit -> unit Lwt.t
|
||||
val upload_file : pet_id:int64 -> ?additional_metadata:string -> ?file:string -> unit -> Api_response.t Lwt.t
|
||||
val upload_file_with_required_file : pet_id:int64 -> required_file:string -> ?additional_metadata:string -> unit -> Api_response.t Lwt.t
|
@ -0,0 +1,81 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let delete_order ~order_id =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/order/{order_id}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "order_id"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
order_id in
|
||||
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let get_inventory () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/inventory" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as_map_of (JsonSupport.to_int32) resp body
|
||||
|
||||
let get_order_by_id ~order_id =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/order/{order_id}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "order_id" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order_id in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
|
||||
|
||||
let place_order ~order_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/order" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Order.to_yojson
|
||||
|
||||
|
||||
|
||||
order_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
|
||||
|
@ -0,0 +1,11 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val delete_order : order_id:string -> unit Lwt.t
|
||||
val get_inventory : unit -> (string * int32) list Lwt.t
|
||||
val get_order_by_id : order_id:int64 -> Order.t Lwt.t
|
||||
val place_order : order_t:Order.t -> Order.t Lwt.t
|
200
samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml
Normal file
200
samples/client/petstore/ocaml-fake-petstore/src/apis/user_api.ml
Normal file
@ -0,0 +1,200 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let create_user ~user_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
user_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let create_users_with_array_input ~user =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/createWithArray" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body (JsonSupport.of_list_of
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
)
|
||||
user
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let create_users_with_list_input ~user =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/createWithList" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body (JsonSupport.of_list_of
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
)
|
||||
user
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let delete_user ~username =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/{username}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let get_user_by_name ~username =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/{username}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body
|
||||
|
||||
let login_user ~username ~password =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/login" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.add_query_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
let uri = Request.add_query_param uri "password"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
password in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.to_string) resp body
|
||||
|
||||
let logout_user () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/logout" in
|
||||
let headers = Request.default_headers in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
let update_user ~username ~user_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/{username}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
user_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
@ -0,0 +1,15 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val create_user : user_t:User.t -> unit Lwt.t
|
||||
val create_users_with_array_input : user:User.t list -> unit Lwt.t
|
||||
val create_users_with_list_input : user:User.t list -> unit Lwt.t
|
||||
val delete_user : username:string -> unit Lwt.t
|
||||
val get_user_by_name : username:string -> User.t Lwt.t
|
||||
val login_user : username:string -> password:string -> string Lwt.t
|
||||
val logout_user : unit -> unit Lwt.t
|
||||
val update_user : username:string -> user_t:User.t -> unit Lwt.t
|
@ -0,0 +1,27 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
map_property: (string * string) list
|
||||
|
||||
[@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]]
|
||||
; [@key "map_of_map_property"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
map_property = [];
|
||||
map_of_map_property = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
username: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "username"]
|
||||
single_ref_type: Enums.singlereftype
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "SingleRefType"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
username = None;
|
||||
single_ref_type = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
class_name: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "className"]
|
||||
color: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "color"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (class_name : string) : t = {
|
||||
class_name = class_name;
|
||||
color = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
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, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
code = None;
|
||||
_type = None;
|
||||
message = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
array_array_number: float list list
|
||||
[@default []]
|
||||
|
||||
; [@key "ArrayArrayNumber"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
array_array_number = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
array_number: float list
|
||||
[@default []]
|
||||
|
||||
; [@key "ArrayNumber"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
array_number = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
array_of_string: string list
|
||||
[@default []]
|
||||
|
||||
; [@key "array_of_string"]
|
||||
array_array_of_integer: int64 list list
|
||||
[@default []]
|
||||
|
||||
; [@key "array_array_of_integer"]
|
||||
array_array_of_model: Read_only_first.t list list
|
||||
[@default []]
|
||||
|
||||
; [@key "array_array_of_model"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
array_of_string = [];
|
||||
array_array_of_integer = [];
|
||||
array_array_of_model = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
small_camel: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "smallCamel"]
|
||||
capital_camel: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "CapitalCamel"]
|
||||
small_snake: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "small_Snake"]
|
||||
capital_snake: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "Capital_Snake"]
|
||||
sca_eth_flow_points: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "SCA_ETH_Flow_Points"]
|
||||
(* Name of the pet *)
|
||||
att_name: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "ATT_NAME"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
small_camel = None;
|
||||
capital_camel = None;
|
||||
small_snake = None;
|
||||
capital_snake = None;
|
||||
sca_eth_flow_points = None;
|
||||
att_name = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
class_name: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "className"]
|
||||
color: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "color"]
|
||||
declawed: bool
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "declawed"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (class_name : string) : t = {
|
||||
class_name = class_name;
|
||||
color = None;
|
||||
declawed = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
id: int64
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "id"]
|
||||
name: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "name"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (name : string) : t = {
|
||||
id = None;
|
||||
name = name;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
_type: Enums.parentwithnullable_type
|
||||
option [@default
|
||||
Some(`ChildWithNullable)
|
||||
|
||||
]
|
||||
; [@key "type"]
|
||||
nullable_property: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "nullableProperty"]
|
||||
other_property: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "otherProperty"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
_type = None;
|
||||
nullable_property = None;
|
||||
other_property = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
* Schema Class_model.t : Model for testing model with \''_class\'' property
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
_class: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "_class"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
(** Model for testing model with \''_class\'' property *)
|
||||
let create () : t = {
|
||||
_class = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
client: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "client"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
client = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
name: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "name"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
name = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
class_name: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "className"]
|
||||
color: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "color"]
|
||||
breed: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "breed"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (class_name : string) : t = {
|
||||
class_name = class_name;
|
||||
color = None;
|
||||
breed = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
just_symbol: Enums.just_symbol
|
||||
option [@default
|
||||
|
||||
None
|
||||
]
|
||||
; [@key "just_symbol"]
|
||||
array_enum: Enums.array_enum list
|
||||
; [@key "array_enum"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
just_symbol = None;
|
||||
array_enum = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
enum_string: Enums.enum_string
|
||||
option [@default
|
||||
|
||||
None
|
||||
]
|
||||
; [@key "enum_string"]
|
||||
enum_string_required: Enums.enum_string
|
||||
|
||||
; [@key "enum_string_required"]
|
||||
enum_integer: Enums.enum_integer
|
||||
option [@default
|
||||
|
||||
None
|
||||
]
|
||||
; [@key "enum_integer"]
|
||||
enum_number: Enums.enum_number
|
||||
option [@default
|
||||
|
||||
None
|
||||
]
|
||||
; [@key "enum_number"]
|
||||
outer_enum: Enums.order_status
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "outerEnum"]
|
||||
outer_enum_integer: Enums.outerenuminteger
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "outerEnumInteger"]
|
||||
outer_enum_default_value: Enums.order_status
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "outerEnumDefaultValue"]
|
||||
outer_enum_integer_default_value: Enums.outerenuminteger
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "outerEnumIntegerDefaultValue"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (enum_string_required : Enums.enum_string) : t = {
|
||||
enum_string = None;
|
||||
enum_string_required = enum_string_required;
|
||||
enum_integer = None;
|
||||
enum_number = None;
|
||||
outer_enum = None;
|
||||
outer_enum_integer = None;
|
||||
outer_enum_default_value = None;
|
||||
outer_enum_integer_default_value = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
some_id: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@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]]
|
||||
; [@key "someMap"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
some_id = None;
|
||||
some_map = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
* Schema File.t : Must be named `File` for test.
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
(* Test capitalization *)
|
||||
source_uri: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "sourceURI"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
(** Must be named `File` for test. *)
|
||||
let create () : t = {
|
||||
source_uri = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
file: File.t
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "file"]
|
||||
files: File.t list
|
||||
[@default []]
|
||||
|
||||
; [@key "files"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
file = None;
|
||||
files = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
bar: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "bar"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
bar = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,131 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
integer: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "integer"]
|
||||
int32: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "int32"]
|
||||
int64: int64
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "int64"]
|
||||
number: float
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "number"]
|
||||
float: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "float"]
|
||||
double: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "double"]
|
||||
decimal: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "decimal"]
|
||||
string: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "string"]
|
||||
byte: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "byte"]
|
||||
binary: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "binary"]
|
||||
date: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "date"]
|
||||
date_time: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "dateTime"]
|
||||
uuid: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "uuid"]
|
||||
password: string
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "password"]
|
||||
(* A string that is a 10 digit number. Can have leading zeros. *)
|
||||
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
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "pattern_with_digits_and_delimiter"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (number : float) (byte : string) (date : string) (password : string) : t = {
|
||||
integer = None;
|
||||
int32 = None;
|
||||
int64 = None;
|
||||
number = number;
|
||||
float = None;
|
||||
double = None;
|
||||
decimal = None;
|
||||
string = None;
|
||||
byte = byte;
|
||||
binary = None;
|
||||
date = date;
|
||||
date_time = None;
|
||||
uuid = None;
|
||||
password = password;
|
||||
pattern_with_digits = None;
|
||||
pattern_with_digits_and_delimiter = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
bar: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "bar"]
|
||||
foo: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "foo"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
bar = None;
|
||||
foo = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
* Schema Health_check_result.t : Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
nullable_message: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "NullableMessage"]
|
||||
} [@@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 = {
|
||||
nullable_message = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
var_123_list: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "123-list"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
var_123_list = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
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]]
|
||||
; [@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]]
|
||||
; [@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]]
|
||||
; [@key "indirect_map"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
map_map_of_string = [];
|
||||
map_of_enum_string = [];
|
||||
direct_map = [];
|
||||
indirect_map = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
uuid: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "uuid"]
|
||||
date_time: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@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]]
|
||||
; [@key "map"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
uuid = None;
|
||||
date_time = None;
|
||||
map = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
* Schema Model_200_response.t : Model for testing model name starting with number
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
name: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "name"]
|
||||
_class: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "class"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
(** Model for testing model name starting with number *)
|
||||
let create () : t = {
|
||||
name = None;
|
||||
_class = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
string: Foo.t
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "string"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
string = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
special_property_name: int64
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "$special[property.name]"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
special_property_name = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,47 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
* Schema Name.t : Model for testing model name same as property name
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
name: int32
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "name"]
|
||||
snake_case: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "snake_case"]
|
||||
property: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "property"]
|
||||
var_123_number: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "123Number"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
(** Model for testing model name same as property name *)
|
||||
let create (name : int32) : t = {
|
||||
name = name;
|
||||
snake_case = None;
|
||||
property = None;
|
||||
var_123_number = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
integer_prop: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "integer_prop"]
|
||||
number_prop: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "number_prop"]
|
||||
boolean_prop: bool
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "boolean_prop"]
|
||||
string_prop: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "string_prop"]
|
||||
date_prop: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "date_prop"]
|
||||
datetime_prop: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "datetime_prop"]
|
||||
array_nullable_prop: Yojson.Safe.t list
|
||||
[@default []]
|
||||
|
||||
; [@key "array_nullable_prop"]
|
||||
array_and_items_nullable_prop: Yojson.Safe.t list
|
||||
[@default []]
|
||||
|
||||
; [@key "array_and_items_nullable_prop"]
|
||||
array_items_nullable: Yojson.Safe.t list
|
||||
[@default []]
|
||||
|
||||
; [@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]]
|
||||
; [@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]]
|
||||
; [@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]]
|
||||
; [@key "object_items_nullable"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
integer_prop = None;
|
||||
number_prop = None;
|
||||
boolean_prop = None;
|
||||
string_prop = None;
|
||||
date_prop = None;
|
||||
datetime_prop = None;
|
||||
array_nullable_prop = [];
|
||||
array_and_items_nullable_prop = [];
|
||||
array_items_nullable = [];
|
||||
object_nullable_prop = [];
|
||||
object_and_items_nullable_prop = [];
|
||||
object_items_nullable = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
just_number: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "JustNumber"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
just_number = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
uuid: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "uuid"]
|
||||
id: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "id"]
|
||||
deprecated_ref: Deprecated_object.t
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "deprecatedRef"]
|
||||
bars: string list
|
||||
[@default []]
|
||||
|
||||
; [@key "bars"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
uuid = None;
|
||||
id = None;
|
||||
deprecated_ref = None;
|
||||
bars = [];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
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"]
|
||||
(* Order Status *)
|
||||
status: Enums.order_status
|
||||
option [@default
|
||||
|
||||
None
|
||||
]
|
||||
; [@key "status"]
|
||||
complete: bool
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "complete"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
id = None;
|
||||
pet_id = None;
|
||||
quantity = None;
|
||||
ship_date = None;
|
||||
status = None;
|
||||
complete = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
my_number: float
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "my_number"]
|
||||
my_string: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "my_string"]
|
||||
my_boolean: bool
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "my_boolean"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
my_number = None;
|
||||
my_string = None;
|
||||
my_boolean = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
value: Enums.outerenuminteger
|
||||
|
||||
|
||||
|
||||
|
||||
; [@key "value"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (value : Enums.outerenuminteger) : t = {
|
||||
value = value;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
_type: Enums.parentwithnullable_type
|
||||
option [@default
|
||||
Some(`ChildWithNullable)
|
||||
|
||||
]
|
||||
; [@key "type"]
|
||||
nullable_property: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "nullableProperty"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
_type = None;
|
||||
nullable_property = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
[@default []]
|
||||
|
||||
; [@key "tags"]
|
||||
(* pet status in the store *)
|
||||
status: Enums.status
|
||||
option [@default
|
||||
|
||||
None
|
||||
]
|
||||
; [@key "status"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create (name : string) (photo_urls : string list) : t = {
|
||||
id = None;
|
||||
category = None;
|
||||
name = name;
|
||||
photo_urls = photo_urls;
|
||||
tags = [];
|
||||
status = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
bar: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "bar"]
|
||||
baz: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "baz"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
bar = None;
|
||||
baz = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
* Schema Return.t : Model for testing reserved words
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
return: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "return"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
(** Model for testing reserved words *)
|
||||
let create () : t = {
|
||||
return = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
id: int64
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "id"]
|
||||
name: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "name"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
id = None;
|
||||
name = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
some_property: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "someProperty"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
some_property = None;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,74 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
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"]
|
||||
(* User Status *)
|
||||
user_status: int32
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "userStatus"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
id = None;
|
||||
username = None;
|
||||
first_name = None;
|
||||
last_name = None;
|
||||
email = None;
|
||||
password = None;
|
||||
phone = None;
|
||||
user_status = None;
|
||||
}
|
||||
|
||||
|
163
samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml
Normal file
163
samples/client/petstore/ocaml-fake-petstore/src/support/enums.ml
Normal file
@ -0,0 +1,163 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
type outerenuminteger = [
|
||||
| `_0 [@printer fun fmt _ -> Format.pp_print_string fmt "0"] [@name "0"]
|
||||
| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"]
|
||||
| `_2 [@printer fun fmt _ -> Format.pp_print_string fmt "2"] [@name "2"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let outerenuminteger_of_yojson json = outerenuminteger_of_yojson (`List [json])
|
||||
let outerenuminteger_to_yojson e =
|
||||
match outerenuminteger_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type map_of_enum_string = [
|
||||
| `UPPER [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] [@name "UPPER"]
|
||||
| `Lower [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] [@name "lower"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let map_of_enum_string_of_yojson json = map_of_enum_string_of_yojson (`List [json])
|
||||
let map_of_enum_string_to_yojson e =
|
||||
match map_of_enum_string_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type enum_integer = [
|
||||
| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"]
|
||||
| `Minus1 [@printer fun fmt _ -> Format.pp_print_string fmt "-1"] [@name "-1"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let enum_integer_of_yojson json = enum_integer_of_yojson (`List [json])
|
||||
let enum_integer_to_yojson e =
|
||||
match enum_integer_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type just_symbol = [
|
||||
| `Greater_ThanEqual [@printer fun fmt _ -> Format.pp_print_string fmt ">="] [@name ">="]
|
||||
| `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let just_symbol_of_yojson json = just_symbol_of_yojson (`List [json])
|
||||
let just_symbol_to_yojson e =
|
||||
match just_symbol_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type enumclass = [
|
||||
| `_abc [@printer fun fmt _ -> Format.pp_print_string fmt "_abc"] [@name "_abc"]
|
||||
| `Minusefg [@printer fun fmt _ -> Format.pp_print_string fmt "-efg"] [@name "-efg"]
|
||||
| `Left_ParenthesisxyzRight_Parenthesis [@printer fun fmt _ -> Format.pp_print_string fmt "(xyz)"] [@name "(xyz)"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let enumclass_of_yojson json = enumclass_of_yojson (`List [json])
|
||||
let enumclass_to_yojson e =
|
||||
match enumclass_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type status = [
|
||||
| `Available [@printer fun fmt _ -> Format.pp_print_string fmt "available"] [@name "available"]
|
||||
| `Pending [@printer fun fmt _ -> Format.pp_print_string fmt "pending"] [@name "pending"]
|
||||
| `Sold [@printer fun fmt _ -> Format.pp_print_string fmt "sold"] [@name "sold"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let status_of_yojson json = status_of_yojson (`List [json])
|
||||
let status_to_yojson e =
|
||||
match status_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type order_status = [
|
||||
| `Placed [@printer fun fmt _ -> Format.pp_print_string fmt "placed"] [@name "placed"]
|
||||
| `Approved [@printer fun fmt _ -> Format.pp_print_string fmt "approved"] [@name "approved"]
|
||||
| `Delivered [@printer fun fmt _ -> Format.pp_print_string fmt "delivered"] [@name "delivered"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let order_status_of_yojson json = order_status_of_yojson (`List [json])
|
||||
let order_status_to_yojson e =
|
||||
match order_status_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type enum_query_integer = [
|
||||
| `_1 [@printer fun fmt _ -> Format.pp_print_string fmt "1"] [@name "1"]
|
||||
| `Minus2 [@printer fun fmt _ -> Format.pp_print_string fmt "-2"] [@name "-2"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let enum_query_integer_of_yojson json = enum_query_integer_of_yojson (`List [json])
|
||||
let enum_query_integer_to_yojson e =
|
||||
match enum_query_integer_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type enum_form_string_array = [
|
||||
| `Greater_Than [@printer fun fmt _ -> Format.pp_print_string fmt ">"] [@name ">"]
|
||||
| `Dollar [@printer fun fmt _ -> Format.pp_print_string fmt "$"] [@name "$"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let enum_form_string_array_of_yojson json = enum_form_string_array_of_yojson (`List [json])
|
||||
let enum_form_string_array_to_yojson e =
|
||||
match enum_form_string_array_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type parentwithnullable_type = [
|
||||
| `ChildWithNullable [@printer fun fmt _ -> Format.pp_print_string fmt "ChildWithNullable"] [@name "ChildWithNullable"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let parentwithnullable_type_of_yojson json = parentwithnullable_type_of_yojson (`List [json])
|
||||
let parentwithnullable_type_to_yojson e =
|
||||
match parentwithnullable_type_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type enum_number = [
|
||||
| `_1Period1 [@printer fun fmt _ -> Format.pp_print_string fmt "1.1"] [@name "1.1"]
|
||||
| `Minus1Period2 [@printer fun fmt _ -> Format.pp_print_string fmt "-1.2"] [@name "-1.2"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let enum_number_of_yojson json = enum_number_of_yojson (`List [json])
|
||||
let enum_number_to_yojson e =
|
||||
match enum_number_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type array_enum = [
|
||||
| `Fish [@printer fun fmt _ -> Format.pp_print_string fmt "fish"] [@name "fish"]
|
||||
| `Crab [@printer fun fmt _ -> Format.pp_print_string fmt "crab"] [@name "crab"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let array_enum_of_yojson json = array_enum_of_yojson (`List [json])
|
||||
let array_enum_to_yojson e =
|
||||
match array_enum_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type singlereftype = [
|
||||
| `Admin [@printer fun fmt _ -> Format.pp_print_string fmt "admin"] [@name "admin"]
|
||||
| `User [@printer fun fmt _ -> Format.pp_print_string fmt "user"] [@name "user"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let singlereftype_of_yojson json = singlereftype_of_yojson (`List [json])
|
||||
let singlereftype_to_yojson e =
|
||||
match singlereftype_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
||||
|
||||
type enum_string = [
|
||||
| `UPPER [@printer fun fmt _ -> Format.pp_print_string fmt "UPPER"] [@name "UPPER"]
|
||||
| `Lower [@printer fun fmt _ -> Format.pp_print_string fmt "lower"] [@name "lower"]
|
||||
] [@@deriving yojson, show { with_path = false }, eq];;
|
||||
|
||||
let enum_string_of_yojson json = enum_string_of_yojson (`List [json])
|
||||
let enum_string_to_yojson e =
|
||||
match enum_string_to_yojson e with
|
||||
| `List [json] -> json
|
||||
| json -> json
|
@ -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"
|
@ -0,0 +1,110 @@
|
||||
let api_key = ""
|
||||
let base_url = "http://petstore.swagger.io:80/v2"
|
||||
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
|
@ -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
|
11
samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES
Normal file
11
samples/client/petstore/ocaml-oneOf/.openapi-generator/FILES
Normal file
@ -0,0 +1,11 @@
|
||||
README.md
|
||||
dune
|
||||
dune-project
|
||||
petstore_client.opam
|
||||
src/apis/default_api.ml
|
||||
src/apis/default_api.mli
|
||||
src/models/child.ml
|
||||
src/models/example.ml
|
||||
src/support/enums.ml
|
||||
src/support/jsonSupport.ml
|
||||
src/support/request.ml
|
@ -0,0 +1 @@
|
||||
7.16.0-SNAPSHOT
|
33
samples/client/petstore/ocaml-oneOf/README.md
Normal file
33
samples/client/petstore/ocaml-oneOf/README.md
Normal file
@ -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
|
||||
|
9
samples/client/petstore/ocaml-oneOf/dune
Normal file
9
samples/client/petstore/ocaml-oneOf/dune
Normal file
@ -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)
|
||||
)
|
2
samples/client/petstore/ocaml-oneOf/dune-project
Normal file
2
samples/client/petstore/ocaml-oneOf/dune-project
Normal file
@ -0,0 +1,2 @@
|
||||
(lang dune 1.10)
|
||||
(name petstore_client)
|
24
samples/client/petstore/ocaml-oneOf/petstore_client.opam
Normal file
24
samples/client/petstore/ocaml-oneOf/petstore_client.opam
Normal file
@ -0,0 +1,24 @@
|
||||
opam-version: "2.0"
|
||||
name: "petstore_client"
|
||||
version: "1.0.0"
|
||||
synopsis: ""
|
||||
description: """
|
||||
Longer description
|
||||
"""
|
||||
maintainer: "Name <email>"
|
||||
authors: "Name <email>"
|
||||
license: ""
|
||||
homepage: ""
|
||||
bug-reports: ""
|
||||
dev-repo: ""
|
||||
depends: [
|
||||
"ocaml"
|
||||
"ocamlfind"
|
||||
"dune"
|
||||
"ppx_deriving_yojson"
|
||||
"conf-libev"
|
||||
"lwt"
|
||||
"cohttp-lwt-unix" {< "6.0.0"}
|
||||
"cohttp-async" {< "6.0.0"}
|
||||
]
|
||||
build: ["dune" "build" "-p" name]
|
14
samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml
Normal file
14
samples/client/petstore/ocaml-oneOf/src/apis/default_api.ml
Normal file
@ -0,0 +1,14 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
let list () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/example" in
|
||||
let headers = Request.default_headers in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Example.of_yojson) resp body
|
||||
|
@ -0,0 +1,8 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
val list : unit -> Example.t Lwt.t
|
24
samples/client/petstore/ocaml-oneOf/src/models/child.ml
Normal file
24
samples/client/petstore/ocaml-oneOf/src/models/child.ml
Normal file
@ -0,0 +1,24 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
||||
type t = {
|
||||
name: string
|
||||
|
||||
option [@default None]
|
||||
|
||||
|
||||
; [@key "name"]
|
||||
} [@@deriving yojson { strict = false }, show, eq ];;
|
||||
|
||||
let create () : t = {
|
||||
name = None;
|
||||
}
|
||||
|
||||
|
39
samples/client/petstore/ocaml-oneOf/src/models/example.ml
Normal file
39
samples/client/petstore/ocaml-oneOf/src/models/example.ml
Normal file
@ -0,0 +1,39 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
||||
|
||||
type t =
|
||||
| OneOf0 of Child.t
|
||||
| OneOf1 of int32
|
||||
[@@deriving show, eq];;
|
||||
|
||||
let to_yojson = function
|
||||
| OneOf0 v -> [%to_yojson: Child.t] v
|
||||
| OneOf1 v -> [%to_yojson: int32] v
|
||||
|
||||
(* Manual implementations because the derived one encodes into a tuple list where the first element is the constructor name. *)
|
||||
|
||||
let of_yojson json =
|
||||
[
|
||||
[%of_yojson: Child.t] json
|
||||
|> Stdlib.Result.to_option
|
||||
|> Stdlib.Option.map (fun v -> OneOf0 v);
|
||||
[%of_yojson: int32] json
|
||||
|> Stdlib.Result.to_option
|
||||
|> Stdlib.Option.map (fun v -> OneOf1 v);
|
||||
]
|
||||
|> Stdlib.List.filter_map (Fun.id)
|
||||
|> function
|
||||
| [t] -> Ok t
|
||||
| [] -> Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type Example.t")
|
||||
| ts -> let parsed_ts = ts
|
||||
|> Stdlib.List.map show
|
||||
|> Stdlib.String.concat " | "
|
||||
in Error ("Failed to parse JSON " ^ Yojson.Safe.show json ^ " into a value of type Example.t: oneOf should only succeed on one parser, but the JSON was parsed into [" ^ parsed_ts ^ "]")
|
||||
|
||||
|
||||
|
||||
|
6
samples/client/petstore/ocaml-oneOf/src/support/enums.ml
Normal file
6
samples/client/petstore/ocaml-oneOf/src/support/enums.ml
Normal file
@ -0,0 +1,6 @@
|
||||
(*
|
||||
* This file has been generated by the OCamlClientCodegen generator for openapi-generator.
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*
|
||||
*)
|
@ -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"
|
110
samples/client/petstore/ocaml-oneOf/src/support/request.ml
Normal file
110
samples/client/petstore/ocaml-oneOf/src/support/request.ml
Normal file
@ -0,0 +1,110 @@
|
||||
let api_key = ""
|
||||
let base_url = "http://api.example.xyz/v1"
|
||||
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
|
@ -9,7 +9,21 @@ let add_pet ~pet_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.write_as_json_body Pet.to_yojson pet_t in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Pet.to_yojson
|
||||
|
||||
|
||||
|
||||
pet_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
@ -17,8 +31,36 @@ let delete_pet ~pet_id ?api_key () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Request.maybe_add_header headers "api_key" (fun x -> x) api_key in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in
|
||||
let headers = Request.maybe_add_header headers "api_key"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
api_key in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
@ -26,7 +68,10 @@ let find_pets_by_status ~status =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/findByStatus" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.add_query_param_list uri "status" (List.map Enums.show_pet_status) status in
|
||||
let uri = Request.add_query_param_list uri "status" (Stdlib.List.map Enums.show_pet_status
|
||||
|
||||
)
|
||||
status in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
@ -34,7 +79,34 @@ let find_pets_by_tags ~tags =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/findByTags" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.add_query_param_list uri "tags" (List.map (fun x -> x)) tags in
|
||||
let uri = Request.add_query_param_list uri "tags" (Stdlib.List.map
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
tags in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as_list_of (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
@ -43,7 +115,21 @@ let get_pet_by_id ~pet_id =
|
||||
let uri = Request.build_uri "/pet/{petId}" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
@ -51,7 +137,21 @@ let update_pet ~pet_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.write_as_json_body Pet.to_yojson pet_t in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Pet.to_yojson
|
||||
|
||||
|
||||
|
||||
pet_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Pet.of_yojson) resp body
|
||||
|
||||
@ -59,10 +159,52 @@ let update_pet_with_form ~pet_id ?name ?status () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
let body = Request.init_form_encoded_body () in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "name" (fun x -> x) name in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "status" (fun x -> x) status in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "name"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
name in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "status"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
status in
|
||||
let body = Request.finalize_form_encoded_body body in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
@ -71,10 +213,52 @@ let upload_file ~pet_id ?additional_metadata ?file () =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/pet/{petId}/uploadImage" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string pet_id in
|
||||
let uri = Request.replace_path_param uri "petId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pet_id in
|
||||
let body = Request.init_form_encoded_body () in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "additional_metadata" (fun x -> x) additional_metadata in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "file" (fun x -> x) file in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "additional_metadata"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
additional_metadata in
|
||||
let body = Request.maybe_add_form_encoded_body_param body "file"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
file in
|
||||
let body = Request.finalize_form_encoded_body body in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Api_response.of_yojson) resp body
|
||||
|
@ -9,7 +9,21 @@ let delete_order ~order_id =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/order/{orderId}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "orderId" (fun x -> x) order_id in
|
||||
let uri = Request.replace_path_param uri "orderId"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
order_id in
|
||||
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
@ -25,7 +39,21 @@ let get_order_by_id ~order_id =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/order/{orderId}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "orderId" Int64.to_string order_id in
|
||||
let uri = Request.replace_path_param uri "orderId" Int64.to_string
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
order_id in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
|
||||
|
||||
@ -33,7 +61,21 @@ let place_order ~order_t =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/store/order" in
|
||||
let headers = Request.default_headers in
|
||||
let body = Request.write_as_json_body Order.to_yojson order_t in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Order.to_yojson
|
||||
|
||||
|
||||
|
||||
order_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap Order.of_yojson) resp body
|
||||
|
||||
|
@ -10,7 +10,21 @@ let create_user ~user_t =
|
||||
let uri = Request.build_uri "/user" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let body = Request.write_as_json_body User.to_yojson user_t in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
user_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
@ -19,7 +33,22 @@ let create_users_with_array_input ~user =
|
||||
let uri = Request.build_uri "/user/createWithArray" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let body = Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body (JsonSupport.of_list_of
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
)
|
||||
user
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
@ -28,7 +57,22 @@ let create_users_with_list_input ~user =
|
||||
let uri = Request.build_uri "/user/createWithList" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let body = Request.write_as_json_body (JsonSupport.of_list_of User.to_yojson) user in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body (JsonSupport.of_list_of
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
)
|
||||
user
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `POST uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
@ -37,7 +81,21 @@ let delete_user ~username =
|
||||
let uri = Request.build_uri "/user/{username}" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let uri = Request.replace_path_param uri "username" (fun x -> x) username in
|
||||
let uri = Request.replace_path_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
Cohttp_lwt_unix.Client.call `DELETE uri ~headers >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
@ -45,7 +103,21 @@ let get_user_by_name ~username =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/{username}" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.replace_path_param uri "username" (fun x -> x) username in
|
||||
let uri = Request.replace_path_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.unwrap User.of_yojson) resp body
|
||||
|
||||
@ -53,8 +125,36 @@ let login_user ~username ~password =
|
||||
let open Lwt.Infix in
|
||||
let uri = Request.build_uri "/user/login" in
|
||||
let headers = Request.default_headers in
|
||||
let uri = Request.add_query_param uri "username" (fun x -> x) username in
|
||||
let uri = Request.add_query_param uri "password" (fun x -> x) password in
|
||||
let uri = Request.add_query_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
let uri = Request.add_query_param uri "password"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
password in
|
||||
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
|
||||
Request.read_json_body_as (JsonSupport.to_string) resp body
|
||||
|
||||
@ -71,8 +171,36 @@ let update_user ~username ~user_t =
|
||||
let uri = Request.build_uri "/user/{username}" in
|
||||
let headers = Request.default_headers in
|
||||
let headers = Cohttp.Header.add headers "api_key" Request.api_key in
|
||||
let uri = Request.replace_path_param uri "username" (fun x -> x) username in
|
||||
let body = Request.write_as_json_body User.to_yojson user_t in
|
||||
let uri = Request.replace_path_param uri "username"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(fun x -> x)
|
||||
|
||||
|
||||
|
||||
|
||||
username in
|
||||
let body = Request.
|
||||
|
||||
write_as_json_body
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
User.to_yojson
|
||||
|
||||
|
||||
|
||||
user_t
|
||||
in
|
||||
Cohttp_lwt_unix.Client.call `PUT uri ~headers ~body >>= fun (resp, body) ->
|
||||
Request.handle_unit_response resp
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user