mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 20:37:46 +00:00
* Fix uri parsing for query parameter with empty brackets (#1501) * Update tests for changed werkzeug behavior in 2.1 (#1506) https://github.com/pallets/werkzeug/issues/2352 * Bugfix/async security check (#1512) * Add failing tests * Use for else construct * openapi: remove JSON body second validation and type casting (#1170) * openapi: remove body preprocessing Body is already validated using jsonschema. There was also some type casting but it was wrong: e.g. not recurring deeply into dicts and lists, relying on existence of "type" in schema (which is not there e.g. if oneOf is used). Anyway, the only reason why types should be casted is converting integer values to float if the type is number. But this is in most cases irrelevant. Added an example, which did not work before this commit (echoed `{}`) e.g. for ``` curl localhost:8080/api/foo -H 'content-type: application/json' -d '{"foo": 1}' ``` but now the example works (echoes `{"foo": 1}`). * test with oneOf in the requestBody * remove oneof examples: superseded by tests Co-authored-by: Pavol Vargovcik <pavol.vargovcik@kiwi.com> Co-authored-by: Ruwann <ruwanlambrichts@gmail.com> Co-authored-by: Pavol Vargovčík <pavol.vargovcik@gmail.com> Co-authored-by: Pavol Vargovcik <pavol.vargovcik@kiwi.com>
33 lines
857 B
Python
33 lines
857 B
Python
from unittest.mock import MagicMock
|
|
|
|
from connexion.decorators.parameter import parameter_to_arg, pythonic
|
|
|
|
|
|
def test_injection():
|
|
request = MagicMock(name='request', path_params={'p1': '123'})
|
|
request.args = {}
|
|
request.headers = {}
|
|
request.params = {}
|
|
|
|
func = MagicMock()
|
|
|
|
def handler(**kwargs):
|
|
func(**kwargs)
|
|
|
|
class Op:
|
|
consumes = ['application/json']
|
|
|
|
def get_arguments(self, *args, **kwargs):
|
|
return {"p1": "123"}
|
|
|
|
parameter_to_arg(Op(), handler)(request)
|
|
func.assert_called_with(p1='123')
|
|
|
|
parameter_to_arg(Op(), handler, pass_context_arg_name='framework_request_ctx')(request)
|
|
func.assert_called_with(p1='123', framework_request_ctx=request.context)
|
|
|
|
|
|
def test_pythonic_params():
|
|
assert pythonic('orderBy[eq]') == 'order_by_eq'
|
|
assert pythonic('ids[]') == 'ids'
|