sanic-org / sanic-openapi

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

[Bug]Getting error on response from doc.py function #163

Closed garcia-0E closed 4 years ago

garcia-0E commented 4 years ago

I’ve been using Sanic on my GCP instance for two months now, however i had to restart it and all my configuration went blown.

Trying to reinitialize it, i got this error:

Traceback (most recent call last): 0|server | File “/opt/soporteventasdiemo/port/server.py”, line 160, in 0|server | async def partner_add(request, token:Token): 0|server | File “/usr/local/lib/python3.7/dist-packages/sanic_openapi/doc.py”, line 332, in inner 0|server | route_specs[func].response.append((status_code, routefield)) 0|server | TypeError: unhashable type: ‘list’

I’ve tried reinstalling dependencies but nothing works, anyone has faced this issue before?

To Reproduce

@doc.tag("Sales Partners") @doc.summary("JWT Req | Add Diemo sales partner") @doc.consumes(SalesPartnerReq, location="body", content_type='application/json') @doc.produces(SalesPartnerResp, content_type='application/json') @doc.response(200, SalesPartnerResp, description="Good response") @doc.response(401, {"message": str}, description="Unauthorized") @app.route('/partner/add',['POST','OPTIONS']) @jwt_required async def partner_add(request, token : Token):

Expected behavior Sanic server start.

Environment (please complete the following information):

koug44 commented 4 years ago

I have the same issue with Sanic 19.12. I don't have any error with Sanic 18.12

koug44 commented 4 years ago

I've deleted my comment as I'm not sure it's exactly the same issue.

@ray-t1 try to move the @doc lines after @app.route declaration

chenjr0719 commented 4 years ago

Hi @ray-t1, I apologize for my very late response. 😅 About this issue, please move @app.route('/partner/add',['POST','OPTIONS']) before other decorator. All decorators from Sanic-OpenAPI can only apply to Sanic’s route. So, please make sure all the decorator is behind app.route(), thanks.

I'm going to close this issue first, and if you still have issues, please feel free to reopen it.

garcia-0E commented 4 years ago

Hi @ray-t1, I apologize for my very late response. About this issue, please move @app.route('/partner/add',['POST','OPTIONS']) before other decorator. All decorators from Sanic-OpenAPI can only apply to Sanic’s route. So, please make sure all the decorator is behind app.route(), thanks.

I'm going to close this issue first, and if you still have issues, please feel free to reopen it.

This worked perfectly! Thanks Jacob