I am trying to create Swagger settings for SecurityDefinition to get the following result in openapi.json:
"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"] }]
In my settings.py, I added the following swagger options:
# 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"] }] }
The problem is that openapi.json, which is generated by Swagger, does not have a security
dict, and I do not know how it is generated.
Below is the generated openapi.json file:
{ "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": {...} }
Is there a better way to describe this concept in my Swagger settings? Or can you describe me what process and how it works to generate openapi.json file?