This works!
from sanic import Sanic
from sanic.request import Request
from sanic.response import JSONResponse
from sanic_ext import openapi
from sanic_ext.extensions.openapi.definitions import RequestBody, Response
app = Sanic("MyHelloWorldApp")
class UserProfile:
name: str
age: int
email: str
class Success:
title: str
description: str
class Failure(Success):
pass
@app.get("/<id>")
@openapi.definition(
summary="Test Summary",
description="Test Description",
tag="User",
body=RequestBody(UserProfile, required=True),
response=[Response(Success, status=200, description="Success"), Response(Failure, status=400, description="Bad Request")],
)
async def hello_worlds(request: Request, id: str) -> JSONResponse:
return JSONResponse({"message": "Hello, world."})