from sanic import Sanic
from sanic.response import json
from sanic_openapi import doc, openapi2_blueprint
app = Sanic()
app.blueprint(openapi2_blueprint)
@app.get("/test")
@doc.summary("Test route")asyncdeftest(request):return json({"Hello":"World"})
Description
使用description() 装饰器,不仅可以处理简短的摘要,还可以处理API路由的长描述。
from sanic import Sanic
from sanic.response import json
from sanic_openapi import doc, openapi2_blueprint
app = Sanic()
app.blueprint(openapi2_blueprint)
@app.get("/test")
@doc.description('This is a test route with detail description.')asyncdeftest(request):return json({"Hello":"World"})