Unverified Commit aaea290c authored by cr0hn's avatar cr0hn Committed by GitHub
Browse files

Merge pull request #90 from daanklijn/89-class-based-view-routes-not-shown-in-swagger-ui

Class based view routes not shown in UI when adding via add_route
parents 644903e3 d1ebf194
...@@ -41,13 +41,8 @@ def _extract_swagger_docs(end_point_doc, method="get"): ...@@ -41,13 +41,8 @@ def _extract_swagger_docs(end_point_doc, method="get"):
def _build_doc_from_func_doc(route): def _build_doc_from_func_doc(route):
out = {} out = {}
if isclass(route.handler) and issubclass(route.handler, web.View):
if isclass(route.handler) and issubclass(route.handler, web.View) and route.method == METH_ANY: for method_name in _get_method_names_for_handler(route):
method_names = {
attr for attr in dir(route.handler)
if attr.upper() in METH_ALL
}
for method_name in method_names:
method = getattr(route.handler, method_name) method = getattr(route.handler, method_name)
if method.__doc__ is not None and "---" in method.__doc__: if method.__doc__ is not None and "---" in method.__doc__:
end_point_doc = method.__doc__.splitlines() end_point_doc = method.__doc__.splitlines()
...@@ -61,6 +56,20 @@ def _build_doc_from_func_doc(route): ...@@ -61,6 +56,20 @@ def _build_doc_from_func_doc(route):
out.update(_extract_swagger_docs(end_point_doc, method=str(route.method).lower())) out.update(_extract_swagger_docs(end_point_doc, method=str(route.method).lower()))
return out return out
def _get_method_names_for_handler(route):
# Return all valid method names in handler if the method is *,
# otherwise return the specific method.
if route.method == METH_ANY:
return {
attr for attr in dir(route.handler)
if attr.upper() in METH_ALL
}
else:
return {
attr for attr in dir(route.handler)
if attr.upper() in METH_ALL and attr.upper() == route.method
}
def generate_doc_from_each_end_point( def generate_doc_from_each_end_point(
app: web.Application, app: web.Application,
......
...@@ -93,7 +93,7 @@ async def ping_partial(request): ...@@ -93,7 +93,7 @@ async def ping_partial(request):
return web.Response(text="pong") return web.Response(text="pong")
async def test_swagger_ui(test_client, loop): async def test_swagger_ui(aiohttp_client, loop):
TESTS_PATH = abspath(join(dirname(__file__))) TESTS_PATH = abspath(join(dirname(__file__)))
app = web.Application(loop=loop) app = web.Application(loop=loop)
...@@ -102,7 +102,7 @@ async def test_swagger_ui(test_client, loop): ...@@ -102,7 +102,7 @@ async def test_swagger_ui(test_client, loop):
ui_version=3 ui_version=3
) )
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc') resp1 = await client.get('/api/doc')
assert resp1.status == 200 assert resp1.status == 200
retrieved = await resp1.text() retrieved = await resp1.text()
...@@ -113,7 +113,7 @@ async def test_swagger_ui(test_client, loop): ...@@ -113,7 +113,7 @@ async def test_swagger_ui(test_client, loop):
assert retrieved == loaded assert retrieved == loaded
async def test_swagger_file_url(test_client, loop): async def test_swagger_file_url(aiohttp_client, loop):
TESTS_PATH = abspath(join(dirname(__file__))) TESTS_PATH = abspath(join(dirname(__file__)))
app = web.Application(loop=loop) app = web.Application(loop=loop)
...@@ -121,7 +121,7 @@ async def test_swagger_file_url(test_client, loop): ...@@ -121,7 +121,7 @@ async def test_swagger_file_url(test_client, loop):
ui_version=3, ui_version=3,
swagger_from_file=TESTS_PATH + "/data/example_swagger.yaml") swagger_from_file=TESTS_PATH + "/data/example_swagger.yaml")
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc/swagger.json') resp1 = await client.get('/api/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -130,19 +130,19 @@ async def test_swagger_file_url(test_client, loop): ...@@ -130,19 +130,19 @@ async def test_swagger_file_url(test_client, loop):
assert 'API Title' in result['info']['title'] assert 'API Title' in result['info']['title']
async def test_partial_swagger_file(test_client, loop): async def test_partial_swagger_file(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping-partial", ping_partial) app.router.add_route('GET', "/ping-partial", ping_partial)
setup_swagger(app, ui_version=3) setup_swagger(app, ui_version=3)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc/swagger.json') resp1 = await client.get('/api/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
assert '/ping-partial' in result['paths'] assert '/ping-partial' in result['paths']
async def test_custom_swagger(test_client, loop): async def test_custom_swagger(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -154,7 +154,7 @@ async def test_custom_swagger(test_client, loop): ...@@ -154,7 +154,7 @@ async def test_custom_swagger(test_client, loop):
api_version="1.0.0", api_version="1.0.0",
contact="my.custom.contact@example.com") contact="my.custom.contact@example.com")
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -162,7 +162,7 @@ async def test_custom_swagger(test_client, loop): ...@@ -162,7 +162,7 @@ async def test_custom_swagger(test_client, loop):
assert 'Test Custom Title' in result['info']['title'] assert 'Test Custom Title' in result['info']['title']
async def test_swagger_home_decorator(test_client, loop): async def test_swagger_home_decorator(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -175,7 +175,7 @@ async def test_swagger_home_decorator(test_client, loop): ...@@ -175,7 +175,7 @@ async def test_swagger_home_decorator(test_client, loop):
contact="my.custom.contact@example.com", contact="my.custom.contact@example.com",
swagger_home_decor=lambda x: x) swagger_home_decor=lambda x: x)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -183,7 +183,7 @@ async def test_swagger_home_decorator(test_client, loop): ...@@ -183,7 +183,7 @@ async def test_swagger_home_decorator(test_client, loop):
assert 'Test Custom Title' in result['info']['title'] assert 'Test Custom Title' in result['info']['title']
async def test_swagger_def_decorator(test_client, loop): async def test_swagger_def_decorator(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -196,7 +196,7 @@ async def test_swagger_def_decorator(test_client, loop): ...@@ -196,7 +196,7 @@ async def test_swagger_def_decorator(test_client, loop):
contact="my.custom.contact@example.com", contact="my.custom.contact@example.com",
swagger_def_decor=lambda x: x) swagger_def_decor=lambda x: x)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -210,7 +210,7 @@ def swagger_info(): ...@@ -210,7 +210,7 @@ def swagger_info():
return yaml.full_load(open(filename).read()) return yaml.full_load(open(filename).read())
async def test_swagger_info(test_client, loop, swagger_info): async def test_swagger_info(aiohttp_client, loop, swagger_info):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -219,7 +219,7 @@ async def test_swagger_info(test_client, loop, swagger_info): ...@@ -219,7 +219,7 @@ async def test_swagger_info(test_client, loop, swagger_info):
swagger_url="/api/v1/doc", swagger_url="/api/v1/doc",
swagger_info=swagger_info) swagger_info=swagger_info)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -228,11 +228,11 @@ async def test_swagger_info(test_client, loop, swagger_info): ...@@ -228,11 +228,11 @@ async def test_swagger_info(test_client, loop, swagger_info):
assert 'API Title' in result['info']['title'] assert 'API Title' in result['info']['title']
async def test_undocumented_fn(test_client, loop): async def test_undocumented_fn(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/undoc_ping", undoc_ping) app.router.add_route('GET', "/undoc_ping", undoc_ping)
setup_swagger(app, ui_version=3) setup_swagger(app, ui_version=3)
client = await test_client(app) client = await aiohttp_client(app)
resp = await client.get('/undoc_ping') resp = await client.get('/undoc_ping')
assert resp.status == 200 assert resp.status == 200
swagger_resp1 = await client.get('/api/doc/swagger.json') swagger_resp1 = await client.get('/api/doc/swagger.json')
...@@ -241,11 +241,11 @@ async def test_undocumented_fn(test_client, loop): ...@@ -241,11 +241,11 @@ async def test_undocumented_fn(test_client, loop):
assert not result['paths'] assert not result['paths']
async def test_wrong_method(test_client, loop): async def test_wrong_method(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('POST', "/post_ping", ping) app.router.add_route('POST', "/post_ping", ping)
setup_swagger(app, ui_version=3) setup_swagger(app, ui_version=3)
client = await test_client(app) client = await aiohttp_client(app)
# GET # GET
swagger_resp1 = await client.get('/api/doc/swagger.json') swagger_resp1 = await client.get('/api/doc/swagger.json')
assert swagger_resp1.status == 200 assert swagger_resp1.status == 200
...@@ -256,12 +256,12 @@ async def test_wrong_method(test_client, loop): ...@@ -256,12 +256,12 @@ async def test_wrong_method(test_client, loop):
assert resp.status == 405 assert resp.status == 405
async def test_class_view(test_client, loop): async def test_class_view(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('*', "/class_view", ClassView) app.router.add_route('*', "/class_view", ClassView)
setup_swagger(app, ui_version=3) setup_swagger(app, ui_version=3)
client = await test_client(app) client = await aiohttp_client(app)
# GET # GET
resp = await client.get('/class_view') resp = await client.get('/class_view')
assert resp.status == 200 assert resp.status == 200
...@@ -294,7 +294,7 @@ async def test_class_view(test_client, loop): ...@@ -294,7 +294,7 @@ async def test_class_view(test_client, loop):
assert "patch" not in result['paths']["/class_view"] assert "patch" not in result['paths']["/class_view"]
async def test_data_defs(test_client, loop): async def test_data_defs(aiohttp_client, loop):
TESTS_PATH = abspath(join(dirname(__file__))) TESTS_PATH = abspath(join(dirname(__file__)))
file = open(TESTS_PATH + "/data/example_data_definitions.json") file = open(TESTS_PATH + "/data/example_data_definitions.json")
app = web.Application(loop=loop) app = web.Application(loop=loop)
...@@ -302,7 +302,7 @@ async def test_data_defs(test_client, loop): ...@@ -302,7 +302,7 @@ async def test_data_defs(test_client, loop):
setup_swagger(app, ui_version=3, definitions=json.loads(file.read())) setup_swagger(app, ui_version=3, definitions=json.loads(file.read()))
file.close() file.close()
client = await test_client(app) client = await aiohttp_client(app)
swagger_resp1 = await client.get('/api/doc/swagger.json') swagger_resp1 = await client.get('/api/doc/swagger.json')
assert swagger_resp1.status == 200 assert swagger_resp1.status == 200
result = await swagger_resp1.json() result = await swagger_resp1.json()
...@@ -311,14 +311,14 @@ async def test_data_defs(test_client, loop): ...@@ -311,14 +311,14 @@ async def test_data_defs(test_client, loop):
assert result['components']['schemas']['User']['properties']['permissions']['items']['$ref'] is not None assert result['components']['schemas']['User']['properties']['permissions']['items']['$ref'] is not None
async def test_sub_app(test_client, loop): async def test_sub_app(aiohttp_client, loop):
sub_app = web.Application(loop=loop) sub_app = web.Application(loop=loop)
sub_app.router.add_route('*', "/class_view", ClassView) sub_app.router.add_route('*', "/class_view", ClassView)
setup_swagger(sub_app, ui_version=3, api_base_url='/sub_app') setup_swagger(sub_app, ui_version=3, api_base_url='/sub_app')
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.add_subapp(prefix='/sub_app', subapp=sub_app) app.add_subapp(prefix='/sub_app', subapp=sub_app)
client = await test_client(app) client = await aiohttp_client(app)
# GET # GET
resp = await client.get('/sub_app/class_view') resp = await client.get('/sub_app/class_view')
assert resp.status == 200 assert resp.status == 200
......
...@@ -93,17 +93,17 @@ async def ping_partial(request): ...@@ -93,17 +93,17 @@ async def ping_partial(request):
return web.Response(text="pong") return web.Response(text="pong")
async def test_ping(test_client, loop): async def test_ping(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
client = await test_client(app) client = await aiohttp_client(app)
resp = await client.get('/ping') resp = await client.get('/ping')
assert resp.status == 200 assert resp.status == 200
text = await resp.text() text = await resp.text()
assert 'pong' in text assert 'pong' in text
async def test_swagger_ui(test_client, loop): async def test_swagger_ui(aiohttp_client, loop):
TESTS_PATH = abspath(join(dirname(__file__))) TESTS_PATH = abspath(join(dirname(__file__)))
...@@ -111,7 +111,7 @@ async def test_swagger_ui(test_client, loop): ...@@ -111,7 +111,7 @@ async def test_swagger_ui(test_client, loop):
setup_swagger(app, setup_swagger(app,
swagger_from_file=TESTS_PATH + "/data/example_swagger.yaml") swagger_from_file=TESTS_PATH + "/data/example_swagger.yaml")
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc') resp1 = await client.get('/api/doc')
assert resp1.status == 200 assert resp1.status == 200
retrieved = await resp1.text() retrieved = await resp1.text()
...@@ -122,7 +122,7 @@ async def test_swagger_ui(test_client, loop): ...@@ -122,7 +122,7 @@ async def test_swagger_ui(test_client, loop):
assert retrieved == loaded assert retrieved == loaded
async def test_swagger_ui3(test_client, loop): async def test_swagger_ui3(aiohttp_client, loop):
TESTS_PATH = abspath(join(dirname(__file__))) TESTS_PATH = abspath(join(dirname(__file__)))
app = web.Application(loop=loop) app = web.Application(loop=loop)
...@@ -131,7 +131,7 @@ async def test_swagger_ui3(test_client, loop): ...@@ -131,7 +131,7 @@ async def test_swagger_ui3(test_client, loop):
ui_version=3 ui_version=3
) )
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc') resp1 = await client.get('/api/doc')
assert resp1.status == 200 assert resp1.status == 200
retrieved = await resp1.text() retrieved = await resp1.text()
...@@ -142,14 +142,14 @@ async def test_swagger_ui3(test_client, loop): ...@@ -142,14 +142,14 @@ async def test_swagger_ui3(test_client, loop):
assert retrieved == loaded assert retrieved == loaded
async def test_swagger_file_url(test_client, loop): async def test_swagger_file_url(aiohttp_client, loop):
TESTS_PATH = abspath(join(dirname(__file__))) TESTS_PATH = abspath(join(dirname(__file__)))
app = web.Application(loop=loop) app = web.Application(loop=loop)
setup_swagger(app, setup_swagger(app,
swagger_from_file=TESTS_PATH + "/data/example_swagger.yaml") swagger_from_file=TESTS_PATH + "/data/example_swagger.yaml")
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc/swagger.json') resp1 = await client.get('/api/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -158,19 +158,19 @@ async def test_swagger_file_url(test_client, loop): ...@@ -158,19 +158,19 @@ async def test_swagger_file_url(test_client, loop):
assert 'API Title' in result['info']['title'] assert 'API Title' in result['info']['title']
async def test_partial_swagger_file(test_client, loop): async def test_partial_swagger_file(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping-partial", ping_partial) app.router.add_route('GET', "/ping-partial", ping_partial)
setup_swagger(app) setup_swagger(app)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/doc/swagger.json') resp1 = await client.get('/api/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
assert '/ping-partial' in result['paths'] assert '/ping-partial' in result['paths']
async def test_custom_swagger(test_client, loop): async def test_custom_swagger(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -181,7 +181,7 @@ async def test_custom_swagger(test_client, loop): ...@@ -181,7 +181,7 @@ async def test_custom_swagger(test_client, loop):
api_version="1.0.0", api_version="1.0.0",
contact="my.custom.contact@example.com") contact="my.custom.contact@example.com")
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -189,7 +189,7 @@ async def test_custom_swagger(test_client, loop): ...@@ -189,7 +189,7 @@ async def test_custom_swagger(test_client, loop):
assert 'Test Custom Title' in result['info']['title'] assert 'Test Custom Title' in result['info']['title']
async def test_swagger_home_decorator(test_client, loop): async def test_swagger_home_decorator(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -201,7 +201,7 @@ async def test_swagger_home_decorator(test_client, loop): ...@@ -201,7 +201,7 @@ async def test_swagger_home_decorator(test_client, loop):
contact="my.custom.contact@example.com", contact="my.custom.contact@example.com",
swagger_home_decor=lambda x: x) swagger_home_decor=lambda x: x)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -209,7 +209,7 @@ async def test_swagger_home_decorator(test_client, loop): ...@@ -209,7 +209,7 @@ async def test_swagger_home_decorator(test_client, loop):
assert 'Test Custom Title' in result['info']['title'] assert 'Test Custom Title' in result['info']['title']
async def test_swagger_def_decorator(test_client, loop): async def test_swagger_def_decorator(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -221,7 +221,7 @@ async def test_swagger_def_decorator(test_client, loop): ...@@ -221,7 +221,7 @@ async def test_swagger_def_decorator(test_client, loop):
contact="my.custom.contact@example.com", contact="my.custom.contact@example.com",
swagger_def_decor=lambda x: x) swagger_def_decor=lambda x: x)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -235,7 +235,7 @@ def swagger_info(): ...@@ -235,7 +235,7 @@ def swagger_info():
return yaml.full_load(open(filename).read()) return yaml.full_load(open(filename).read())
async def test_swagger_info(test_client, loop, swagger_info): async def test_swagger_info(aiohttp_client, loop, swagger_info):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/ping", ping) app.router.add_route('GET', "/ping", ping)
description = "Test Custom Swagger" description = "Test Custom Swagger"
...@@ -243,7 +243,7 @@ async def test_swagger_info(test_client, loop, swagger_info): ...@@ -243,7 +243,7 @@ async def test_swagger_info(test_client, loop, swagger_info):
swagger_url="/api/v1/doc", swagger_url="/api/v1/doc",
swagger_info=swagger_info) swagger_info=swagger_info)
client = await test_client(app) client = await aiohttp_client(app)
resp1 = await client.get('/api/v1/doc/swagger.json') resp1 = await client.get('/api/v1/doc/swagger.json')
assert resp1.status == 200 assert resp1.status == 200
result = await resp1.json() result = await resp1.json()
...@@ -252,11 +252,11 @@ async def test_swagger_info(test_client, loop, swagger_info): ...@@ -252,11 +252,11 @@ async def test_swagger_info(test_client, loop, swagger_info):
assert 'API Title' in result['info']['title'] assert 'API Title' in result['info']['title']
async def test_undocumented_fn(test_client, loop): async def test_undocumented_fn(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('GET', "/undoc_ping", undoc_ping) app.router.add_route('GET', "/undoc_ping", undoc_ping)
setup_swagger(app) setup_swagger(app)
client = await test_client(app) client = await aiohttp_client(app)
resp = await client.get('/undoc_ping') resp = await client.get('/undoc_ping')
assert resp.status == 200 assert resp.status == 200
swagger_resp1 = await client.get('/api/doc/swagger.json') swagger_resp1 = await client.get('/api/doc/swagger.json')
...@@ -265,11 +265,11 @@ async def test_undocumented_fn(test_client, loop): ...@@ -265,11 +265,11 @@ async def test_undocumented_fn(test_client, loop):
assert not result['paths'] assert not result['paths']
async def test_wrong_method(test_client, loop): async def test_wrong_method(aiohttp_client, loop):
app = web.Application(loop=loop) app = web.Application(loop=loop)
app.router.add_route('POST', "/post_ping", ping) app.router.add_route('POST', "/post_ping", ping)
setup_swagger(app) setup_swagger(app)
client = await test_client(app) client = await aiohttp_client(app)
# GET # GET
swagger_resp1 = await client.get('/api/doc/swagger.json')