Repository: Clariteia/api_gateway_common

Issue:
Update `.gitignore` ignoring documentation-generated files
In order to avoid that unexpected files are committed, I propose to extend the excluded files adding the following lines:

```
# lmdb database
*.mdb

# Sphinx Api Documentation
docs/api
```

This issue was inspired by the following Pull Request: https://github.com/Clariteia/minos_microservice_networks/pull/137

This issue is a clone of: https://github.com/Clariteia/minos-pypackage/issues/12

Discussion:

Patch:
diff --git a/.gitignore b/.gitignore
index 23ae5f8..262e0c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -106,3 +106,9 @@ ENV/
 
 # Intellij IDEa / PyCharm / etc.
 .idea
+
+# lmdb database
+*.mdb
+
+# Sphinx Api Documentation
+docs/api
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/api_gateway_common.iml b/.idea/api_gateway_common.iml
new file mode 100644
index 0000000..f64dcac
--- /dev/null
+++ b/.idea/api_gateway_common.iml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="jdk" jdkName="Python 3.9 (api_gateway_common)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="PyDocumentationSettings">
+    <option name="format" value="PLAIN" />
+    <option name="myDocStringFormat" value="Plain" />
+  </component>
+  <component name="TestRunnerService">
+    <option name="PROJECT_TEST_RUNNER" value="pytest" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..e80e975
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,16 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="ignoredPackages">
+        <value>
+          <list size="3">
+            <item index="0" class="java.lang.String" itemvalue="pytest-runner" />
+            <item index="1" class="java.lang.String" itemvalue="pytest" />
+            <item index="2" class="java.lang.String" itemvalue="pytest-asyncio" />
+          </list>
+        </value>
+      </option>
+    </inspection_tool>
+  </profile>
+</component>
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1b63cf9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/api_gateway_common.iml" filepath="$PROJECT_DIR$/.idea/api_gateway_common.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/HISTORY.md b/HISTORY.md
index 802afb1..6e92299 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -2,10 +2,4 @@
 
 ## 0.0.1 (2021-05-18)
 
-* First release on PyPI.
-
-## 0.0.2 (2021-05-19)
-
-* Added REST Loader routes.
-* modified the .gitignore
-* Added injection of MinosConfig on Handler class
+-   First release on PyPI.
diff --git a/minos/api_gateway/common/__init__.py b/minos/api_gateway/common/__init__.py
index a066723..7ac3d6e 100644
--- a/minos/api_gateway/common/__init__.py
+++ b/minos/api_gateway/common/__init__.py
@@ -5,7 +5,7 @@ This file is part of minos framework.
 
 Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
 """
-__version__ = "0.0.2"
+__version__ = "0.0.1"
 
 from minos.api_gateway.common.exceptions import (
     EmptyMinosModelSequenceException,
diff --git a/minos/api_gateway/common/rest/loader.py b/minos/api_gateway/common/rest/loader.py
index 4b550c5..6abd5b1 100644
--- a/minos/api_gateway/common/rest/loader.py
+++ b/minos/api_gateway/common/rest/loader.py
@@ -4,15 +4,10 @@
 #
 # Minos framework can not be copied and/or distributed without the express
 # permission of Clariteia SL.
-import functools
-
 from aiohttp import (
     web,
 )
 
-from ..configuration import (
-    MinosConfig,
-)
 from ..importlib import (
     import_module,
 )
@@ -26,21 +21,21 @@ class RestRoutesLoader:
 
     """
 
-    __slots__ = "_endpoints", "_app", "_config"
+    __slots__ = "_endpoints", "_app"
 
-    def __init__(self, endpoints: dict, config: MinosConfig, app: web.Application = web.Application()):
+    def __init__(self, endpoints: dict, app: web.Application = web.Application()):
         self._endpoints = endpoints
         self._app = app
-        self._config = config
         self.load_routes()
 
     def load_routes(self):
         """Load routes from config file."""
         for item in self._endpoints:
-            callable_f = self.resolve_callable(item.controller, item.action)
+            callable_f = self.class_resolver(item.controller, item.action)
             self._app.router.add_route(item.method, item.route, callable_f)
 
-    def resolve_callable(self, controller: str, action: str):
+    @staticmethod
+    def class_resolver(controller: str, action: str):
         """Load controller class and action method.
         :param controller: Controller string. Example: "tests.service.CommandTestService.CommandService"
         :param action: Config instance. Example: "get_order"
@@ -49,9 +44,8 @@ class RestRoutesLoader:
         object_class = import_module(controller)
         instance_class = object_class()
         class_method = getattr(instance_class, action)
-        partial = functools.partial(class_method, config=self._config)
 
-        return partial
+        return class_method
 
     def get_app(self):
         """Return rest application instance.
diff --git a/minos/api_gateway/common/rest/service.py b/minos/api_gateway/common/rest/service.py
index be10492..6c62cba 100644
--- a/minos/api_gateway/common/rest/service.py
+++ b/minos/api_gateway/common/rest/service.py
@@ -13,9 +13,6 @@ from aiomisc.service.aiohttp import (
     AIOHTTPService,
 )
 
