Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [python-nextgen] Generated ApiClient Throws Error With Dict Query Params #14725

Closed
5 of 6 tasks
emma-campbell opened this issue Feb 16, 2023 · 8 comments
Closed
5 of 6 tasks

Comments

@emma-campbell
Copy link
Contributor

emma-campbell commented Feb 16, 2023

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

OpenApi Gist Here

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
  1. Generate the client using the CLI options above
  2. 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.

@spacether
Copy link
Contributor

@emma-campbell
Copy link
Contributor Author

@spacether The spec provided is a minimal reproduction. Truthfully, we tried the python first, but ran into issues with recursion errors with specs that worked fine for other languages so decided to give python-nextgen a try. This is the only issue we've had with nextgen, so we figured submitting a PR would get us up and running quicker. That, and we prefer the output of python-nextgen to python.

@spacether
Copy link
Contributor

Can you please file a bug for the recursion error that you ran into?

@emma-campbell
Copy link
Contributor Author

@spacether Yep, I can do that later today.

@spacether
Copy link
Contributor

@emma-campbell where is the issue? Can you please file it?

@emma-campbell
Copy link
Contributor Author

@spacether Sorry, I ended up getting sick and then now having to play major catchup at work. Creating a minimal reproduction is proving to be a little more challenging than I anticipated. I can try my best to get it up by the end of the weekend.

@spacether
Copy link
Contributor

Sorry to hear that. If you want, you can direct message me the spec on slack and I can create the issue. I am there and my name is Justin Black in our slack org.

@emma-campbell
Copy link
Contributor Author

@spacether I've spent some time now trying to reproduce the issue that I previously ran into using the master branch, and for whatever reason I am unable to. If I run into it again, I will be sure to open up a new issue.

As for now, since #14727 was merged in, I will close this issue 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants