reliqua 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
reliqua-0.0.6/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Terrence Meiczinger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
reliqua-0.0.6/PKG-INFO ADDED
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.2
2
+ Name: reliqua
3
+ Version: 0.0.6
4
+ Summary: Simple, efficient, intuitive API Framework
5
+ Author-email: Terrence Meiczinger <terrence72@gmail.com>
6
+ License: MIT
7
+ Project-URL: homepage, https://github.com/tmeiczin/reliqua
8
+ Project-URL: documentation, https://github.com/tmeiczin/reliqua
9
+ Project-URL: repository, https://github.com/tmeiczin/reliqua
10
+ Keywords: utilities
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: Unix
14
+ Classifier: Operating System :: POSIX
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: falcon>=3.0.0
26
+ Requires-Dist: falcon-cors
27
+ Requires-Dist: gunicorn>=19.6.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: tox; extra == "dev"
30
+ Requires-Dist: requests; extra == "dev"
31
+ Requires-Dist: bump2version; extra == "dev"
32
+
33
+ This is sample template to create a quick Python Falcon API application. It uses a schema defined in the resource for the route path and OpenAPI documentation. The base application will handle creating the routes and documentation automatically at runtime.
34
+
35
+ You define a resource and the documentation will be auto-generated at startup using the docstrings.
36
+
37
+ ```python
38
+
39
+ from reliqua.resources.base import Resource
40
+ from reliqua import status_codes as status
41
+
42
+
43
+ class User(Resource):
44
+
45
+ __routes__ = [
46
+ '/users/{id}',
47
+ ]
48
+
49
+ phone = phone
50
+
51
+ def on_get(self, req, resp, id=None):
52
+ """
53
+ Retrieve a user. This value
54
+ is awesome
55
+
56
+ :param str id: [in=path, required] User ID
57
+ :param str email: [in=query] User Email
58
+ :param str phone: [in=query, enum] Phone Numbers
59
+
60
+ :response 200:
61
+ :response 400:
62
+
63
+ :return json:
64
+ """
65
+ try:
66
+ resp.media = users[int(id)]
67
+ except IndexError:
68
+ resp.status = status.HTTP_404
69
+
70
+ def on_delete(self, req, resp, id=None):
71
+ try:
72
+ users.pop(int(id))
73
+ resp.media = {'success': True}
74
+ except IndexError
75
+ resp.status = status.HTTP_400
76
+ ```
77
+
78
+ This will create the /users/{id} endpoint and corresponding API documentation. The OpenAPI documentation and swagger.json will be dynamically generate at application startup. The OpenAPI ui will be available at:
79
+
80
+ ```
81
+ http://<api-url>/docs/
82
+ ```
83
+
84
+ and the swagger.json file located at:
85
+
86
+ ```
87
+ http://<api-url>/docs/swagger.json
88
+ ```
89
+
90
+ To create an application, you import the application template.
91
+
92
+ ```python
93
+ from reliqua.app import Application
94
+
95
+
96
+ app = Application(
97
+ bind='0.0.0.0:8000',
98
+ proxy_api_url = 'http://example.com/api',
99
+ workers=1,
100
+ resource_path='/var/www/html/resources'
101
+ )
102
+ app.run()
103
+ ```
104
+
105
+ ```
106
+ Where:
107
+
108
+ bind: Address and port to listen for requests. [host:port]
109
+ proxy_api_url: The URL to the API when being used with a proxy, like nginx. If not supplied,
110
+ then the bind address is used.
111
+ workers: Number of worker threads to start.
112
+ resource_path: This is where your python resource files are located.
113
+ ```
114
+
115
+ Refer to the example application for more examples. You can install the library and example application
116
+
117
+ ```
118
+ python setup.py install
119
+ ```
120
+
121
+ You can execute the example application
122
+
123
+ ```
124
+ $ reliqua-example
125
+ ```
126
+
127
+ From here the openapi-ui will be available at
128
+
129
+ ````
130
+ http://localhost:8000/docs/
131
+ ````
@@ -0,0 +1,99 @@
1
+ This is sample template to create a quick Python Falcon API application. It uses a schema defined in the resource for the route path and OpenAPI documentation. The base application will handle creating the routes and documentation automatically at runtime.
2
+
3
+ You define a resource and the documentation will be auto-generated at startup using the docstrings.
4
+
5
+ ```python
6
+
7
+ from reliqua.resources.base import Resource
8
+ from reliqua import status_codes as status
9
+
10
+
11
+ class User(Resource):
12
+
13
+ __routes__ = [
14
+ '/users/{id}',
15
+ ]
16
+
17
+ phone = phone
18
+
19
+ def on_get(self, req, resp, id=None):
20
+ """
21
+ Retrieve a user. This value
22
+ is awesome
23
+
24
+ :param str id: [in=path, required] User ID
25
+ :param str email: [in=query] User Email
26
+ :param str phone: [in=query, enum] Phone Numbers
27
+
28
+ :response 200:
29
+ :response 400:
30
+
31
+ :return json:
32
+ """
33
+ try:
34
+ resp.media = users[int(id)]
35
+ except IndexError:
36
+ resp.status = status.HTTP_404
37
+
38
+ def on_delete(self, req, resp, id=None):
39
+ try:
40
+ users.pop(int(id))
41
+ resp.media = {'success': True}
42
+ except IndexError
43
+ resp.status = status.HTTP_400
44
+ ```
45
+
46
+ This will create the /users/{id} endpoint and corresponding API documentation. The OpenAPI documentation and swagger.json will be dynamically generate at application startup. The OpenAPI ui will be available at:
47
+
48
+ ```
49
+ http://<api-url>/docs/
50
+ ```
51
+
52
+ and the swagger.json file located at:
53
+
54
+ ```
55
+ http://<api-url>/docs/swagger.json
56
+ ```
57
+
58
+ To create an application, you import the application template.
59
+
60
+ ```python
61
+ from reliqua.app import Application
62
+
63
+
64
+ app = Application(
65
+ bind='0.0.0.0:8000',
66
+ proxy_api_url = 'http://example.com/api',
67
+ workers=1,
68
+ resource_path='/var/www/html/resources'
69
+ )
70
+ app.run()
71
+ ```
72
+
73
+ ```
74
+ Where:
75
+
76
+ bind: Address and port to listen for requests. [host:port]
77
+ proxy_api_url: The URL to the API when being used with a proxy, like nginx. If not supplied,
78
+ then the bind address is used.
79
+ workers: Number of worker threads to start.
80
+ resource_path: This is where your python resource files are located.
81
+ ```
82
+
83
+ Refer to the example application for more examples. You can install the library and example application
84
+
85
+ ```
86
+ python setup.py install
87
+ ```
88
+
89
+ You can execute the example application
90
+
91
+ ```
92
+ $ reliqua-example
93
+ ```
94
+
95
+ From here the openapi-ui will be available at
96
+
97
+ ````
98
+ http://localhost:8000/docs/
99
+ ````
@@ -0,0 +1,175 @@
1
+ [build-system]
2
+ build-backend = "setuptools.build_meta"
3
+ requires = [
4
+ "setuptools",
5
+ "wheel"
6
+ ]
7
+
8
+ [project]
9
+ name = "reliqua"
10
+ version = "0.0.6"
11
+ description = "Simple, efficient, intuitive API Framework"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ keywords = ["utilities"]
15
+ license = { text = "MIT" }
16
+ authors = [
17
+ {name = "Terrence Meiczinger", email = "terrence72@gmail.com"}
18
+ ]
19
+
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Developers",
23
+ "Operating System :: Unix",
24
+ "Operating System :: POSIX",
25
+ "Operating System :: MacOS",
26
+ "Operating System :: Microsoft :: Windows",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: Implementation :: CPython",
29
+ "Programming Language :: Python :: Implementation :: PyPy",
30
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
31
+ "License :: OSI Approved :: MIT License",
32
+ ]
33
+ dependencies = [
34
+ "falcon>=3.0.0",
35
+ "falcon-cors",
36
+ "gunicorn>=19.6.0",
37
+ ]
38
+
39
+ [project.urls]
40
+ homepage = "https://github.com/tmeiczin/reliqua"
41
+ documentation = "https://github.com/tmeiczin/reliqua"
42
+ repository = "https://github.com/tmeiczin/reliqua"
43
+
44
+ [project.optional-dependencies]
45
+ dev = [
46
+ "tox",
47
+ "requests",
48
+ "bump2version"
49
+ ]
50
+
51
+ [tool.setuptools]
52
+ include-package-data = true
53
+
54
+ [tool.setuptools.packages.find]
55
+ where = ["src"]
56
+
57
+ [tool.black]
58
+ line-length = 120
59
+ target-version = ["py310"]
60
+ include = '\.pyi?$'
61
+
62
+ [tool.pydocstyle]
63
+ convention = "pep257"
64
+ add-ignore = "D412"
65
+ # D412: No blank lines allowed between a section header and its content
66
+ # [required by Sphinx for ".. code:: <lang>" blocks]
67
+
68
+ [tool.pylint."messages control"]
69
+ disable = [
70
+ "too-many-instance-attributes",
71
+ "too-many-arguments",
72
+ "too-few-public-methods",
73
+ "too-many-locals",
74
+ "too-many-public-methods",
75
+ "consider-using-with",
76
+ "too-many-lines",
77
+ "too-many-branches",
78
+ "duplicate-code",
79
+ "raw-checker-failed",
80
+ "bad-inline-option",
81
+ "locally-disabled",
82
+ "file-ignored",
83
+ "suppressed-message",
84
+ "useless-suppression",
85
+ "deprecated-pragma",
86
+ "use-symbolic-message-instead",
87
+ "fixme",
88
+ ]
89
+ max-line-length = 120
90
+
91
+ [tool.pylint.BASIC]
92
+ good-names = "i, j, k, v, r, x, y, db, fh, id, ip, st, mt, ex, Run, _"
93
+ allowed-redefined-builtins = "id,"
94
+
95
+ [tool.pylint.MAIN]
96
+ extension-pkg-allow-list = "falcon,tesserocr"
97
+
98
+ [tool.pylint.FORMAT]
99
+ ignore-long-lines = "^.*https?://.*$"
100
+
101
+ [tool.isort]
102
+ multi_line_output = 3
103
+ py_version = 310
104
+ include_trailing_comma = true
105
+
106
+ [tool.ruff]
107
+ target-version = "py38"
108
+ line-length = 120
109
+ output-format = "full"
110
+ exclude = [".git", ".venv", ".tox", ".dist", "doc", "*egg,build", "*.pyc"]
111
+
112
+ [tool.ruff.lint]
113
+ select = [
114
+ "ALL",
115
+ ]
116
+ ignore = [
117
+ "A", # flake8-builtins
118
+ "ANN", # flake8-annotations
119
+ "ARG", # flake8-unused-arguments
120
+ "B904", # flake8-bugbear raise-without-from-inside-except
121
+ "BLE", # flake8-blind-except blind-except
122
+ "EM", # flake8-errmsg
123
+ "ERA", # eradicate commented-out-code
124
+ "FIX002", # flake8-fixme line-contains-todo
125
+ "FIX003", # flake8-fixme line-contains-xxx
126
+ "FBT", # flake8-boolean-trap
127
+ "G", # flake8-logging-format
128
+ "PIE", # flake8-pie
129
+ "C901", # too-complex
130
+ "COM812", # trailing-comma
131
+ "UP015", # pyupgrade redundant-open-modes
132
+ "E501", # line length
133
+ "D412", # pydocstyle blank-lines-between-header-and-content
134
+ "N818", # pep8-naming error-suffix-on-exception-name
135
+ "G010", # false positive warning (check is confused between our logger and python logging)
136
+ "PERF203", # try/except in for loop (this is minor issue and 3.11 added zero-cost exceptions)
137
+ "PLR0912", # pylint too-many-branches
138
+ "PLR0913", # pylint too-many-arguments
139
+ "PLR2004", # pylint magic-value-comparison
140
+ "PLC1901", # pylint compare-to-empty-string
141
+ "PLW2901", # pylint redefined-loop-name
142
+ "PTH", # flake8-use-pathlib
143
+ "RUF012", # ruff mutable-class-default
144
+ "S105", # flake8-bandit hardcoded-password-string
145
+ "S107", # flake8-bandit hardcoded-password-default
146
+ "S108", # flake8-bandit hardcoded-temp-file
147
+ "S304", # flake8-bandit suspicious-insecure-cipher-usage
148
+ "S311", # flake8-bandit suspicious-non-cryptographic-random-usage
149
+ "S312", # flake8-bandit suspicious-telnet-usage
150
+ "S501", # request-with-no-cert-validation
151
+ "S602", # flake8-bandit subprocess-popen-with-shell-equals-true
152
+ "S603", # flake8-bandit subprocess-without-shell-equals-true
153
+ "SLOT000", # subclasses of `str` should define `__slots__`
154
+ "SIM", # flake8-simplify
155
+ "SLF", # flake8-self
156
+ "T201", # flake8-print print
157
+ "TD003", # flake8-todos missing-todo-link
158
+ "TRY003", # tryceratops
159
+ "TRY400", # tryceratops
160
+ ]
161
+
162
+ [tool.ruff.lint.pydocstyle]
163
+ convention = "pep257"
164
+
165
+ [tool.coverage.paths]
166
+ source = ['src', '*/site-packages']
167
+
168
+ [tool.coverage.run]
169
+ source = ['reliqua']
170
+ branch = true
171
+ parallel = true
172
+
173
+ [tool.coverage.report]
174
+ show_missing = true
175
+ precision = 2
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ """
2
+ MIT License.
3
+
4
+ Copyright (c) 2017 Terrence Meiczinger
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ """
24
+
25
+ from .app import Application, load_config
26
+
27
+ __all__ = ["Application", "load_config"]
@@ -0,0 +1,196 @@
1
+ """
2
+ MIT License.
3
+
4
+ Copyright (c) 2017 Terrence Meiczinger
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ """
24
+
25
+ import glob
26
+ import importlib
27
+ import inspect
28
+ import os
29
+ import re
30
+ import sys
31
+ import uuid
32
+
33
+ import falcon
34
+ from falcon_cors import CORS
35
+
36
+ from .auth import AuthMiddleware
37
+ from .docs import Docs
38
+ from .media_handlers import JSONHandler, TextHandler, YAMLHandler
39
+ from .openapi import OpenApi
40
+ from .resources.base import Resource
41
+ from .sphinx_parser import SphinxParser
42
+ from .swagger import Swagger
43
+
44
+
45
+ class Api(falcon.App):
46
+ """Add auto route and documentation."""
47
+
48
+ def __init__(
49
+ self,
50
+ resource_path=None,
51
+ middleware=None,
52
+ config=None,
53
+ resource_attributes=None,
54
+ info=None,
55
+ openapi=None,
56
+ **_kwargs,
57
+ ):
58
+ """
59
+ Create an API instance.
60
+
61
+ :param str resource_path: Path to the resource modules
62
+ :param list middleware: Middleware
63
+ :param dict config: API configuration parameters
64
+ :param dict resource_attributes: Parameters added as resource attributes
65
+ :param dict info: Application information
66
+ :param dict openapi: OpenAPI configuration options
67
+
68
+ :return: api instance
69
+ """
70
+ info = info or {}
71
+ openapi = openapi or {}
72
+
73
+ openapi_path = openapi["path"]
74
+ self.url = openapi["api_url"]
75
+
76
+ self.openapi = openapi
77
+ self.info = info
78
+
79
+ self.openapi["spec"] = f"{openapi_path}/openapi.json"
80
+ self.openapi["static"] = f"{openapi_path}/static"
81
+ self.resources = []
82
+ self.auth = [x for x in middleware if isinstance(x, AuthMiddleware)]
83
+ self.config = config or {}
84
+ self.resource_attributes = resource_attributes or {}
85
+
86
+ path = os.path.dirname(sys.modules[__name__].__file__)
87
+ self.openapi["file_path"] = f"{path}/swagger"
88
+ self.openapi["spec_url"] = f"{self.url}{self.openapi['spec']}"
89
+ self.openapi["static_url"] = f"{self.url}{self.openapi['static']}"
90
+
91
+ middleware = middleware or []
92
+ cors = CORS(allow_all_origins=True, allow_all_methods=True, allow_all_headers=True)
93
+ middleware.append(cors.middleware)
94
+
95
+ super().__init__(middleware=middleware)
96
+
97
+ if not resource_path:
98
+ resource_path = path + "/resources"
99
+
100
+ self.req_options.auto_parse_form_urlencoded = True
101
+ self.resource_path = resource_path
102
+
103
+ self._add_handlers()
104
+ self._load_resources()
105
+ self._parse_docstrings()
106
+ self._add_routes()
107
+ self._add_docs()
108
+
109
+ def _add_handlers(self):
110
+ extra_handlers = {
111
+ "application/yaml": YAMLHandler(),
112
+ "text/html; charset=utf-8": TextHandler(),
113
+ "text/plain; charset=utf-8": TextHandler(),
114
+ "application/json": JSONHandler(),
115
+ }
116
+
117
+ self.req_options.media_handlers.update(extra_handlers)
118
+ self.resp_options.media_handlers.update(extra_handlers)
119
+
120
+ def _load_resources(self):
121
+ resources = []
122
+ path = f"{self.resource_path}/*.py"
123
+ print(f"searching {path}")
124
+ files = glob.glob(path)
125
+
126
+ for file in files:
127
+ print(f"loading {file}")
128
+ classes = self._get_classes(file)
129
+ resources.extend(classes)
130
+
131
+ # add config to resource
132
+ self.resources = [x(app_config=self.config, **self.resource_attributes) for x in resources]
133
+
134
+ def _is_route_method(self, name, suffix):
135
+ if not name.startswith("on_"):
136
+ return None
137
+
138
+ if suffix:
139
+ return name.endswith(suffix)
140
+
141
+ return re.search(r"^on_([a-z]+)$", name)
142
+
143
+ def _parse_methods(self, resource, route, methods):
144
+ parser = SphinxParser()
145
+ for name in methods:
146
+ operation_id = f"{resource.__class__.__name__}.{name}"
147
+ action = re.search(r"on_(delete|get|patch|post|put)", name).group(1)
148
+ method = getattr(resource, name)
149
+ resource.__data__[route][action] = parser.parse(method, operation_id=operation_id)
150
+
151
+ def _parse_resource(self, resource):
152
+ for route, data in resource.__routes__.items():
153
+ resource.__data__[route] = {}
154
+ suffix = data.get("suffix", None)
155
+ methods = [x for x in dir(resource) if self._is_route_method(x, suffix)]
156
+ self._parse_methods(resource, route, methods)
157
+
158
+ def _parse_docstrings(self):
159
+ for resource in self.resources:
160
+ resource.__data__ = {}
161
+ self._parse_resource(resource)
162
+
163
+ def _get_classes(self, filename):
164
+ classes = []
165
+ module_name = str(uuid.uuid3(uuid.NAMESPACE_OID, filename))
166
+ spec = importlib.util.spec_from_file_location(module_name, filename)
167
+ module = importlib.util.module_from_spec(spec)
168
+ spec.loader.exec_module(module)
169
+
170
+ for _, c in inspect.getmembers(module, inspect.isclass):
171
+ if issubclass(c, Resource) and hasattr(c, "__routes__"):
172
+ classes.append(c)
173
+
174
+ return classes
175
+
176
+ def _add_routes(self):
177
+ for resource in self.resources:
178
+ routes = resource.__routes__
179
+ for route, kwargs in routes.items():
180
+ self.add_route(route, resource, **kwargs)
181
+
182
+ def _add_docs(self):
183
+ swagger = Swagger(
184
+ self.openapi["static_url"],
185
+ self.openapi["spec_url"],
186
+ sort=self.openapi["sort"],
187
+ highlight=self.openapi["highlight"],
188
+ )
189
+ openapi = OpenApi(**self.info, auth=self.auth)
190
+ openapi.process_resources(self.resources)
191
+ schema = openapi.schema()
192
+ print(f"adding static route {self.openapi['docs_endpoint']} {self.openapi['file_path']}")
193
+ self.add_static_route(self.openapi["static"], self.openapi["file_path"])
194
+ self.add_route(self.openapi["docs_endpoint"], swagger)
195
+ print(f"adding openapi file {self.openapi['spec']}")
196
+ self.add_route(self.openapi["spec"], Docs(schema))