Skip to content

Commit

Permalink
feat: remove unused imports from python clients; fix discriminator
Browse files Browse the repository at this point in the history
  • Loading branch information
tomplus committed May 18, 2018
1 parent c0f85df commit 3678eaf
Show file tree
Hide file tree
Showing 26 changed files with 19 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import pprint
import re # noqa: F401

import six
{{#imports}}{{#-first}}
{{/-first}}
{{import}} # noqa: F401,E501
{{/imports}}


{{#models}}
Expand Down Expand Up @@ -170,7 +166,7 @@ class {{classname}}(object):
{{#discriminator}}
def get_real_child_model(self, data):
"""Returns the real base class specified by the discriminator"""
discriminator_value = data[self.discriminator].lower()
discriminator_value = data[self.discriminator]
return self.discriminator_value_class_map.get(discriminator_value)

{{/discriminator}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def color(self, color):

def get_real_child_model(self, data):
"""Returns the real base class specified by the discriminator"""
discriminator_value = data[self.discriminator].lower()
discriminator_value = data[self.discriminator]
return self.discriminator_value_class_map.get(discriminator_value)

def to_dict(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class AnimalFarm(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.read_only_first import ReadOnlyFirst # noqa: F401,E501


class ArrayTest(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class Cat(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class Dog(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.outer_enum import OuterEnum # noqa: F401,E501


class EnumTest(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class MixedPropertiesAndAdditionalPropertiesClass(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

import six

from petstore_api.models.category import Category # noqa: F401,E501
from petstore_api.models.tag import Tag # noqa: F401,E501


class Pet(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def color(self, color):

def get_real_child_model(self, data):
"""Returns the real base class specified by the discriminator"""
discriminator_value = data[self.discriminator].lower()
discriminator_value = data[self.discriminator]
return self.discriminator_value_class_map.get(discriminator_value)

def to_dict(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class AnimalFarm(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.read_only_first import ReadOnlyFirst # noqa: F401,E501


class ArrayTest(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class Cat(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class Dog(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.outer_enum import OuterEnum # noqa: F401,E501


class EnumTest(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class MixedPropertiesAndAdditionalPropertiesClass(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

import six

from petstore_api.models.category import Category # noqa: F401,E501
from petstore_api.models.tag import Tag # noqa: F401,E501


class Pet(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def color(self, color):

def get_real_child_model(self, data):
"""Returns the real base class specified by the discriminator"""
discriminator_value = data[self.discriminator].lower()
discriminator_value = data[self.discriminator]
return self.discriminator_value_class_map.get(discriminator_value)

def to_dict(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class AnimalFarm(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.read_only_first import ReadOnlyFirst # noqa: F401,E501


class ArrayTest(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
2 changes: 0 additions & 2 deletions samples/client/petstore/python/petstore_api/models/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class Cat(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
2 changes: 0 additions & 2 deletions samples/client/petstore/python/petstore_api/models/dog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class Dog(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.outer_enum import OuterEnum # noqa: F401,E501


class EnumTest(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import six

from petstore_api.models.animal import Animal # noqa: F401,E501


class MixedPropertiesAndAdditionalPropertiesClass(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
3 changes: 0 additions & 3 deletions samples/client/petstore/python/petstore_api/models/pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

import six

from petstore_api.models.category import Category # noqa: F401,E501
from petstore_api.models.tag import Tag # noqa: F401,E501


class Pet(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand Down
15 changes: 15 additions & 0 deletions samples/client/petstore/python/tests/test_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ def test_deserialize_dict_str_pet(self):
self.assertTrue(isinstance(deserialized, dict))
self.assertTrue(isinstance(deserialized['pet'], petstore_api.Pet))

def test_deserialize_dict_str_dog(self):
""" deserialize dict(str, Dog), use discriminator"""
data = {
'dog': {
"id": 0,
"className": "Dog",
"color": "white",
"bread": "Jack Russel Terrier"
}
}

deserialized = self.deserialize(data, 'dict(str, Animal)')
self.assertTrue(isinstance(deserialized, dict))
self.assertTrue(isinstance(deserialized['dog'], petstore_api.Dog))

def test_deserialize_dict_str_int(self):
""" deserialize dict(str, int) """
data = {
Expand Down

0 comments on commit 3678eaf

Please sign in to comment.