This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 88
Support for "securityDefinitions" #54
Copy link
Copy link
Open
Description
Currently even though "securityDefinitions" section is provided in the documentation for the API, it is not reproduced in the final JSON produced.
Sample Documentation on a API method (with securityDefinitions section)
@app.route('/reports', methods=["POST"])
def sample_meth():
"""
Uploads the given file to servers.
---
securityDefinitions:
BasicAuth:
type: "basic"
definitions:
- schema:
id: ErrorResponse
properties:
error:
type: "string"
description: "Gives a description about the error."
example:
error: "Lab name is not provided."
operationId: "uploadReport"
security:
- BasicAuth: []
"""
print("sample meth")
Expected JSON response
Following definition should be present at the root level of the JSON generated.
"securityDefinitions": {
"BasicAuth": {
"type": "basic"
}
}
Actual JSON response
Carries only the security requirement for the corresponding path, and the 'securityDefinitions' section is missing.
{
"definitions":{
"ErrorResponse":{
"example":{
"error":"Lab name is not provided."
},
"properties":{
"error":{
"description":"Gives a description about the error.",
"type":"string"
}
}
}
},
"paths":{
"/reports":{
"post":{
"security":[
{
"BasicAuth":[
]
}
],
"summary":"Uploads the given file to servers."
}
}
}
}
Current solution is to add it manually to the generated JSON object, like below:
from flask_swagger import swagger
@app.route("/spec")
def spec():
swag_doc = swagger(app)
swag_doc['securityDefinitions'] = {"BasicAuth": {"type": "basic"}}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels