[BUG] [python-nextgen] Generated ApiClient Throws Error With Dict Query Params
Created by: emma-campbell
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The generated ApiClient
method parameters_to_url_query
converts int
, float
, and bool
values to strings. It does not do the same for dict
. As a result passing a dict
query param to the client results in the following error.
TypeError: sequence item 1: expected str instance, dict found
Expected output would be to not have this error.
openapi-generator version
Tested against 6.3.0
as well as master
.
OpenAPI declaration file content or url
Generation Details
./run-in-docker.sh generate -i result_api.json -g python-nextgen -o python-sdk -p disallowAdditionalPropertiesIfNotPresent=false,generateSourceCodeOnly=true,packageName=result_sdk
Steps to reproduce
- Generate the client using the CLI options above
- Use the output client in a python script
from result_sdk.api.runner_api import RunnerApi
from datetime import datetime, timedelta
api = RunnerApi()
end = datetime.utcnow()
start = end - timedelta(days=5)
filter = {
"$and": [
{
"createdOn": {
"$lte": end.isoformat()
}
},
{
"createdOn": {
"$gte": start.isoformat()
}
}
]
}
results = api.get_runner_results(filter=filter)
print(results)
Error mentioned before will throw on the results =
line.
Related issues/PRs
Pretty similar to #14334, but here applying to dict
types.
Suggest a fix
I will have a PR shortly for the mustache template.