doc: update swagger

This commit is contained in:
superobk
2024-04-25 15:07:18 +08:00
parent 201d0f374c
commit c062abbe19
4 changed files with 19 additions and 79 deletions

View File

@ -1,27 +0,0 @@
from typing import Any, Coroutine
from fastapi import Request, Response, status
from fastapi.responses import JSONResponse
from .blackbox import Blackbox
class SUM(Blackbox):
def __call__(self, *args, **kwargs):
return self.processing(*args, **kwargs)
def valid(self, *args, **kwargs) -> bool:
data = args[0]
return isinstance(data, list)
def processing(self, *args, **kwargs):
return sum(args)
async def fast_api_handler(self, request: Request) -> Response:
try:
data = await request.json()
except:
return JSONResponse(content={"error": "json parse error"}, status_code=status.HTTP_400_BAD_REQUEST)
if not self.valid(data):
return JSONResponse(content={"error": "format error"}, status_code=status.HTTP_400_BAD_REQUEST)
return JSONResponse(content={"result": self.processing(data)}, status_code=status.HTTP_200_OK)