ก่อนอื่น ให้ติดตั้งเฟรมเวิร์ก django rest ลงในแอปพลิเคชันของคุณ และนำเข้าเฟรมเวิร์กนั้นในไฟล์ setup.py
สร้าง API สองสามตัวโดยใช้ DRF จากนั้นเพิ่มการตั้งค่าผยองภายในไฟล์ setup.py ของคุณ
SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'api_key': {
'type': 'apiKey',
'in': 'header',
'name': 'Authorization'
}
}, # setting to pass token in header
'USE_SESSION_AUTH': False,
# set to True if session based authentication needed
'JSON_EDITOR': True,
'api_path': 'api/',
'api_version': 'v0',
"is_authenticated": False, # Set to True to enforce user authentication,
"is_superuser": False, # Set to True to enforce admin only access
'unauthenticated_user': 'django.contrib.auth.models.AnonymousUser',
# unauthenticated user will be shown as Anonymous user in swagger UI.
}
หมายเหตุ:- คุณสามารถแก้ไขการตั้งค่าผยองได้ตามที่คุณต้องการ
person
Ankush Sahu
schedule
23.08.2019