OpenAPITools / OpenAPITools/openapi-generator
[BUG] [python-flask] deepObjects in query causes exception with duplicates
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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?
The expected output is not to throw an exception and return 200.
Description
When a query has deepObjects either a BAD REQUEST with "missing parameter" is observed with python3.5 or an exception is raised with python3.6 in _resolve_param_duplicates.
openapi-generator version
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Foo API
description:
Test out deepObjects with query
version: 0.1.0
servers:
- url: 'http://localhost:8080/v1'
components:
schemas:
fakeObj:
type: object
required:
- part1
- part2
properties:
part1:
type: number
format: double
part2:
type: number
format: double
description:
Fake object that takes doubles
example:
part1: 50.4351
part2: -3.5642
parameters:
fakeObj-arrayparam:
in: query
name: fakeit
required: true
style: deepObject
explode: true
schema:
type: array
items:
$ref: '#/components/schemas/fakeObj'
description:
Array of fake objects
example:
- part1: 37.222864
part2: -80.420806
- part1: 37.223637
part2: -80.420153
- part1: 37.224372
part2: -80.419886
paths:
/obs/fake:
get:
operationId: FakeOp
parameters:
- $ref: '#/components/parameters/fakeObj-arrayparam'
responses:
'200':
description: OK
'400':
description: Bad request
Generation Details
./run-in-docker.sh generate -i PNT-A/Fake.yaml -g python-flask -o PNT-A/CDN/Fake --package-name=FaakeINF
Steps to reproduce
Created using docker tools in Ubuntu and then ran. Connected to http://localhost:8080/v1/ui and used the "Try it Out" on the /obs/fake path, accepted all the defaults and pressed execute. Expected it to come back with 'do some magic!'
Related issues/PRs
Only some for typescript but not for python-flask.
Suggest a fix
Looks like it is not handling the duplicates in the URL with the deepObject:
http://localhost:8080/v1/obs/fake?fakeit[part1]=37.222864&fakeit[part2]=-80.420806&fakeit[part1]=37.223637&fakeit[part2]=-80.420153&fakeit[part1]=37.224372&fakeit[part2]=-80.419886
python3.6 stack dump is:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/decorator.py", line 48, in wrapper
response = function(request)
File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/uri_parsing.py", line 141, in wrapper
request.query = self.resolve_query(query)
File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/uri_parsing.py", line 215, in resolve_query
return self.resolve_params(query_data, 'query')
File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/uri_parsing.py", line 113, in resolve_params
values = self._resolve_param_duplicates(values, param_defn, _in)
File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/uri_parsing.py", line 235, in _resolve_param_duplicates
return delimiter.join(values)
TypeError: sequence item 0: expected str instance, dict found
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied OpenAPI declaration and duplicate deepObject URL, then inspect connexion/decorators/uri_parsing.py at resolve_params and _resolve_param_duplicates, the locations named in the traceback. Reproduce the Python-Flask request and verify that it returns HTTP 200 without the missing-parameter response or TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100