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

[UserWarning] Use instance.ctx._spec instead #228

Closed comic31 closed 3 years ago

comic31 commented 3 years ago

Hello 🖖,

Since the last version, a warning is shown upon starting sanic.

UserWarning: Setting variables on Blueprint instances is deprecated and will be removed in version 21.9. You should change your Blueprint instance to use instance.ctx._spec instead.

from sanic import Sanic
from sanic.response import json
from sanic_openapi import swagger_blueprint

app = Sanic(name="sanic_openapi_test")
app.blueprint(swagger_blueprint)

@app.route("/")
async def test(request):
    return json({"hello": "world"})

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

I created a pull request that fixes this warning

Thanks,

artcg commented 3 years ago

🔥 (thanks for the fix)