github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/python/python-experimental/model_templates/method_discriminator.mustache (about)

     1      @classmethod
     2      def get_discriminator_class(cls, from_server, data):
     3          """Returns the child class specified by the discriminator"""
     4          discriminator = cls.discriminator()
     5          discr_propertyname_py = list(discriminator.keys())[0]
     6          discr_propertyname_js = cls.attribute_map[discr_propertyname_py]
     7          if from_server:
     8              class_name = data[discr_propertyname_js]
     9          else:
    10              class_name = data[discr_propertyname_py]
    11          class_name_to_discr_class = discriminator[discr_propertyname_py]
    12          return class_name_to_discr_class.get(class_name)