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

Lack of coverage for schemas of types oneOf, allOf, anyOf when validating Query Params #2031

Open
temple opened this issue Feb 3, 2025 · 0 comments

Comments

@temple
Copy link

temple commented Feb 3, 2025

Description

On Connexion 3.2.0 run on Python 3.10.12

When sending a request to Connection at an endpoint which has a param with an schema containing:

Steps to reproduce

Follow the steps explained in README.md to bootstrap and launch a connexion server running a FlaskApp and serving the "Pets Spec".

Modify the specs/openapi.yaml and adapt the schema for the parameter limit (which appears at line 20), the following way:

      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            oneOf:
              - type: integer
                format: int32

Relaunch the app if running, or just launch if not.
Do a curl against the GET /pets endpoint passing a valid value on the limit query param

curl -X 'GET' \
  'http://127.0.0.1:8080/openapi/pets?limit=1' \
  -H 'accept: application/json'

Additional info

That's the exception trace:

  File "connexion/examples/methodresolver/my-venv/lib/python3.10/site-packages/connexion/validators/parameter.py", line 104, in validate
    self.validate_request(request)
  File "connexion/examples/methodresolver/my-venv/lib/python3.10/site-packages/connexion/validators/parameter.py", line 108, in validate_request
    query_errors = self.validate_query_parameter_list(
  File "connexion/examples/methodresolver/my-venv/lib/python3.10/site-packages/connexion/validators/parameter.py", line 73, in validate_query_parameter_list
    request_params = request.query_params.keys()
  File "connexion/examples/methodresolver/my-venv/lib/python3.10/site-packages/connexion/lifecycle.py", line 199, in query_params
    self._query_params = self.uri_parser.resolve_query(query_params)
  File "connexion/examples/methodresolver/my-venv/lib/python3.10/site-packages/connexion/uri_parsing.py", line 220, in resolve_query
    return self.resolve_params(query_data, "query")
  File "connexion/examples/methodresolver/my-venv/lib/python3.10/site-packages/connexion/uri_parsing.py", line 114, in resolve_params
    if param_schema and param_schema["type"] == "array":
KeyError: 'type'

The method AbstractURIParser::resolve_params seems not to be aware of the "multiple criteria schemas" and expects for a single schema; while on the other hand the body validation supports this kind of complex schemas.

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

No branches or pull requests

1 participant