djangodjango-rest-frameworkswaggerelapsedtimedrf-spectacular

Show request duration in drf-spectacular (Swagger)


I have a Django/DRF project with drf-spectacular (Swagger) integration and wondering how can I add a request duration as shown on the image below. Is there any way to achive elapsed time section? Thanks in advance.

enter image description here


Solution

  • That is a Swagger-UI feature independent of drf-spectacular. To pass it through simply set the setting like so:

    
    SPECTACULAR_SETTINGS = {
        "SWAGGER_UI_SETTINGS": {
            "displayRequestDuration": True,
            # other swagger settings
        },
        # other spectcular settings
    }
    

    other swagger settings can be found here