How to enable "Expand all" in response samples in the Redoc page provided by FastAPI?

225 Views Asked by At

In Redoc, you can open the Response samples using the "Expand all" button:

enter image description here

I want to put this as the default value via custom_openapi(). Here is my code:

def custom_openapi():
    if app.openapi_schema:
        return app.openapi_schema
    openapi_schema = get_openapi(
        title=title,
        version="1.0",
        description=description,
        routes=app.routes,

    )
    app.openapi_schema = openapi_schema
    return app.openapi_schema


openapi_schema = custom_openapi()

How can I set it up?

1

There are 1 best solutions below

0
Lorna Mitchell On

Redoc supports a expandResponses as one of its configuration options, I'm not familiar with passing the Redoc configuration within FastAPI but setting the value "all", it should show all responses expanded.