bearer auth/security section in OpenAPI Schema

175 views
Skip to first unread message

Adam Fletcher

unread,
Jan 23, 2021, 12:54:20 PM1/23/21
to django-res...@googlegroups.com
Hi DRFers,

I'm using the default OpenAPI schema generator on the latest DRF, and it is not adding the component section for securitySchemes nor is it adding the general security block.

Specifically, if i get the the schema with format openapi-json, I don't see:

{
  ...
  "components": { 
    ...
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
     }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ]
}


I'm using the default schema generator, my settings for authentication classes:

    "DEFAULT_AUTHENTICATION_CLASSES": [
        "rest_framework.authentication.SessionAuthentication",
    ],

Any ideas why the securitySchemas aren't showing up in my OpenAPI schema?

Thanks!

-Adam


Alan Crosswell

unread,
Jan 23, 2021, 1:19:18 PM1/23/21
to django-res...@googlegroups.com
See https://github.com/encode/django-rest-framework/pull/7516 which is hopefully in the pipeline for the 3.13 release. This adds a framework for adding bearerAuth, etc. by adding two class methods to each Authentication class. I believe what you are calling bearerAuth I called tokenAuth.

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CAEP43uNG1J7rK7p%2BCZ%2BFrSHBb6Y7zHxcDo%2BhzSJ36Oy9K0Bo4A%40mail.gmail.com.

Adam Fletcher

unread,
Jan 23, 2021, 1:47:35 PM1/23/21
to django-res...@googlegroups.com
Ah thanks, I see I had already <3'd that PR :)

I'll keep manually adding until the next release. Thanks!

skumar pandey

unread,
Jan 23, 2021, 10:36:03 PM1/23/21
to django-res...@googlegroups.com
Anyone can you please write the exact process of creating an api like to Add/Edit admin/,coordinator list , please tell me the process and also how to update all these on database table

Reply all
Reply to author
Forward
0 new messages