We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug I'm running flake8 on the generated code and I get a lot of these "variable assigned but not used" for the json_json_body variable:
json_json_body
async def create_or_update_version(*, client: Client, json_body: CreateVersion) -> Union[ BusinessModel, None, None, None, None, None, ]: """My description.""" url = "{}/api/v1/resource/versions".format(client.base_url,) json_json_body = json_body.to_dict() async with httpx.AsyncClient() as _client: response = await _client.post(url=url, headers=client.get_headers(), json=json_body,) if response.status_code == 200: return BusinessModel.from_dict(cast(Dict[str, Any], response.json())) if response.status_code == 400: return None if response.status_code == 401: return None if response.status_code == 403: return None if response.status_code == 404: return None if response.status_code == 500: return None else: raise ApiResponseError(response=response)
As you can see the json_json_body variable is not used.
To Reproduce It seems to happen for every client I generate from a spec file.
Expected behavior Not sure. The variable should not be declared if it is not used.
OpenAPI Spec File The interesting parts might be:
"/api/v1/resource/versions": { "post": { "operationId": "create_or_update_version", "description": "My description.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateVersion" } } } },
and
"CreateVersion": { "type": "object", "properties": { "Comment": { "type": "string" }, "ParentId": { "type": "string", "format": "uuid" }, "solutionGUID": { "type": "string", "format": "uuid" }, "versionName": { "type": "string" }, "versionNumber": { "type": "integer" } } },
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered:
So, in the above example, it should really be:
json_json_body = json_body.to_dict() async with httpx.AsyncClient() as _client: response = await _client.post(url=url, headers=client.get_headers(), json=json_json_body,)
Same for sync api endpoints. Not sure if the templates are faulty, or how to fix it yet.
Sorry, something went wrong.
Fix JSON bodies in generated endpoints. Fixes #139
8cd8e9c
Fix JSON bodies in generated endpoints. Fixes #139 (#147)
c0d101b
All set on main, will be available in the next release.
Thanks a lot for your work and your fast replies @dbanty!
Successfully merging a pull request may close this issue.
Describe the bug
I'm running flake8 on the generated code and I get a lot of these "variable assigned but not used" for the
json_json_body
variable:As you can see the
json_json_body
variable is not used.To Reproduce
It seems to happen for every client I generate from a spec file.
Expected behavior
Not sure. The variable should not be declared if it is not used.
OpenAPI Spec File
The interesting parts might be:
and
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: