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

[Bug] Incompatible with Sanic>=21.0 #216

Closed MSusik closed 3 years ago

MSusik commented 3 years ago

Describe the bug

Can't start a simple app with Sanic 21.3. Works well with Sanic 20.12.2

Traceback (most recent call last):                                                                                       
 File "yon/app2.py", line 6, in <module>                                                                                   
app.blueprint(swagger_blueprint)                                                                                      
File "/usr/local/lib/python3.8/site-packages/sanic/app.py", line 421, in blueprint                                        
blueprint.register(self, options)                                                                                     
File "/usr/local/lib/python3.8/site-packages/sanic/blueprints.py", line 234, in register                                 
 route = app._apply_static(apply_route)                                                                                
File "/usr/local/lib/python3.8/site-packages/sanic/app.py", line 345, in _apply_static                                    
return self._register_static(static)                                                                                  
File "/usr/local/lib/python3.8/site-packages/sanic/mixins/routes.py", line 796, in _register_static                       
route, _ = self.route(                                                                                                
File "/usr/local/lib/python3.8/site-packages/sanic/mixins/routes.py", line 155, in decorator                              self._apply_route(route)                                                                                             
 File "/usr/local/lib/python3.8/site-packages/sanic/app.py", line 335, in _apply_route                                     
routes = self.router.add(**params)                                                                                    
File "/usr/local/lib/python3.8/site-packages/sanic/router.py", line 128, in add                                           
route = super().add(**params)  # type: ignore                                                                         
File "/usr/local/lib/python3.8/site-packages/sanic_routing/router.py", line 170, in add                                   route.add_handler(path, handler, method, requirements, overwrite)                                                     
File "/usr/local/lib/python3.8/site-packages/sanic_routing/route.py", line 114, in add_handler                            
raise RouteExists(                                                                                                  
sanic_routing.exceptions.RouteExists: Route already registered: swagger/ [GET] 

To Reproduce Run the example from the documentation with Sanic 21.3

Environment (please complete the following information):

artcg commented 3 years ago

Yes sanic-openapi is broken with sanic 21.3, should be fixed in release next monday. Hope you can use sanic==20.12 until then...

MSusik commented 3 years ago

Yes, that would work!

Thanks, I just was not sure if you are aware of this :)

artcg commented 3 years ago

Would appreciate it if you would test against https://github.com/artcg/sanic-openapi/tree/s21

So you can install like this

pip install git+https://github.com/artcg/sanic-openapi.git@s21

It works for my organisations project at least :)

and make sure you update sanic to the latest release (21.3.2 released today/yesterday -- previous version had a bug that affected sanic-openapi)

artcg commented 3 years ago

Closing this since sanic 21.3 is now implemented (https://github.com/sanic-org/sanic-openapi/pull/218)