Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger ui RangeError: Maximum call stack size exceeded in FastAPI

In my FastAPI project's Swagger UI, when I execute an API after a while I get this error:

RangeError: Maximum call stack size exceeded in FastAPI

When I check the Network tab in browser's inspect, I can see that the status code is 200 and I can view the result response there. But the loading icon is still spinning in Swagger UI and after a while I get that error.

UPDATE

After lots of investigations, I realized that Swagger UI has issue with large responses (2MB+ in my case ).

I tried this:

app = FastAPI(
        swagger_ui_parameters={'syntaxHighlight.theme': 'obsidian'}
)

But it didn't work.

Does anyone has any idea how to do it right?

like image 516
Alex Jolig Avatar asked Oct 31 '25 23:10

Alex Jolig


1 Answers

I found out that one solution for this is to disable the syntax highlight in Swagger configurations. So I tried to deactivate it with FastAPI like this:

app = FastAPI(
        swagger_ui_parameters={'syntaxHighlight': False}
)

And it's working now.

like image 98
Alex Jolig Avatar answered Nov 03 '25 13:11

Alex Jolig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!