From 2f1209823e71d6e5bb802b01c2808127b25f4f6f Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 1 Jul 2021 15:06:04 +0100 Subject: [PATCH] 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. --- src/labthings/views/__init__.py | 1 - src/labthings/views/builder.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/labthings/views/__init__.py b/src/labthings/views/__init__.py index 68604f8b..5640df58 100644 --- a/src/labthings/views/__init__.py +++ b/src/labthings/views/__init__.py @@ -18,7 +18,6 @@ build_action_schema, ) from ..utilities import unpack -from . import builder, op __all__ = ["MethodView", "View", "ActionView", "PropertyView", "op", "builder"] diff --git a/src/labthings/views/builder.py b/src/labthings/views/builder.py index 03bccc6b..d6868a3f 100644 --- a/src/labthings/views/builder.py +++ b/src/labthings/views/builder.py @@ -4,10 +4,10 @@ from typing import Type from flask import abort, send_file -from flask.views import MethodView +from . import View -def static_from(static_folder: str, name=None) -> Type[MethodView]: +def static_from(static_folder: str, name=None) -> Type[View]: """ :param static_folder: str: :param name: (Default value = None) @@ -37,6 +37,6 @@ def _get(_, path=""): return send_file(indexes[0]) # Generate a basic property class - generated_class = type(name, (MethodView, object), {"get": _get}) + generated_class = type(name, (View, object), {"get": _get}) return generated_class