Skip to content

Commit

Permalink
use non-sanitized path param name when getting the path definition fr…
Browse files Browse the repository at this point in the history
…om the spec
  • Loading branch information
dtkav committed Jan 15, 2020
1 parent f575f0e commit 667ceba
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
6 changes: 3 additions & 3 deletions connexion/operations/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ def _get_path_arguments(self, path_params, sanitize):
kwargs = {}
path_defns = {p["name"]: p for p in self.parameters if p["in"] == "path"}
for key, value in path_params.items():
key = sanitize(key)
sanitized_key = sanitize(key)
if key in path_defns:
kwargs[key] = self._get_val_from_param(value, path_defns[key])
kwargs[sanitized_key] = self._get_val_from_param(value, path_defns[key])
else: # Assume path params mechanism used for injection
kwargs[key] = value
kwargs[sanitized_key] = value
return kwargs

@abc.abstractproperty
Expand Down
14 changes: 14 additions & 0 deletions tests/aiohttp/test_aiohttp_simple_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ def test_swagger_ui_index_with_config(aiohttp_api_spec_dir, aiohttp_client):
assert b'configUrl: "swagger-ui-config.json"' in (yield from swagger_ui.read())


@asyncio.coroutine
def test_pythonic_path_param(aiohttp_api_spec_dir, aiohttp_client):
app = AioHttpApp(__name__, port=5001,
specification_dir=aiohttp_api_spec_dir,
debug=True)
app.add_api('openapi_simple.yaml', pythonic_params=True)

app_client = yield from aiohttp_client(app.app)
pythonic = yield from app_client.get('/v1.0/pythonic/100')
assert pythonic.status == 200
j = yield from pythonic.json()
assert j['id_'] == 100


@asyncio.coroutine
def test_swagger_ui_static(aiohttp_api_spec_dir, aiohttp_client):
app = AioHttpApp(__name__, port=5001,
Expand Down
4 changes: 4 additions & 0 deletions tests/fakeapi/aiohttp_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def aiohttp_post_greeting(name, **kwargs):
data = {'greeting': 'Hello {name}'.format(name=name)}
return data

@asyncio.coroutine
def aiohttp_echo(**kwargs):
return aiohttp.web.json_response(data=kwargs, status=200)


@asyncio.coroutine
def aiohttp_access_request_context(request_ctx):
Expand Down
22 changes: 22 additions & 0 deletions tests/fixtures/aiohttp/openapi_simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
openapi: 3.0.0
servers:
- url: /v1.0
info:
title: '{{title}}'
version: '1.0'
paths:
'/pythonic/{id}':
get:
description: test overloading pythonic snake-case and builtins
operationId: fakeapi.aiohttp_handlers.aiohttp_echo
parameters:
- name: id
description: id field
in: path
required: true
schema:
type: integer
responses:
'200':
description: ok
security: []

0 comments on commit 667ceba

Please sign in to comment.