Search code examples
pythonswagger-uifastapi

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?


Solution

  • 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.