【问题标题】:Connexion class based handling基于连接类的处理
【发布时间】:2017-02-19 10:08:43
【问题描述】:

我正在为烧瓶使用connexion 框架。我想将几个相关的函数分组到一个类中,我想知道一个类的方法是否可以用于 operationId 而不是函数。

类似

class Job:

    def get():
        "something"

    def post():
        "something"

在描述yaml文件中:

 paths:
    /hello:
        post:
            operationId: myapp.api.Job.post

【问题讨论】:

  • 请澄清您的问题。
  • 很清楚。
  • 在连接操作 id 被映射到处理请求的函数。我们可以在类中使用函数吗?

标签: python flask connexion


【解决方案1】:

如果这些方法可用作类上的静态方法,则可以使用它们:

class Job:

    @staticmethod
    def get():
        "something"

    @staticmethod
    def post():
        "something"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    相关资源
    最近更新 更多