How to add prefix Bearer on django-yasg swagger

149 Views Asked by At

I am using django-yasg swagger. And i need to add prefix Bearer before my token in authorization.Header needed for django-rest-framework: Bearer I should write only token, and it makes automatically into header Authorization. My settings:

SWAGGER_SETTINGS = {
   'SECURITY_DEFINITIONS': {
      'Bearer': {
            'type': 'apiKey',
            'name': 'Authorization',
            'in': 'header'
      }
   }
}
1

There are 1 best solutions below

0
On BEST ANSWER

Check this out: https://stackoverflow.com/a/72149357/13478090. This guy recommends the use of drf-spetacular, which already supports this by default, has an easier usage, plus uses OpenAPI 3 when drf-yasg still uses 2 which will be soon deprecated.