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

Don't work docs #2283

Open
bekishev04 opened this issue Oct 31, 2024 · 4 comments
Open

Don't work docs #2283

bekishev04 opened this issue Oct 31, 2024 · 4 comments

Comments

@bekishev04
Copy link

I send a request to /api/v1/_openapi and get 500.

Trace:

ERROR:flask_appbuilder.api:'str' object has no attribute 'update'
Traceback (most recent call last):
  File "/Users/matvei/Desktop/Work/Lexie/turbocash-backend/venv/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", line 111, in wraps
    return f(self, *args, **kwargs)
  File "/Users/matvei/Desktop/Work/Lexie/turbocash-backend/venv/lib/python3.10/site-packages/flask_appbuilder/api/manager.py", line 60, in get
    base_api.add_api_spec(api_spec)
  File "/Users/matvei/Desktop/Work/Lexie/turbocash-backend/venv/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", line 574, in add_api_spec
    self.operation_helper(
  File "/Users/matvei/Desktop/Work/Lexie/turbocash-backend/venv/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", line 683, in operation_helper
    operation_spec.update(override_method_spec.get(method.lower(), {}))
AttributeError: 'str' object has no attribute 'update'
127.0.0.1 - - [31/Oct/2024 20:07:31] "GET /api/v1/_openapi HTTP/1.1" 500 490 0.289405

For some reason, in the line operation_spec.update(override_method_spec.get(method.lower(), {})) the type string "None" is coming.
File /flask_appbuilder/api/init.py " line 683

Python 3.10
Flask-AppBuilder 4.5.1

@bekishev04
Copy link
Author

I can't send the code, but I suspect that not all handles in this project have a description. But I would still like to get 200 or more detailed errors.

@Yoyasp
Copy link
Contributor

Yoyasp commented Nov 1, 2024

I'm pretty sure that one of your openapi doc strings is misformatted or the openapi_spec_methods attribute is, without the code we cannot help you.
What you could try to identify the incorrect docstring is run your code in a debugger and catch the exception to see which docstring is the culprit.

@bekishev04
Copy link
Author

I'm pretty sure that one of your openapi doc strings is misformatted or the openapi_spec_methods attribute is, without the code we cannot help you. What you could try to identify the incorrect docstring is run your code in a debugger and catch the exception to see which docstring is the culprit.

You are right, in the project that I launched, there are many places where docstrings are not filled in. But why should all documentation fall because of it? Especially without specifying a specific reason and a line of code? In my opinion, either this should work without some endpoints, or identify problems.

@Yoyasp
Copy link
Contributor

Yoyasp commented Nov 7, 2024

In my own projects i have some endpoints that are not documented aswell, this doesnt give this error.
Your code is failing on the .update() function which is expecting operation_spec to not be a string.
This code only gets executed if there is a doc string. Therefor my assumption is that you have a doc string, but it is malformed in some way.

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