django-rest-frameworkdrf-spectacular

How to show the operation_id in drf_spectacular?


Is there a way to show the operation_id in drf_spectacular like it is shown in drf_yasg? The docs don't show anything regarding this setting. The operation_id is used in our code generators, so it is very practical to view it in the overview.

Swagger UI without the operation_id


Solution

  • Yes this is possible, just not very findable. It is a setting in the Swagger UI, which is listed here.

    'SWAGGER_UI_SETTINGS': {
        'displayOperationId': True,
    }
    

    With this added to the SPECTACULAR_SETTINGS, the operation_id shows up in the Swagger UI.

    Swagger UI with the operation_id