mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-10 04:19:37 +00:00
Changes requested by @prawn-cake:
- Unified the python version checking - Fixed the endpoint name registration on AioHttpApi
This commit is contained in:
@@ -142,15 +142,17 @@ class AioHttpApi(AbstractAPI):
|
||||
|
||||
def _add_operation_internal(self, method, path, operation):
|
||||
method = method.upper()
|
||||
operation_id = \
|
||||
operation.operation_id if operation.operation_id else path
|
||||
operation_id = operation.operation_id or path
|
||||
|
||||
logger.debug('... Adding %s -> %s', method, operation_id,
|
||||
extra=vars(operation))
|
||||
|
||||
handler = operation.function
|
||||
endpoint_name = '{}_{}'.format(self._api_name,
|
||||
self._normalize_string(path))
|
||||
endpoint_name = '{}_{}_{}'.format(
|
||||
self._api_name,
|
||||
self._normalize_string(path),
|
||||
method.lower()
|
||||
)
|
||||
self.subapp.router.add_route(
|
||||
method, path, handler, name=endpoint_name
|
||||
)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import importlib
|
||||
import logging
|
||||
import sys
|
||||
from itertools import chain
|
||||
from os import path
|
||||
|
||||
import click
|
||||
|
||||
@@ -97,7 +97,7 @@ class ResponseValidator(BaseDecorator):
|
||||
|
||||
is_coroutine = False
|
||||
|
||||
if sys.version_info >= (3, 4): # pragma: 2.7 no cover
|
||||
if sys.version_info[0] >= 3: # pragma: 2.7 no cover
|
||||
import asyncio
|
||||
is_coroutine = asyncio.iscoroutinefunction(function)
|
||||
|
||||
|
||||
4
setup.py
4
setup.py
@@ -48,7 +48,7 @@ tests_require = [
|
||||
flask_require
|
||||
]
|
||||
|
||||
if sys.version_info >= (3, 4):
|
||||
if sys.version_info[0] >= 3:
|
||||
tests_require.extend(aiohttp_require)
|
||||
tests_require.append(ujson_require)
|
||||
tests_require.append('pytest-aiohttp')
|
||||
@@ -63,7 +63,7 @@ class PyTest(TestCommand):
|
||||
self.cov = None
|
||||
self.pytest_args = ['--cov', 'connexion', '--cov-report', 'term-missing', '-v']
|
||||
|
||||
if sys.version_info < (3, 4):
|
||||
if sys.version_info[0] < 3:
|
||||
self.pytest_args.append('--cov-config=py2-coveragerc')
|
||||
self.pytest_args.append('--ignore=tests/aiohttp')
|
||||
|
||||
|
||||
@@ -46,8 +46,24 @@ def aiohttp_validate_responses():
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def post_greeting(name, **kwargs):
|
||||
def aiohttp_post_greeting(name, **kwargs):
|
||||
data = {'greeting': 'Hello {name}'.format(name=name)}
|
||||
return ConnexionResponse(
|
||||
body=data
|
||||
)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def aiohttp_multiple_methods_get(name, **kwargs):
|
||||
data = {'method': 'get'}
|
||||
return ConnexionResponse(
|
||||
body=data
|
||||
)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def aiohttp_multiple_methods_post(name, **kwargs):
|
||||
data = {'method': 'post'}
|
||||
return ConnexionResponse(
|
||||
body=data
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ paths:
|
||||
post:
|
||||
summary: Generate greeting
|
||||
description: Generates a greeting message.
|
||||
operationId: fakeapi.aiohttp_hello.post_greeting
|
||||
operationId: fakeapi.aiohttp_hello.aiohttp_post_greeting
|
||||
responses:
|
||||
200:
|
||||
description: greeting response
|
||||
|
||||
25
tests/fixtures/aiohttp_simple/swagger.yaml
vendored
25
tests/fixtures/aiohttp_simple/swagger.yaml
vendored
@@ -79,3 +79,28 @@ paths:
|
||||
description: json response
|
||||
schema:
|
||||
type: object
|
||||
|
||||
/multiple_methods:
|
||||
get:
|
||||
summary: Test path with multiple methods when get
|
||||
description: Test path with multiple methods when get
|
||||
operationId: fakeapi.aiohttp_hello.aiohttp_multiple_methods_get
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
200:
|
||||
description: json response
|
||||
schema:
|
||||
type: object
|
||||
|
||||
post:
|
||||
summary: Test path with multiple methods when post
|
||||
description: Test path with multiple methods when post
|
||||
operationId: fakeapi.aiohttp_hello.aiohttp_multiple_methods_post
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
200:
|
||||
description: json response
|
||||
schema:
|
||||
type: object
|
||||
|
||||
Reference in New Issue
Block a user