私はopenapi.jsonに次のような結果を得るためにSecurityDefinitionため闊歩設定を構築しようとしている:私のsettings.pyでDjango REST Swagger:Swagger設定でセキュリティセクションを使用するには?
"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"]
}]
を、私は、次の闊歩設定をadddedています
# 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"]
}]
}
問題は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を構築したのはなぜですか?プレーンな辞書で試してみてください。 –