Bug Report Checklist
Description
The generator generates OCaml code that does not compile when a query param is of type form and exploded.
See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters
The generated code is
let connections_controller_get_data_location_spec ~connection_id_or_key
~data_location_key ?(collection_params = []) () =
let open Lwt.Infix in
let uri =
Request.build_uri "/connections/{connectionIdOrKey}/data/{dataLocationKey}"
in
let headers = Request.default_headers in
let uri =
Request.replace_path_param uri "connectionIdOrKey"
(fun x -> x)
connection_id_or_key
in
let uri =
Request.replace_path_param uri "dataLocationKey"
(fun x -> x)
data_location_key
in
let uri =
Request.add_query_param uri "collectionParams"
(List.map (fun x -> x))
collection_params
in
Cohttp_lwt_unix.Client.call `GET uri ~headers >>= fun (resp, body) ->
Request.read_json_body_as
(JsonSupport.unwrap Data_collection_spec_dto.of_yojson)
resp body
The compilation error is:
File "integration-app-api/apis/connections_api.ml", line 56, characters 6-29:
56 | (List.map (fun x -> x))
^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type 'a list -> 'a list
but an expression was expected of type 'a list -> string
Type 'a list is not compatible with type string
Also:
- The generated code should not make mention of
collectionParams since the OpenAPI spec says explode: true
openapi-generator version
7.12.0 (latest)
OpenAPI declaration file content or url
https://api.integration.app/docs-json
In particular (notice the collectionParams query param):
"/connections/{connectionIdOrKey}/data/{dataLocationKey}": {
"get": {
"operationId": "ConnectionsController_getDataLocationSpec",
"parameters": [
{
"name": "connectionIdOrKey",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "dataLocationKey",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "collectionParams",
"required": false,
"in": "query",
"description": "Data Collection parameters",
"style": "form",
"explode": true,
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DataCollectionSpecDto"
}
}
}
}
},
"summary": "Get connection data collection",
"tags": [
"Connections"
]
}
}
Generation Details
$ openapi-generator-cli generate \
--generator-name ocaml \
--input-spec docs-json
Steps to reproduce
$ openapi-generator-cli generate \
--generator-name ocaml \
--input-spec docs-json
Related issues/PRs
None.
Suggest a fix
A suggestion of generated code that seems to do the trick:
let uri =
List.fold_left
(fun uri (param_name, param_value) ->
Request.add_query_param uri param_name (fun x -> x) param_value)
uri collection_params
in
Bug Report Checklist
Description
The generator generates OCaml code that does not compile when a query param is of type
formand exploded.See https://swagger.io/docs/specification/v3_0/serialization/#query-parameters
The generated code is
The compilation error is:
Also:
collectionParamssince the OpenAPI spec saysexplode: trueopenapi-generator version
7.12.0(latest)OpenAPI declaration file content or url
https://api.integration.app/docs-json
In particular (notice the
collectionParamsquery param):Generation Details
Steps to reproduce
Related issues/PRs
None.
Suggest a fix
A suggestion of generated code that seems to do the trick: