class MessageOut(Exception):
message = None
alias = None
message_type = None
def __init__(self, message, alias, message_type):
self.message = message
self.alias = alias
self.message_type = message_type
so we want a feature that would add the attributable schemas of MessageOut to OpenAPI, and it should be able to detect schemas from every_inside_funtion.
def get_by_id(todo_id):
try:
todo_item = TodoItem.objects.get(id=todo_id)
return todo_item
except:
raise MessageOut(
"Todo item not found",
"todo_item_not_found",
"error"
)
@djapify
def get_todo_item(request, todo_id: int) -> TodoItemSchema:
todo_item = get_by_id(todo_id)
if todo_item.is_owner(request.user):
return todo_item
raise MessageOut(
"You are not allowed to view this item",
"todo_item_not_found",
"error"
)
possible approach, using inspect API to get all raises and comparing them with a base class, and assigning it to the schema.
Current it's
so we want a feature that would add the attributable schemas of MessageOut to OpenAPI, and it should be able to detect schemas from every_inside_funtion.
possible approach, using
inspect
API to get allraises
and comparing them with a base class, and assigning it to the schema.