From cbcc232d7582633dfc7604dde219c7c5e2d275ca Mon Sep 17 00:00:00 2001 From: Francis Charette Migneault Date: Fri, 14 Sep 2018 21:50:32 -0400 Subject: [PATCH] remove all extra api swagger paths --- magpie/api/api_rest_schemas.py | 7 ------- magpie/ui/swagger/__init__.py | 4 ---- magpie/ui/swagger/views.py | 10 +--------- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/magpie/api/api_rest_schemas.py b/magpie/api/api_rest_schemas.py index 0ec1af1c3..87952e146 100644 --- a/magpie/api/api_rest_schemas.py +++ b/magpie/api/api_rest_schemas.py @@ -61,13 +61,6 @@ def service_api_route_info(service_api): path='/api', name='swagger_schema_ui', description="{} documentation".format(TitleAPI)) -# trailing '/' allows the route to work on all following routes: -# - '/api' -# - '/api/' -# - '/magpie/api' -# - '/magpie/api/' (final '/' added automatically by application) -SwaggerAPI_extra_name = SwaggerAPI.name + '_extra' -SwaggerAPI_extra_path = SwaggerAPI.path + '/' UsersAPI = Service( path='/users', name='Users') diff --git a/magpie/ui/swagger/__init__.py b/magpie/ui/swagger/__init__.py index 1dc4f092e..09f75ea37 100644 --- a/magpie/ui/swagger/__init__.py +++ b/magpie/ui/swagger/__init__.py @@ -7,12 +7,8 @@ def includeme(config): logger.info('Adding swagger ...') config.add_route(**service_api_route_info(SwaggerAPI)) - config.add_route(SwaggerAPI_extra_name, SwaggerAPI_extra_path) config.add_route(**service_api_route_info(SwaggerGenerator)) config.add_view(api_schema, route_name=SwaggerGenerator.name, request_method='GET', renderer='json', permission=NO_PERMISSION_REQUIRED) config.add_view(api_swagger, route_name=SwaggerAPI.name, renderer='templates/swagger_ui.mako', permission=NO_PERMISSION_REQUIRED) - config.add_view(api_swagger, route_name=SwaggerAPI_extra_name, - renderer='templates/swagger_ui.mako', permission=NO_PERMISSION_REQUIRED) - # config.scan() diff --git a/magpie/ui/swagger/views.py b/magpie/ui/swagger/views.py index bf8f93a3e..734fe2e56 100644 --- a/magpie/ui/swagger/views.py +++ b/magpie/ui/swagger/views.py @@ -4,20 +4,12 @@ @SwaggerAPI.get(tags=[APITag]) -#@view_config(route_name=SwaggerAPI.name, renderer='templates/swagger_ui.mako', permission=NO_PERMISSION_REQUIRED) -#@view_config(route_name=SwaggerAPI_extra_name, renderer='templates/swagger_ui.mako', permission=NO_PERMISSION_REQUIRED) def api_swagger(request): """ Swagger UI route to display the Magpie REST API schemas. """ swagger_versions_dir = '{}'.format(os.path.abspath(os.path.join(MAGPIE_MODULE_DIR, 'ui/swagger/versions'))) - swagger_ui_path = SwaggerGenerator.path - # come back one level if path ends with '/' to properly find json (from Magpie API extra path) - if request.url.endswith(SwaggerAPI.path + '/'): - swagger_ui_path = '../{}'.format(swagger_ui_path.lstrip('/')) - # remove leading '/' if path is on same level so that json page can be found by relative route - elif swagger_ui_path.startswith('/'): - swagger_ui_path = swagger_ui_path.rstrip('/') + swagger_ui_path = SwaggerGenerator.path.lstrip('/') return_data = {'api_title': TitleAPI, 'api_schema_path': swagger_ui_path, 'api_schema_versions_dir': swagger_versions_dir}