-from ..configuration import (
-    MinosConfig,
-)
 from .loader import (
     RestRoutesLoader,
 )
@@ -30,19 +27,13 @@ class RESTService(AIOHTTPService):
     """
 
     def __init__(
-        self,
-        address: str,
-        port: int,
-        endpoints: dict,
-        config: MinosConfig,
-        app: web.Application = web.Application(),
-        **kwds: t.Any
+        self, address: str, port: int, endpoints: dict, app: web.Application = web.Application(), **kwds: t.Any
     ):
         address = address
         port = port
         super().__init__(address=address, port=port, **kwds)
         self._endpoints = endpoints
-        self.rest_interface = RestRoutesLoader(endpoints=endpoints, config=config, app=app)
+        self.rest_interface = RestRoutesLoader(endpoints=endpoints, app=app)
 
     async def create_application(self):
         return self.rest_interface.get_app()  # pragma: no cover
diff --git a/pyproject.toml b/pyproject.toml
index a75d7b2..8d552c9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
-name = "minos-apigateway-common"
-version = "0.0.2"
+name = "api_gateway_common"
+version = "0.0.1"
 description = "Python Package with common Classes and Utilities used in Minos API Gateway."
 readme = "README.md"
 repository = "https://github.com/clariteia/api_gateway_common"
@@ -17,7 +17,7 @@ classifiers = [
 keywords = [
     "clariteia",
     "minos",
-    "apigateway",
+    "api gateway",
     "microservices",
 ]
 packages = [


Test patch:
diff --git a/tests/services/TestRestService.py b/tests/services/TestRestService.py
index fe8d457..4b21430 100644
--- a/tests/services/TestRestService.py
+++ b/tests/services/TestRestService.py
@@ -2,14 +2,10 @@ from aiohttp import (
     web,
 )
 
-from minos.api_gateway.common import (
-    MinosConfig,
-)
-
 
 class RestService(object):
-    async def add_order(self, request: web.Request, config: MinosConfig, **kwargs):
+    async def add_order(self, request):
         return web.Response(text="Order added")
 
-    async def get_order(self, request: web.Request, config: MinosConfig, **kwargs):
+    async def get_order(self, request):
         return web.Response(text="Order get")
diff --git a/tests/test_api_gateway/test_common/test_rest_interface/test_loader.py b/tests/test_api_gateway/test_common/test_rest_interface/test_loader.py
index a0df3da..43c02a6 100644
--- a/tests/test_api_gateway/test_common/test_rest_interface/test_loader.py
+++ b/tests/test_api_gateway/test_common/test_rest_interface/test_loader.py
@@ -19,6 +19,6 @@ class TestRestInterfaceLoader(IsolatedAsyncioTestCase):
     async def test_load_endpoints(self):
         conf = MinosConfig(path=BASE_PATH / "test_config.yml")
         app = web.Application()
-        rest = RestRoutesLoader(endpoints=conf.rest.endpoints, config=conf, app=app)
+        rest = RestRoutesLoader(endpoints=conf.rest.endpoints, app=app)
         app = rest.get_app()
         self.assertIsInstance(app, web.Application)
diff --git a/tests/test_api_gateway/test_common/test_rest_interface/test_service.py b/tests/test_api_gateway/test_common/test_rest_interface/test_service.py
index 41aac01..9f5a269 100644
--- a/tests/test_api_gateway/test_common/test_rest_interface/test_service.py
+++ b/tests/test_api_gateway/test_common/test_rest_interface/test_service.py
@@ -18,8 +18,8 @@ from tests.utils import (
 
 
 class ExampleRestService(RESTService):
-    def __init__(self, address: str, port: int, endpoints: dict, config=MinosConfig, **kwds: t.Any):
-        super().__init__(address=address, port=port, endpoints=endpoints, config=config, **kwds)
+    def __init__(self, address: str, port: int, endpoints: dict, **kwds: t.Any):
+        super().__init__(address=address, port=port, endpoints=endpoints, **kwds)
 
 
 class TestRestInterfaceService(AioHTTPTestCase):
@@ -35,7 +35,6 @@ class TestRestInterfaceService(AioHTTPTestCase):
             address=config.rest.connection.host,
             port=config.rest.connection.port,
             endpoints=config.rest.endpoints,
-            config=config,
             app=app,
         )
 
@@ -64,10 +63,7 @@ class TestCustomRestInterfaceService(AioHTTPTestCase):
         """
         config = MinosConfig(self.CONFIG_FILE_PATH)
         rest_interface = ExampleRestService(
-            address=config.rest.connection.host,
-            port=config.rest.connection.port,
-            endpoints=config.rest.endpoints,
-            config=config,
+            address=config.rest.connection.host, port=config.rest.connection.port, endpoints=config.rest.endpoints,
         )
 
         return await rest_interface.create_application()