8

I'm using the connexion framework for flask. I'd like to group several related functions into a class and I'm wondering whether methods of a class can be used for operationId instead of functions.

Something like

class Job:

    def get():
        "something"

    def post():
        "something"

in the describing yaml file:

 paths:
    /hello:
        post:
            operationId: myapp.api.Job.post
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Akhil Batra
  • 581
  • 4
  • 16

1 Answers1

5

You can use the methods if they are available as staticmethods on the class:

class Job:

    @staticmethod
    def get():
        "something"

    @staticmethod
    def post():
        "something"
Sebastian Wozny
  • 16,943
  • 7
  • 52
  • 69