Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask plugin does not gracefully fail when view is None #133

Open
ElementalWarrior opened this issue Feb 15, 2024 · 1 comment
Open

Flask plugin does not gracefully fail when view is None #133

ElementalWarrior opened this issue Feb 15, 2024 · 1 comment

Comments

@ElementalWarrior
Copy link

I cannot use spec.path without providing view.

In flask.py:

def path_helper(
        self,
        path: Optional[str] = None,
        operations: Optional[dict] = None,
        parameters: Optional[List[dict]] = None,
        *,
        view: Optional[Union[Callable[..., Any], "RouteCallable"]] = None,
        app: Optional[Flask] = None,
        **kwargs: Any,
    ) -> Optional[str]:
        """Path helper that allows passing a Flask view function."""
        assert view is not None

The assert statement completely fails, this means that if someone was to define multiple plugins for apispec, then because this one fails any time view is not defined, there is no way forward.

Inside core.py inside the apispec, library, they handle any PluginMethodNotImplementedErrors, and move on. I would suggest raising that exception instead.

for plugin in self.plugins:
            try:
                ret = plugin.path_helper(
                    path=path, operations=operations, parameters=parameters, **kwargs
                )
            except PluginMethodNotImplementedError:
                continue
@lafrech
Copy link
Member

lafrech commented Feb 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants