schema generator error type doc

This commit is contained in:
Igor Loskutov
2025-09-03 09:04:40 -04:00
parent 1b22eabb3f
commit 611e258d96
4 changed files with 20 additions and 12 deletions

View File

@@ -11,23 +11,14 @@ type RoomList = {
refetch: () => void;
};
type ValidationError = components["schemas"]["ValidationError"];
const formatValidationErrors = (errors: ValidationError[]) => {
return errors.map((error) => error.msg).join(", ");
};
// Wrapper to maintain backward compatibility
const useRoomList = (page: PaginationPage): RoomList => {
const { data, isLoading, error, refetch } = useRoomsList(page);
return {
response: data || null,
loading: isLoading,
error: error
? new Error(
error.detail ? formatValidationErrors(error.detail) : undefined,
)
? new Error(error.detail ? JSON.stringify(error.detail) : undefined)
: null,
refetch,
};