sanic-org / sanic-openapi

Easily document your Sanic API with a UI
https://sanic-openapi.readthedocs.io/
MIT License
505 stars 108 forks source link

When I run the following example, the following error occurs #230

Closed Liudg002 closed 2 years ago

Liudg002 commented 3 years ago

[2021-05-12 11:42:08 +0800] [99586] [INFO] Goin' Fast @ http://0.0.0.0:12000 [2021-05-12 11:42:08 +0800] [99586] [ERROR] Experienced exception while trying to serve Traceback (most recent call last): File "/Users//.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/app.py", line 918, in run serve_single(server_settings) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/server.py", line 725, in serve_single serve(server_settings) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/server.py", line 562, in serve trigger_events(after_start, loop) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/server.py", line 352, in trigger_events result = event(loop) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic_openapi/openapi2/blueprint.py", line 41, in build_spec for blueprint_name, handler in get_blueprinted_routes(app): File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic_openapi/utils.py", line 52, in get_blueprinted_routes if hasattr(route.handler, "view_class"): AttributeError: 'Route' object has no attribute 'handler' Traceback (most recent call last): File "/Users/xxx/Desktop/StudyAndWorks/Python/MyStudyTest/HyperDL/server.py", line 37, in app.run(host="0.0.0.0", port=12000) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/app.py", line 918, in run serve_single(server_settings) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/server.py", line 725, in serve_single serve(server_settings) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/server.py", line 562, in serve trigger_events(after_start, loop) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic/server.py", line 352, in trigger_events result = event(loop) File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic_openapi/openapi2/blueprint.py", line 41, in build_spec for blueprint_name, handler in get_blueprinted_routes(app): File "/Users/xxx/.conda/envs/HyperDL/lib/python3.7/site-packages/sanic_openapi/utils.py", line 52, in get_blueprinted_routes if hasattr(route.handler, "view_class"): AttributeError: 'Route' object has no attribute 'handler

Sanic Version: 21.3.4

ahopkins commented 3 years ago

Which version of sanic-openapi are you using?

Liudg002 commented 3 years ago

Sanic Version: 21.3.4 sanic-openapi: 21.3.1

ahopkins commented 3 years ago

What example? How can I replicate this?

artcg commented 3 years ago

Havent had time to look in detail at this, but the "get_blueprinted_routes" function may be the issue, the chunk of code which is removed here

https://github.com/sanic-org/sanic-openapi/pull/218/commits/17505ed5e93ca20df8e401328245df38993db03c

was aiming to handle that case, however it may have been a misguided solution, definitely open to some better suggestion...

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.