Giter VIP home page Giter VIP logo

Comments (3)

mrname avatar mrname commented on June 18, 2024

IMO, your current solution seems like the most reasonable way to accomplish this. Defining the base securityDefinitions inside of your docstrings does not fully make sense, as they should only be defined once at the base and then referenced inside your docstrings.

In that case, some clarification/examples in the docs might help. If this is insufficient for your needs, can you elaborate more on how you would like to see this working?

from flask-swagger.

SandhyaGiri avatar SandhyaGiri commented on June 18, 2024

The current solution is perfectly fine for me. But what I had in my mind, was to extract these securityDefinitions from the docstrings of any method to the top level, just like what is currently being done for definitions. Do you think this makes sense?

from flask-swagger.

mrname avatar mrname commented on June 18, 2024

Thanks @SandhyaGiri this definitely makes sense. I think I'm just trying to reason about conflict resolution in the event that there are two different security definitions with the same name. For example:

@app.route('/reports', methods=["POST"])
def sample_meth():
       """
       docstring
        ---
        securityDefinitions:
          ApiKeyAuth:
            type: apikey
            in: header
            name: X-API-Key

and then another view:

@app.route('/reports', methods=["POST"])
def sample_meth():
       """
       docstring
        ---
        securityDefinitions:
          ApiKeyAuth:
            type: apikey
            in: header
            name: X-API-Key-Different-Header

In this case, which definition would we expect to see in securityDefinitions? More importantly, which one would be used for the view?

The thing I like about your solution is that there is one and only one way to define the security definitions.

It looks like definitions gets handled by requiring an ID, so we could consider doing something similar with securityDefinitions if we want to.

from flask-swagger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.