简体   繁体   中英

How to disable "django login" hyperlink while accessing swagger ui in drf-yasg?

I'm using drf-yasg to add swagger auto schema to my endpoints. The swagger-ui is being visible at /api/v1/swagger/ At my local setup this link is working fine and I'm getting the proper schema as required.

/api/v1/swagger at my local setup

But while accessing the same link when my application is deployed at the server, It is showing a "django login" hyperlink as:

/api/v1/swagger at server

And this "django login" hyperlink is navigating to -> SERVER_IP/accounts/login/?next=/api/v1/swagger/ which is showing 404 Not found page as: 404 Not found page after clicking on django login hyperlink

Even though the openAPI yaml file is being successfully generated of the endpoints at server, but the UI is not getting visible.

There was one similar question at stackoverflow: Similar question at SO , but the solution mentioned there was not working for me.

Thanks.

May you need to set USE_SESSION_AUTH to False in SWAGGER_SETTINGS in settings.py file.

# Swagger settings
SWAGGER_SETTINGS = {
    'USE_SESSION_AUTH': False        
}

Hope it could help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM