Skip to content

Commit 2f12098

Browse files
committed
Swap MethodView for View in builder.static_from
Static views created with `static_from` had no metadata in the OpenAPI representation. This is fixed by subclassing our custom View. There was a circular import problem, which I have fixed by removing the `import builder` from `__init__.py` This wasn't used, and only appeared in `__all__`. It appears that removing the import has changed nothing; `from labthings.views import *` still imports the `builder` module.
1 parent bdfbcba commit 2f12098

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/labthings/views/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
build_action_schema,
1919
)
2020
from ..utilities import unpack
21-
from . import builder, op
2221

2322
__all__ = ["MethodView", "View", "ActionView", "PropertyView", "op", "builder"]
2423

src/labthings/views/builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from typing import Type
55

66
from flask import abort, send_file
7-
from flask.views import MethodView
7+
from . import View
88

99

10-
def static_from(static_folder: str, name=None) -> Type[MethodView]:
10+
def static_from(static_folder: str, name=None) -> Type[View]:
1111
"""
1212
:param static_folder: str:
1313
:param name: (Default value = None)
@@ -37,6 +37,6 @@ def _get(_, path=""):
3737
return send_file(indexes[0])
3838

3939
# Generate a basic property class
40-
generated_class = type(name, (MethodView, object), {"get": _get})
40+
generated_class = type(name, (View, object), {"get": _get})
4141

4242
return generated_class

0 commit comments

Comments
 (0)