diff --git a/services/web/server/requirements/_base.in b/services/web/server/requirements/_base.in index 308a1604cb3..caf883fc166 100644 --- a/services/web/server/requirements/_base.in +++ b/services/web/server/requirements/_base.in @@ -27,7 +27,6 @@ aiohttp aiohttp_jinja2 aiohttp_security aiohttp_session[secure] -aiohttp-swagger[performance] aiopg[sa] # db aiosmtplib # email asyncpg # db @@ -50,5 +49,6 @@ pydantic[email] # models python-magic # excel python-socketio # web-sockets redis +swagger-ui-py tenacity twilio diff --git a/services/web/server/requirements/_base.txt b/services/web/server/requirements/_base.txt index ada75776f9e..810e6e29fad 100644 --- a/services/web/server/requirements/_base.txt +++ b/services/web/server/requirements/_base.txt @@ -61,15 +61,12 @@ aiohttp==3.8.5 # aiohttp-jinja2 # aiohttp-security # aiohttp-session - # aiohttp-swagger aiohttp-jinja2==1.5 # via -r requirements/_base.in aiohttp-security==0.4.0 # via -r requirements/_base.in aiohttp-session==2.11.0 # via -r requirements/_base.in -aiohttp-swagger==1.0.16 - # via -r requirements/_base.in aiopg==1.4.0 # via # -r requirements/../../../../packages/service-library/requirements/_aiohttp.in @@ -269,7 +266,7 @@ jinja2==3.1.2 # -c requirements/../../../../packages/simcore-sdk/requirements/../../../requirements/constraints.txt # -c requirements/../../../../requirements/constraints.txt # aiohttp-jinja2 - # aiohttp-swagger + # swagger-ui-py json2html==1.3.0 # via -r requirements/_base.in jsondiff==2.0.0 @@ -473,6 +470,7 @@ packaging==24.1 # -r requirements/../../../../packages/simcore-sdk/requirements/_base.in # -r requirements/_base.in # gunicorn + # swagger-ui-py pamqp==3.2.1 # via aiormq passlib==1.7.4 @@ -651,7 +649,7 @@ pyyaml==6.0.1 # -c requirements/../../../../requirements/constraints.txt # -r requirements/../../../../packages/service-library/requirements/_base.in # -r requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/_base.in - # aiohttp-swagger + # swagger-ui-py redis==5.0.4 # via # -c requirements/../../../../packages/common-library/requirements/../../../requirements/constraints.txt @@ -748,6 +746,8 @@ sqlalchemy==1.4.47 # -r requirements/../../../../packages/simcore-sdk/requirements/../../../packages/postgres-database/requirements/_base.in # aiopg # alembic +swagger-ui-py==23.9.23 + # via -r requirements/_base.in tenacity==8.5.0 # via # -r requirements/../../../../packages/service-library/requirements/_base.in @@ -783,37 +783,6 @@ typing-extensions==4.12.2 # pydantic # pydantic-core # typer -ujson==5.5.0 - # via - # -c requirements/../../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/postgres-database/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/postgres-database/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/service-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/postgres-database/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/postgres-database/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/service-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/settings-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../packages/simcore-sdk/requirements/../../../requirements/constraints.txt - # -c requirements/../../../../requirements/constraints.txt - # aiohttp-swagger urllib3==2.2.3 # via # -c requirements/../../../../packages/common-library/requirements/../../../requirements/constraints.txt diff --git a/services/web/server/src/simcore_service_webserver/rest/plugin.py b/services/web/server/src/simcore_service_webserver/rest/plugin.py index 833023d6df9..9d23181a814 100644 --- a/services/web/server/src/simcore_service_webserver/rest/plugin.py +++ b/services/web/server/src/simcore_service_webserver/rest/plugin.py @@ -9,12 +9,12 @@ import logging from aiohttp import web -from aiohttp_swagger import setup_swagger # type: ignore[import-untyped] from servicelib.aiohttp.application_setup import ModuleCategory, app_module_setup from servicelib.aiohttp.rest_middlewares import ( envelope_middleware_factory, error_middleware_factory, ) +from swagger_ui import api_doc # type: ignore from .._meta import API_VTAG from ..security.plugin import setup_security @@ -60,11 +60,11 @@ def setup_rest(app: web.Application): # _logger.debug("OAS loaded from %s ", spec_path) if settings.REST_SWAGGER_API_DOC_ENABLED: - setup_swagger( - app, - swagger_url="/dev/doc", - swagger_from_file=str(spec_path), - ui_version=3, + api_doc( + app=app, + url_prefix="/dev/doc", + config_path=str(spec_path), + title="Web-API doc", ) diff --git a/services/web/server/tests/unit/isolated/test_diagnostics.py b/services/web/server/tests/unit/isolated/test_diagnostics.py index 3f18e81fd09..fdd08db062d 100644 --- a/services/web/server/tests/unit/isolated/test_diagnostics.py +++ b/services/web/server/tests/unit/isolated/test_diagnostics.py @@ -6,6 +6,7 @@ from unittest.mock import Mock import pytest +from pytest_mock import MockerFixture from servicelib.aiohttp.application_setup import APP_SETUP_COMPLETED_KEY from simcore_service_webserver.application_settings import setup_settings from simcore_service_webserver.diagnostics.plugin import setup_diagnostics @@ -35,12 +36,14 @@ def add_routes(self, *args, **kwargs): @pytest.fixture -def app_mock(): +def app_mock(mocker: MockerFixture): app = MockApp() # emulates security is initialized app[APP_SETUP_COMPLETED_KEY] = ["simcore_service_webserver.security"] + mocker.patch("simcore_service_webserver.rest.plugin.api_doc") + return app