Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Support for "securityDefinitions" #54

@SandhyaGiri

Description

@SandhyaGiri

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"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions