मैं आदेश openapi.json में निम्न परिणाम प्राप्त करने के लिए SecurityDefinition के लिए स्वैगर सेटिंग्स का निर्माण करने की कोशिश कर रहा हूँ:Django REST Swagger: Swagger सेटिंग्स में सुरक्षा अनुभाग का उपयोग कैसे करें?
# Swagger settings
SWAGGER_SETTINGS = {
"SECURITY_DEFINITIONS": {
"password": {
"type": "oauth2",
"tokenUrl": "http://example.com/oauth/token",
"flow": "password",
"scopes": {
"write": "allows modifying resources",
"read": "allows reading resources"
}
}
},
"SECURITY": [{
"password": ["read", "write"]
}]
}
:
"securityDefinitions": {
"password": {
"type": "oauth2",
"tokenUrl": "http://example.com/oauth/token",
"flow": "password",
"scopes": {
"write": "allows modifying resources",
"read": "allows reading resources"
}
}
},
"security": [{
"password": ["read", "write"]
}]
मेरी settings.py में मैं निम्नलिखित अकड़ सेटिंग्स addded है
मुद्दा यह है कि swagger द्वारा उत्पन्न openapi.json में security
dict नहीं है और मुझे कोई संकेत नहीं है कि यह कैसे उत्पन्न होता है।
{
"info": {
"title": "Example Service API",
"version": ""
},
"host": "http://example.com",
"swagger": "2.0",
"securityDefinitions": {
"password": {
"type": "oauth2",
"scopes": {
"write": "allows modifying resources",
"read": "allows reading resources"
},
"tokenUrl": "http://example.com/oauth/token",
"flow": "password"
}
},
"paths": {...}
}
मेरे स्वैगर सेटिंग में इस अवधारणा को वर्णन करने के लिए किसी भी बेहतर तरीका है:
नीचे, उत्पन्न openapi.json प्रस्तुत? या क्या आप मुझे बता सकते हैं कि कौन सी प्रक्रिया है और यह openapi.json फ़ाइल जेनरेट करने के लिए कैसे काम कर रहा है?
क्या आप openapi.json फ़ाइल सामग्री पोस्ट कर सकते हैं ताकि –
डीबग करना आसान हो, मैंने अभी प्रश्न को अपडेट किया है! –
आपने सुरक्षा को परिभाषित करने के लिए सूची के अंदर निर्देश क्यों बनाया है? सादा dict के साथ इसे आज़माएं। –