-
Notifications
You must be signed in to change notification settings - Fork 6
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
Multiple classes wrap #6
Comments
Awesome!
Can you explain this more? What code do you want to be able to write?
What's the problem?
Probably, I'd just like to understand the problem better. |
As far as I know, I can't make endpoint like
However as mentioned above, such syntax produces following error:
|
I looked into the flasgger source code and found the blueprint name being set here to InstantAPI(app, path="/api1/", swagger_kwargs={"config": {"endpoint": "foo"}, "merge": True}) The Then I got this error: Traceback (most recent call last):
File "/home/alex/.config/JetBrains/PyCharm2022.1/scratches/scratch_2086.py", line 36, in <module>
InstantAPI(app, path="/api2/")(Methods2)
File "/home/alex/work/instant_api/instant_api/instant_api.py", line 133, in __init__
self._add_view(
File "/home/alex/work/instant_api/instant_api/instant_api.py", line 393, in _add_view
self.app.add_url_rule(
File "/home/alex/.pyenv/versions/3.8.5/lib/python3.8/site-packages/flask/scaffold.py", line 56, in wrapper_func
return f(self, *args, **kwargs)
File "/home/alex/.pyenv/versions/3.8.5/lib/python3.8/site-packages/flask/app.py", line 1090, in add_url_rule
raise AssertionError(
AssertionError: View function mapping is overwriting an existing endpoint function: InstantAPI Here the problem was that it's calling class InstantApi2(InstantAPI):
pass
InstantAPI(app, path="/api1/", swagger_kwargs={"config": {"endpoint": "foo"}, "merge": True})(Methods)
InstantApi2(app, path="/api2/")(Methods2) That seems to work 😄 Does it work for you? But of course that's confusing and inconvenient and difficult to figure out, instead of instant. A PR making this easier for other users would be good. |
Yeah works for me too! Thank you! anyway I might try to make it more obvious for other users, the merge true was the thing I was missing! I haven't figured out how to get apidocs with multiple endpoints, I assume it will be merged somehow? |
http://127.0.0.1:5000/apidocs/ shows everything combined in one page for me. |
Hi, I use InstantAPI for my work, it would be lovely to be able to wrap multiple classes around it with user-defined endpoints. Flasgger library does have problem with that, will you be willing to accept PR eventually?
The text was updated successfully, but these errors were encountered: