diff --git a/bin/openapi3/python-experimental-petstore.sh b/bin/openapi3/python-experimental-petstore.sh index 71cd902dee57..20d0595485c3 100755 --- a/bin/openapi3/python-experimental-petstore.sh +++ b/bin/openapi3/python-experimental-petstore.sh @@ -28,7 +28,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" #yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml" -yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml" +yaml="modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml" ags="generate -t modules/openapi-generator/src/main/resources/python -i $yaml -g python-experimental -o samples/openapi3/client/petstore/python-experimental/ --additional-properties packageName=petstore_api $@" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache index ef7da5728252..9afb17b52776 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache @@ -13,6 +13,9 @@ from {{packageName}}.model_utils import ( # noqa: F401 ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache index 8b49e58edbf2..fe54e34f5bb6 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache @@ -94,7 +94,7 @@ additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -113,7 +113,7 @@ {{/optionalVars}} } - @staticmethod + @cached_property def discriminator(): {{^discriminator}}return None{{/discriminator}}{{#discriminator}}val = { {{#mappedModels}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache index c4baa722ffb5..de06fb461ebc 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache @@ -1,10 +1,10 @@ @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache index e00bf129b247..a5d948f0dd8c 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache @@ -4,6 +4,7 @@ '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', @@ -16,6 +17,7 @@ '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { {{#requiredVars}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache index d26506c56c31..8433c49f2f6a 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache @@ -4,6 +4,7 @@ '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) {{> python-experimental/model_templates/method_init_shared }} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache index 9dd5bc2b6f3f..1631d57eec29 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache @@ -1,4 +1,5 @@ - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI {{#requiredVars}} @@ -31,6 +32,21 @@ deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) {{#optionalVars}} {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 {{/optionalVars}} @@ -40,4 +56,5 @@ self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item - self._configuration = _configuration \ No newline at end of file + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache index bcafb71368f1..f4a36e42f25b 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache @@ -6,9 +6,8 @@ path_to_item.extend(self._path_to_item) path_to_item.append(name) - openapi_types = self.openapi_types() - if name in openapi_types: - required_types_mixed = openapi_types[name] + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] elif self.additional_properties_type is None: raise ApiKeyError( "{0} has no key '{1}'".format(type(self).__name__, name), diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache index d53d89cef2be..002b2a578952 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache @@ -26,7 +26,7 @@ class {{unescapedDescription}}(ModelComposed): {{> python-experimental/model_templates/method_init_composed }} - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache index 8bfe6ada48d8..f9d82ef2a802 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache @@ -24,9 +24,7 @@ class {{unescapedDescription}}(ModelNormal): {{/optionalVars}} } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} {{> python-experimental/model_templates/method_init_normal}}{{#discriminator}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache index 465918dfa5c0..95b8a81715b2 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache @@ -11,8 +11,6 @@ class {{unescapedDescription}}(ModelSimple): {{> python-experimental/model_templates/classvars }} - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None {{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache index 58da408a19eb..e6b1df6b0e99 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -35,6 +35,24 @@ else: from builtins import int, str +class cached_property(object): + # this caches the result of the function call for fn with no inputs + # use this as a decorator on fuction methods that you want converted + # into cached properties + result_key = '_results' + + def __init__(self, fn): + self._fn = fn + + def __get__(self, instance, cls=None): + try: + return vars(self)[self.result_key] + except KeyError: + result = self._fn() + setattr(self, self.result_key, result) + return result + + class OpenApiModel(object): """The base class for all OpenAPIModels""" @@ -42,6 +60,55 @@ class OpenApiModel(object): {{> python-experimental/model_templates/methods_shared }} + def __new__(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # we don't have a discriminator + # or we have already visited this class before and are sure that we + # want to instantiate it this time + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_classes = [] + oneof_anyof_classes.extend(cls._composed_schemas.get('oneOf', ())) + oneof_anyof_classes.extend(cls._composed_schemas.get('anyOf', ())) + new_cls = cls.get_discriminator_class(kwargs) + if new_cls is None: + disc_prop_name_py = list(cls.discriminator.keys())[0] + disc_prop_name_js = cls.attribute_map[disc_prop_name_py] + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + disc_prop_name_js, kwargs.get(disc_prop_name_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (disc_prop_name_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are coming from the chosen new_cls use cls instead + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = super(OpenApiModel, cls).__new__(cls) + self_inst.__init__(*args, **kwargs) + + new_inst = new_cls.__new__(new_cls, *args, **kwargs) + new_inst.__init__(*args, **kwargs) + return new_inst + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their @@ -473,10 +540,12 @@ def change_keys_js_to_python(input_dict, model_class): document). """ + if getattr(model_class, 'attribute_map', None) is None: + return input_dict output_dict = {} reversed_attr_map = {value: key for key, value in - six.iteritems(model_class.attribute_map)} - for javascript_key, value in six.iteritems(input_dict): + model_class.attribute_map.items()} + for javascript_key, value in input_dict.items(): python_key = reversed_attr_map.get(javascript_key) if python_key is None: # if the key is unknown, it is in error or it is an @@ -553,21 +622,6 @@ def deserialize_primitive(data, klass, path_to_item): ) -def fix_model_input_data(model_data, model_class): - # this is only called on classes where the input data is a dict - fixed_model_data = change_keys_js_to_python( - model_data, - model_class - ) - if model_class._composed_schemas() is not None: - for allof_class in model_class._composed_schemas()['allOf']: - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - allof_class - ) - return fixed_model_data - - def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -596,23 +650,14 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, _configuration=configuration, _from_server=from_server) - used_model_class = model_class - if model_class.discriminator() is not None: - used_model_class = model_class.get_discriminator_class( - from_server, model_data) - - if issubclass(used_model_class, ModelSimple): - instance = used_model_class(value=model_data, **kw_args) + if issubclass(model_class, ModelSimple): + instance = model_class(value=model_data, **kw_args) return instance if isinstance(model_data, list): - instance = used_model_class(*model_data, **kw_args) + instance = model_class(*model_data, **kw_args) if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - model_data, - used_model_class - ) - kw_args.update(fixed_model_data) - instance = used_model_class(**kw_args) + kw_args.update(model_data) + instance = model_class(**kw_args) return instance @@ -833,7 +878,7 @@ def model_to_dict(model_instance, serialize=True): result = {} model_instances = [model_instance] - if model_instance._composed_schemas() is not None: + if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): @@ -914,6 +959,17 @@ def get_py3_class_name(input_class): return input_class.__name__ +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(self, *args, **kwargs): + from_server = kwargs.get('_from_server', False) + if from_server: + kwargs = change_keys_js_to_python(kwargs, self.__class__) + return fn(self, *args, **kwargs) + return wrapped_init + + def get_allof_instances(self, model_args, constant_args): """ Args: @@ -927,18 +983,17 @@ def get_allof_instances(self, model_args, constant_args): composed_instances (list) """ composed_instances = [] - for allof_class in self._composed_schemas()['allOf']: - - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_args, allof_class) + for allof_class in self._composed_schemas['allOf']: + # no need to handle changing js keys to python because + # for composed schemas, allof parameters are included in the + # composed schema and were changed to python keys in __new__ # extract a dict of only required keys from fixed_model_args kwargs = {} - var_names = set(allof_class.openapi_types().keys()) + var_names = set(allof_class.openapi_types.keys()) for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] + if var_name in model_args: + kwargs[var_name] = model_args[var_name] # and use it to make the instance kwargs.update(constant_args) @@ -950,8 +1005,8 @@ def get_allof_instances(self, model_args, constant_args): "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( - allof_class.__class__.__name__, - allof_class.__class__.__name__, + allof_class.__name__, + allof_class.__name__, self.__class__.__name__, str(ex) ) @@ -979,13 +1034,13 @@ def get_oneof_instance(self, model_args, constant_args): Returns oneof_instance (instance/None) """ - if len(self._composed_schemas()['oneOf']) == 0: + if len(self._composed_schemas['oneOf']) == 0: return None oneof_instances = [] # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. - for oneof_class in self._composed_schemas()['oneOf']: + for oneof_class in self._composed_schemas['oneOf']: # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) @@ -995,7 +1050,7 @@ def get_oneof_instance(self, model_args, constant_args): # additionalProperties attribute in the OAS document) are not added to # the dict. kwargs = {} - var_names = set(oneof_class.openapi_types().keys()) + var_names = set(oneof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1039,16 +1094,16 @@ def get_anyof_instances(self, model_args, constant_args): anyof_instances (list) """ anyof_instances = [] - if len(self._composed_schemas()['anyOf']) == 0: + if len(self._composed_schemas['anyOf']) == 0: return anyof_instances - for anyof_class in self._composed_schemas()['anyOf']: + for anyof_class in self._composed_schemas['anyOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python(model_args, anyof_class) # extract a dict of only required keys from these_model_vars kwargs = {} - var_names = set(anyof_class.openapi_types().keys()) + var_names = set(anyof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1089,7 +1144,7 @@ def get_var_name_to_model_instances(self, composed_instances): all_instances = [self] all_instances.extend(composed_instances) for instance in all_instances: - for var_name in instance.openapi_types(): + for var_name in instance.openapi_types: if var_name not in var_name_to_model_instances: var_name_to_model_instances[var_name] = [instance] else: @@ -1105,7 +1160,7 @@ def get_unused_args(self, composed_instances, model_args): if var_name_py in unused_args: del unused_args[var_name_py] for instance in composed_instances: - if instance.__class__ in self._composed_schemas()['allOf']: + if instance.__class__ in self._composed_schemas['allOf']: for var_name_py in instance.attribute_map: if var_name_py in unused_args: del unused_args[var_name_py] @@ -1125,9 +1180,7 @@ def validate_get_composed_info(constant_args, model_args, self): Openapi schemas are python classes. Exceptions are raised if: - - no oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data + - 0 or > 1 oneOf schema matches the model_args input data - no anyOf schema matches the model_args input data - any of the allOf schemas do not match the model_args input data @@ -1136,7 +1189,7 @@ def validate_get_composed_info(constant_args, model_args, self): model_args (dict): these are the required and optional spec args that were passed in to make this model self (class): the class that we are instantiating - This class contains self._composed_schemas() + This class contains self._composed_schemas Returns: composed_info (list): length three diff --git a/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml new file mode 100644 index 000000000000..066d7f295127 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -0,0 +1,1936 @@ +openapi: 3.0.0 +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '405': + description: Invalid input + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generated exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + responses: + '400': + description: Invalid request + '404': + description: Not found + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + enum_form_string: + description: Form parameter enum test (string) + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + integer: + description: None + type: integer + minimum: 10 + maximum: 100 + int32: + description: None + type: integer + format: int32 + minimum: 20 + maximum: 200 + int64: + description: None + type: integer + format: int64 + number: + description: None + type: number + minimum: 32.1 + maximum: 543.2 + float: + description: None + type: number + format: float + maximum: 987.6 + double: + description: None + type: number + format: double + minimum: 67.8 + maximum: 123.4 + string: + description: None + type: string + pattern: '/[a-z]/i' + pattern_without_delimiter: + description: None + type: string + pattern: '^[A-Z].*' + byte: + description: None + type: string + format: byte + binary: + description: None + type: string + format: binary + date: + description: None + type: string + format: date + dateTime: + description: None + type: string + format: date-time + password: + description: None + type: string + format: password + minLength: 10 + maxLength: 64 + callback: + description: None + type: string + required: + - number + - double + - pattern_without_delimiter + - byte + delete: + tags: + - fake + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + x-group-parameters: true + parameters: + - name: required_string_group + in: query + description: Required String in group parameters + required: true + schema: + type: integer + - name: required_boolean_group + in: header + description: Required Boolean in group parameters + required: true + schema: + type: boolean + - name: required_int64_group + in: query + description: Required Integer in group parameters + required: true + schema: + type: integer + format: int64 + - name: string_group + in: query + description: String in group parameters + schema: + type: integer + - name: boolean_group + in: header + description: Boolean in group parameters + schema: + type: boolean + - name: int64_group + in: query + description: Integer in group parameters + schema: + type: integer + format: int64 + responses: + '400': + description: Someting wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + responses: + '200': + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + responses: + '200': + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + responses: + '200': + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + responses: + '200': + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + responses: + '200': + description: successful operation + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: string + description: request body + required: true + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags and operation ID starting with number + operationId: '123_test_@#$%_special_tags' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + /fake/body-with-file-schema: + put: + tags: + - fake + description: >- + For this test, the body for this request much reference a schema named + `File`. + operationId: testBodyWithFileSchema + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + /fake/test-query-paramters: + put: + tags: + - fake + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - name: pipe + in: query + required: true + schema: + type: array + items: + type: string + - name: ioutil + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: http + in: query + required: true + style: spaceDelimited + schema: + type: array + items: + type: string + - name: url + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: context + in: query + required: true + explode: true + schema: + type: array + items: + type: string + responses: + "200": + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + type: string + format: binary + required: + - requiredFile + /fake/health: + get: + tags: + - fake + summary: Health check endpoint + responses: + 200: + description: The instance started successfully + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' +servers: + - url: 'http://{server}.swagger.io:{port}/v2' + description: petstore server + variables: + server: + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + - url: https://localhost:8080/{version} + description: The local server + variables: + version: + enum: + - 'v1' + - 'v2' + default: 'v2' +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + http_signature_test: + # Test the 'HTTP signature' security scheme. + # Each HTTP request is cryptographically signed as specified + # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ + type: http + scheme: signature + schemas: + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + arbitraryObject: + type: object + description: test code generation for objects + Value must be a map of strings to values. It cannot be the 'null' value. + arbitraryNullableObject: + type: object + description: test code generation for nullable objects. + Value must be a map of strings to values or the 'null' value. + nullable: true + arbitraryTypeValue: + description: test code generation for any type + Value can be any type - string, number, boolean, array or object. + arbitraryNullableTypeValue: + description: test code generation for any type + Value can be any type - string, number, boolean, array, object or + the 'null' value. + nullable: true + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Return: + description: Model for testing reserved words + properties: + return: + type: integer + format: int32 + xml: + name: Return + Name: + description: Model for testing model name same as property name + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + readOnly: true + type: integer + format: int32 + property: + type: string + 123Number: + type: integer + readOnly: true + xml: + name: Name + 200_response: + description: Model for testing model name starting with number + properties: + name: + type: integer + format: int32 + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - type: object + properties: + declawed: + type: boolean + Address: + type: object + additionalProperties: + type: integer + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + type: object + required: + - number + - byte + - date + - password + properties: + integer: + type: integer + maximum: 100 + minimum: 10 + int32: + type: integer + format: int32 + maximum: 200 + minimum: 20 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + type: number + format: float + maximum: 987.6 + minimum: 54.3 + double: + type: number + format: double + maximum: 123.4 + minimum: 67.8 + string: + type: string + pattern: '/[a-z]/i' + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + dateTime: + type: string + format: date-time + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + password: + type: string + format: password + maxLength: 64 + minLength: 10 + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + type: string + pattern: '^\d{10}$' + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + type: string + pattern: '/^image_\d{1,3}$/i' + EnumClass: + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + Enum_Test: + type: object + required: + - enum_string_required + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - '' + enum_string_required: + type: string + enum: + - UPPER + - lower + - '' + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + NumberOnly: + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + OuterEnum: + nullable: true + type: string + enum: + - placed + - approved + - delivered + OuterEnumInteger: + type: integer + enum: + - 0 + - 1 + - 2 + OuterEnumDefaultValue: + type: string + enum: + - placed + - approved + - delivered + default: placed + OuterEnumIntegerDefaultValue: + type: integer + enum: + - 0 + - 1 + - 2 + default: 0 + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + FileSchemaTestClass: + type: object + properties: + file: + $ref: '#/components/schemas/File' + files: + type: array + items: + $ref: '#/components/schemas/File' + File: + type: object + description: Must be named `File` for test. + properties: + sourceURI: + description: Test capitalization + type: string + _special_model.name_: + properties: + '$special[property.name]': + type: integer + format: int64 + xml: + name: '$special[model.name]' + HealthCheckResult: + type: object + properties: + NullableMessage: + nullable: true + type: string + description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + NullableClass: + type: object + properties: + integer_prop: + type: integer + nullable: true + number_prop: + type: number + nullable: true + boolean_prop: + type: boolean + nullable: true + string_prop: + type: string + nullable: true + date_prop: + type: string + format: date + nullable: true + datetime_prop: + type: string + format: date-time + nullable: true + array_nullable_prop: + type: array + nullable: true + items: + type: object + array_and_items_nullable_prop: + type: array + nullable: true + items: + type: object + nullable: true + array_items_nullable: + type: array + items: + type: object + nullable: true + object_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + object_and_items_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + object_items_nullable: + type: object + additionalProperties: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + fruit: + properties: + color: + type: string + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + apple: + type: object + properties: + cultivar: + type: string + banana: + type: object + properties: + lengthCm: + type: number + mammal: + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + discriminator: + propertyName: className + mapping: + whale: '#/components/schemas/whale' + zebra: '#/components/schemas/zebra' + whale: + type: object + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + zebra: + type: object + properties: + type: + type: string + enum: + - plains + - mountain + - grevys + className: + type: string + required: + - className + gmFruit: + properties: + color: + type: string + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + fruitReq: + oneOf: + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + appleReq: + type: object + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + bananaReq: + type: object + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + # go-experimental is unable to make Triangle and Quadrilateral models + # correctly https://github.com/OpenAPITools/openapi-generator/issues/6149 + Shape: + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + ShapeInterface: + properties: + shapeType: + type: string + required: + - shapeType + TriangleInterface: + properties: + triangleType: + type: string + required: + - triangleType + Triangle: + oneOf: + - $ref: '#/components/schemas/EquilateralTriangle' + - $ref: '#/components/schemas/IsoscelesTriangle' + - $ref: '#/components/schemas/ScaleneTriangle' + discriminator: + propertyName: triangleType + EquilateralTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + IsoscelesTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + ScaleneTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + QuadrilateralInterface: + properties: + quadrilateralType: + type: string + required: + - quadrilateralType + Quadrilateral: + oneOf: + - $ref: '#/components/schemas/SimpleQuadrilateral' + - $ref: '#/components/schemas/ComplexQuadrilateral' + discriminator: + propertyName: quadrilateralType + SimpleQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + ComplexQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py index b905f7d347a5..519b5f7a5ed5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -43,6 +43,24 @@ from builtins import int, str +class cached_property(object): + # this caches the result of the function call for fn with no inputs + # use this as a decorator on fuction methods that you want converted + # into cached properties + result_key = '_results' + + def __init__(self, fn): + self._fn = fn + + def __get__(self, instance, cls=None): + try: + return vars(self)[self.result_key] + except KeyError: + result = self._fn() + setattr(self, self.result_key, result) + return result + + class OpenApiModel(object): """The base class for all OpenAPIModels""" @@ -54,9 +72,8 @@ def set_attribute(self, name, value): path_to_item.extend(self._path_to_item) path_to_item.append(name) - openapi_types = self.openapi_types() - if name in openapi_types: - required_types_mixed = openapi_types[name] + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] elif self.additional_properties_type is None: raise ApiKeyError( "{0} has no key '{1}'".format(type(self).__name__, name), @@ -113,6 +130,55 @@ def __ne__(self, other): """Returns true if both objects are not equal""" return not self == other + def __new__(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # we don't have a discriminator + # or we have already visited this class before and are sure that we + # want to instantiate it this time + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_classes = [] + oneof_anyof_classes.extend(cls._composed_schemas.get('oneOf', ())) + oneof_anyof_classes.extend(cls._composed_schemas.get('anyOf', ())) + new_cls = cls.get_discriminator_class(kwargs) + if new_cls is None: + disc_prop_name_py = list(cls.discriminator.keys())[0] + disc_prop_name_js = cls.attribute_map[disc_prop_name_py] + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + disc_prop_name_js, kwargs.get(disc_prop_name_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (disc_prop_name_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are coming from the chosen new_cls use cls instead + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = super(OpenApiModel, cls).__new__(cls) + self_inst.__init__(*args, **kwargs) + + new_inst = new_cls.__new__(new_cls, *args, **kwargs) + new_inst.__init__(*args, **kwargs) + return new_inst + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their @@ -735,10 +801,12 @@ def change_keys_js_to_python(input_dict, model_class): document). """ + if getattr(model_class, 'attribute_map', None) is None: + return input_dict output_dict = {} reversed_attr_map = {value: key for key, value in - six.iteritems(model_class.attribute_map)} - for javascript_key, value in six.iteritems(input_dict): + model_class.attribute_map.items()} + for javascript_key, value in input_dict.items(): python_key = reversed_attr_map.get(javascript_key) if python_key is None: # if the key is unknown, it is in error or it is an @@ -815,21 +883,6 @@ def deserialize_primitive(data, klass, path_to_item): ) -def fix_model_input_data(model_data, model_class): - # this is only called on classes where the input data is a dict - fixed_model_data = change_keys_js_to_python( - model_data, - model_class - ) - if model_class._composed_schemas() is not None: - for allof_class in model_class._composed_schemas()['allOf']: - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - allof_class - ) - return fixed_model_data - - def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -858,23 +911,14 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, _configuration=configuration, _from_server=from_server) - used_model_class = model_class - if model_class.discriminator() is not None: - used_model_class = model_class.get_discriminator_class( - from_server, model_data) - - if issubclass(used_model_class, ModelSimple): - instance = used_model_class(value=model_data, **kw_args) + if issubclass(model_class, ModelSimple): + instance = model_class(value=model_data, **kw_args) return instance if isinstance(model_data, list): - instance = used_model_class(*model_data, **kw_args) + instance = model_class(*model_data, **kw_args) if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - model_data, - used_model_class - ) - kw_args.update(fixed_model_data) - instance = used_model_class(**kw_args) + kw_args.update(model_data) + instance = model_class(**kw_args) return instance @@ -1095,7 +1139,7 @@ def model_to_dict(model_instance, serialize=True): result = {} model_instances = [model_instance] - if model_instance._composed_schemas() is not None: + if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): @@ -1176,6 +1220,17 @@ def get_py3_class_name(input_class): return input_class.__name__ +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(self, *args, **kwargs): + from_server = kwargs.get('_from_server', False) + if from_server: + kwargs = change_keys_js_to_python(kwargs, self.__class__) + return fn(self, *args, **kwargs) + return wrapped_init + + def get_allof_instances(self, model_args, constant_args): """ Args: @@ -1189,18 +1244,17 @@ def get_allof_instances(self, model_args, constant_args): composed_instances (list) """ composed_instances = [] - for allof_class in self._composed_schemas()['allOf']: - - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_args, allof_class) + for allof_class in self._composed_schemas['allOf']: + # no need to handle changing js keys to python because + # for composed schemas, allof parameters are included in the + # composed schema and were changed to python keys in __new__ # extract a dict of only required keys from fixed_model_args kwargs = {} - var_names = set(allof_class.openapi_types().keys()) + var_names = set(allof_class.openapi_types.keys()) for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] + if var_name in model_args: + kwargs[var_name] = model_args[var_name] # and use it to make the instance kwargs.update(constant_args) @@ -1212,8 +1266,8 @@ def get_allof_instances(self, model_args, constant_args): "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( - allof_class.__class__.__name__, - allof_class.__class__.__name__, + allof_class.__name__, + allof_class.__name__, self.__class__.__name__, str(ex) ) @@ -1241,13 +1295,13 @@ def get_oneof_instance(self, model_args, constant_args): Returns oneof_instance (instance/None) """ - if len(self._composed_schemas()['oneOf']) == 0: + if len(self._composed_schemas['oneOf']) == 0: return None oneof_instances = [] # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. - for oneof_class in self._composed_schemas()['oneOf']: + for oneof_class in self._composed_schemas['oneOf']: # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) @@ -1257,7 +1311,7 @@ def get_oneof_instance(self, model_args, constant_args): # additionalProperties attribute in the OAS document) are not added to # the dict. kwargs = {} - var_names = set(oneof_class.openapi_types().keys()) + var_names = set(oneof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1301,16 +1355,16 @@ def get_anyof_instances(self, model_args, constant_args): anyof_instances (list) """ anyof_instances = [] - if len(self._composed_schemas()['anyOf']) == 0: + if len(self._composed_schemas['anyOf']) == 0: return anyof_instances - for anyof_class in self._composed_schemas()['anyOf']: + for anyof_class in self._composed_schemas['anyOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python(model_args, anyof_class) # extract a dict of only required keys from these_model_vars kwargs = {} - var_names = set(anyof_class.openapi_types().keys()) + var_names = set(anyof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1351,7 +1405,7 @@ def get_var_name_to_model_instances(self, composed_instances): all_instances = [self] all_instances.extend(composed_instances) for instance in all_instances: - for var_name in instance.openapi_types(): + for var_name in instance.openapi_types: if var_name not in var_name_to_model_instances: var_name_to_model_instances[var_name] = [instance] else: @@ -1367,7 +1421,7 @@ def get_unused_args(self, composed_instances, model_args): if var_name_py in unused_args: del unused_args[var_name_py] for instance in composed_instances: - if instance.__class__ in self._composed_schemas()['allOf']: + if instance.__class__ in self._composed_schemas['allOf']: for var_name_py in instance.attribute_map: if var_name_py in unused_args: del unused_args[var_name_py] @@ -1387,9 +1441,7 @@ def validate_get_composed_info(constant_args, model_args, self): Openapi schemas are python classes. Exceptions are raised if: - - no oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data + - 0 or > 1 oneOf schema matches the model_args input data - no anyOf schema matches the model_args input data - any of the allOf schemas do not match the model_args input data @@ -1398,7 +1450,7 @@ def validate_get_composed_info(constant_args, model_args, self): model_args (dict): these are the required and optional spec args that were passed in to make this model self (class): the class that we are instantiating - This class contains self._composed_schemas() + This class contains self._composed_schemas Returns: composed_info (list): length three diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py index d1a06123ea88..4fec91d87358 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesAnyType(ModelNormal): additional_properties_type = (bool, date, datetime, dict, float, int, list, str,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_any_type.AdditionalPropertiesAnyType - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py index bba4f0ed95f1..345d5c970c9c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesArray(ModelNormal): additional_properties_type = ([bool, date, datetime, dict, float, int, list, str],) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_array.AdditionalPropertiesArray - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py index de012c132c90..22b604b631f7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesBoolean(ModelNormal): additional_properties_type = (bool,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_boolean.AdditionalPropertiesBoolean - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py index c37e9b5c73bf..4ef564793dc0 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesClass(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -87,7 +90,7 @@ def openapi_types(): 'anytype_3': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -105,9 +108,7 @@ def discriminator(): 'anytype_3': 'anytype_3', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -115,9 +116,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_class.AdditionalPropertiesClass - a model defined in OpenAPI Keyword Args: @@ -134,6 +137,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) map_string ({str: (str,)}): [optional] # noqa: E501 map_number ({str: (float,)}): [optional] # noqa: E501 map_integer ({str: (int,)}): [optional] # noqa: E501 @@ -152,6 +170,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py index 649fbc485896..c309826f2e82 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesInteger(ModelNormal): additional_properties_type = (int,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_integer.AdditionalPropertiesInteger - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py index ce12662a8ed0..8bbd629023ea 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesNumber(ModelNormal): additional_properties_type = (float,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_number.AdditionalPropertiesNumber - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py index e5c60015a9e1..749e3ada66e5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesObject(ModelNormal): additional_properties_type = ({str: (bool, date, datetime, dict, float, int, list, str,)},) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_object.AdditionalPropertiesObject - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py index 24cef21ba90d..88fb6a5e15bc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesString(ModelNormal): additional_properties_type = (str,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_string.AdditionalPropertiesString - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/animal.py b/samples/client/petstore/python-experimental/petstore_api/models/animal.py index 39dd9789ff8b..34ae2ab23ef5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/animal.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/animal.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Animal(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'color': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { 'Cat': cat.Cat, @@ -103,9 +106,7 @@ def discriminator(): 'color': 'color', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -113,9 +114,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """animal.Animal - a model defined in OpenAPI Args: @@ -135,6 +138,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ @@ -143,6 +161,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): @@ -155,12 +174,12 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it setattr(self, var_name, var_value) @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/api_response.py b/samples/client/petstore/python-experimental/petstore_api/models/api_response.py index f1680c87f67a..aa85a8d32c8e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/api_response.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ApiResponse(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -79,7 +82,7 @@ def openapi_types(): 'message': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -89,9 +92,7 @@ def discriminator(): 'message': 'message', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -99,9 +100,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """api_response.ApiResponse - a model defined in OpenAPI Keyword Args: @@ -118,6 +121,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) code (int): [optional] # noqa: E501 type (str): [optional] # noqa: E501 message (str): [optional] # noqa: E501 @@ -128,6 +146,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py index bf6419e5c089..8648ca8e101e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ArrayOfArrayOfNumberOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'array_array_number': ([[float]],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'array_array_number': 'ArrayArrayNumber', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """array_of_array_of_number_only.ArrayOfArrayOfNumberOnly - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) array_array_number ([[float]]): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py index f3bf89e27ba3..b457b27a8cb5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ArrayOfNumberOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'array_number': ([float],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'array_number': 'ArrayNumber', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """array_of_number_only.ArrayOfNumberOnly - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) array_number ([float]): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_test.py b/samples/client/petstore/python-experimental/petstore_api/models/array_test.py index 0a01b3cad210..3733298e843c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class ArrayTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -84,7 +87,7 @@ def openapi_types(): 'array_array_of_model': ([[read_only_first.ReadOnlyFirst]],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -94,9 +97,7 @@ def discriminator(): 'array_array_of_model': 'array_array_of_model', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -104,9 +105,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """array_test.ArrayTest - a model defined in OpenAPI Keyword Args: @@ -123,6 +126,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) array_of_string ([str]): [optional] # noqa: E501 array_array_of_integer ([[int]]): [optional] # noqa: E501 array_array_of_model ([[read_only_first.ReadOnlyFirst]]): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py index 6011db39400c..3ca42fba60be 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Capitalization(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -82,7 +85,7 @@ def openapi_types(): 'att_name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -95,9 +98,7 @@ def discriminator(): 'att_name': 'ATT_NAME', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -105,9 +106,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """capitalization.Capitalization - a model defined in OpenAPI Keyword Args: @@ -124,6 +127,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) small_camel (str): [optional] # noqa: E501 capital_camel (str): [optional] # noqa: E501 small_snake (str): [optional] # noqa: E501 @@ -137,6 +155,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/cat.py b/samples/client/petstore/python-experimental/petstore_api/models/cat.py index 3f3c2384ec22..d2ce6b29c10a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Cat(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'color': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -109,12 +112,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """cat.Cat - a model defined in OpenAPI Args: @@ -134,6 +139,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ @@ -143,12 +163,14 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'class_name': class_name, @@ -179,7 +201,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -200,12 +222,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py index 75e856dcbcde..f008695b43ac 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class CatAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'declawed': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'declawed': 'declawed', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """cat_all_of.CatAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/category.py b/samples/client/petstore/python-experimental/petstore_api/models/category.py index 5d3e21ddd7e9..b34ba8ac0206 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/category.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/category.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Category(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'id': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'id': 'id', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name='default-name', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name='default-name', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """category.Category - a model defined in OpenAPI Args: @@ -119,6 +122,21 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child.py b/samples/client/petstore/python-experimental/petstore_api/models/child.py index 501c22427916..3587e28fdcb7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Child(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'inter_net': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -105,12 +108,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child.Child - a model defined in OpenAPI Keyword Args: @@ -127,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) radio_waves (bool): [optional] # noqa: E501 tele_vision (bool): [optional] # noqa: E501 inter_net (bool): [optional] # noqa: E501 @@ -137,12 +157,14 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { } @@ -172,7 +194,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py index 69f6b962f242..c416862240f8 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ChildAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'inter_net': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'inter_net': 'interNet', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_all_of.ChildAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) inter_net (bool): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py b/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py index e7894c9c7af4..4493cc514bb3 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class ChildCat(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -107,12 +110,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_cat.ChildCat - a model defined in OpenAPI Args: @@ -132,6 +137,21 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -140,12 +160,14 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'pet_type': pet_type, @@ -176,7 +198,7 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -197,12 +219,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py index dbe4e88bcebc..2f0cf1bdc607 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ChildCatAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_cat_all_of.ChildCatAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py b/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py index 8544773e8843..9df796705c99 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class ChildDog(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'bark': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -107,12 +110,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_dog.ChildDog - a model defined in OpenAPI Args: @@ -132,6 +137,21 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bark (str): [optional] # noqa: E501 """ @@ -140,12 +160,14 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'pet_type': pet_type, @@ -176,7 +198,7 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -197,12 +219,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py index f95f5ff8ae74..1ab97028ee48 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ChildDogAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'bark': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'bark': 'bark', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_dog_all_of.ChildDogAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bark (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py index 681e99ae6665..f42269372ea8 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class ChildLizard(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'loves_rocks': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -107,12 +110,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_lizard.ChildLizard - a model defined in OpenAPI Args: @@ -132,6 +137,21 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) loves_rocks (bool): [optional] # noqa: E501 """ @@ -140,12 +160,14 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'pet_type': pet_type, @@ -176,7 +198,7 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -197,12 +219,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py index 27686379a890..41bd842225fd 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ChildLizardAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'loves_rocks': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'loves_rocks': 'lovesRocks', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """child_lizard_all_of.ChildLizardAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) loves_rocks (bool): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/class_model.py b/samples/client/petstore/python-experimental/petstore_api/models/class_model.py index 06c52dc8bee9..a492a47164e7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/class_model.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ClassModel(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): '_class': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): '_class': '_class', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """class_model.ClassModel - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) _class (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/client.py b/samples/client/petstore/python-experimental/petstore_api/models/client.py index b7184b3f2b40..195e3d4209ca 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/client.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/client.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Client(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'client': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'client': 'client', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """client.Client - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) client (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/dog.py b/samples/client/petstore/python-experimental/petstore_api/models/dog.py index 5d5712d428e9..edf89695f8fa 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Dog(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'color': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -109,12 +112,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """dog.Dog - a model defined in OpenAPI Args: @@ -134,6 +139,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ @@ -143,12 +163,14 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'class_name': class_name, @@ -179,7 +201,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -200,12 +222,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py index 0832f4b696cc..6278289267d5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class DogAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'breed': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'breed': 'breed', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """dog_all_of.DogAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py index 358e9f680e76..107e1f3e0f8f 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -71,7 +74,7 @@ class EnumArrays(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -86,7 +89,7 @@ def openapi_types(): 'array_enum': ([str],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -95,9 +98,7 @@ def discriminator(): 'array_enum': 'array_enum', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -105,9 +106,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """enum_arrays.EnumArrays - a model defined in OpenAPI Keyword Args: @@ -124,6 +127,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) just_symbol (str): [optional] # noqa: E501 array_enum ([str]): [optional] # noqa: E501 """ @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py index 5f3f1894de47..4323ac7f0856 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -64,7 +67,7 @@ class EnumClass(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,13 +81,11 @@ def openapi_types(): 'value': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -92,9 +93,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """enum_class.EnumClass - a model defined in OpenAPI Args: @@ -114,6 +117,21 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -121,6 +139,7 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py index 4c35c7b8c2bb..160db49fd14c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -86,7 +89,7 @@ class EnumTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -104,7 +107,7 @@ def openapi_types(): 'outer_enum': (outer_enum.OuterEnum,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -116,9 +119,7 @@ def discriminator(): 'outer_enum': 'outerEnum', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -126,9 +127,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, enum_string_required, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, enum_string_required, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """enum_test.EnumTest - a model defined in OpenAPI Args: @@ -148,6 +151,21 @@ def __init__(self, enum_string_required, _check_type=True, _from_server=False, _ deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) enum_string (str): [optional] # noqa: E501 enum_integer (int): [optional] # noqa: E501 enum_number (float): [optional] # noqa: E501 @@ -159,6 +177,7 @@ def __init__(self, enum_string_required, _check_type=True, _from_server=False, _ self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.enum_string_required = enum_string_required for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/file.py b/samples/client/petstore/python-experimental/petstore_api/models/file.py index f71dc07b7ca8..0f21a84df498 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class File(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'source_uri': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'source_uri': 'sourceURI', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """file.File - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) source_uri (str): Test capitalization. [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py b/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py index 1260e8affda2..2715cfdbfd55 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class FileSchemaTestClass(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -83,7 +86,7 @@ def openapi_types(): 'files': ([file.File],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -92,9 +95,7 @@ def discriminator(): 'files': 'files', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -102,9 +103,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """file_schema_test_class.FileSchemaTestClass - a model defined in OpenAPI Keyword Args: @@ -121,6 +124,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) file (file.File): [optional] # noqa: E501 files ([file.File]): [optional] # noqa: E501 """ @@ -130,6 +148,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/format_test.py b/samples/client/petstore/python-experimental/petstore_api/models/format_test.py index 823c3cb88d91..b22bc0b30527 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/format_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/format_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -98,7 +101,7 @@ class FormatTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -124,7 +127,7 @@ def openapi_types(): 'uuid': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -144,9 +147,7 @@ def discriminator(): 'uuid': 'uuid', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -154,9 +155,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, number, byte, date, password, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, number, byte, date, password, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """format_test.FormatTest - a model defined in OpenAPI Args: @@ -179,6 +182,21 @@ def __init__(self, number, byte, date, password, _check_type=True, _from_server= deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) integer (int): [optional] # noqa: E501 int32 (int): [optional] # noqa: E501 int64 (int): [optional] # noqa: E501 @@ -195,6 +213,7 @@ def __init__(self, number, byte, date, password, _check_type=True, _from_server= self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.number = number self.byte = byte diff --git a/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py b/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py index 98d7934f472f..bb5188acaf02 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Grandparent(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'radio_waves': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'radio_waves': 'radioWaves', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """grandparent.Grandparent - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) radio_waves (bool): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py b/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py index db7e6f33887d..e87b751a0ee7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -83,7 +86,7 @@ class GrandparentAnimal(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -97,7 +100,7 @@ def openapi_types(): 'pet_type': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { 'ChildCat': child_cat.ChildCat, @@ -113,9 +116,7 @@ def discriminator(): 'pet_type': 'pet_type', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -123,9 +124,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """grandparent_animal.GrandparentAnimal - a model defined in OpenAPI Args: @@ -145,6 +148,21 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -152,6 +170,7 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.pet_type = pet_type for var_name, var_value in six.iteritems(kwargs): @@ -164,12 +183,12 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item setattr(self, var_name, var_value) @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py index c84cf0be3f2b..974136a56a6f 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class HasOnlyReadOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'foo': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'foo': 'foo', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """has_only_read_only.HasOnlyReadOnly - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bar (str): [optional] # noqa: E501 foo (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/list.py b/samples/client/petstore/python-experimental/petstore_api/models/list.py index c7c80e8bd28b..3f85acb2e4d3 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/list.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/list.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class List(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): '_123_list': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): '_123_list': '123-list', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """list.List - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) _123_list (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/map_test.py b/samples/client/petstore/python-experimental/petstore_api/models/map_test.py index 8cc47c0a6922..e3510cef772f 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/map_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/map_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -72,7 +75,7 @@ class MapTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'indirect_map': (string_boolean_map.StringBooleanMap,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -100,9 +103,7 @@ def discriminator(): 'indirect_map': 'indirect_map', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -110,9 +111,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """map_test.MapTest - a model defined in OpenAPI Keyword Args: @@ -129,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) map_map_of_string ({str: ({str: (str,)},)}): [optional] # noqa: E501 map_of_enum_string ({str: (str,)}): [optional] # noqa: E501 direct_map ({str: (bool,)}): [optional] # noqa: E501 @@ -140,6 +158,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py index 143a79bfa266..36f5add3db88 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -84,7 +87,7 @@ def openapi_types(): 'map': ({str: (animal.Animal,)},), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -94,9 +97,7 @@ def discriminator(): 'map': 'map', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -104,9 +105,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI Keyword Args: @@ -123,6 +126,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) uuid (str): [optional] # noqa: E501 date_time (datetime): [optional] # noqa: E501 map ({str: (animal.Animal,)}): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py b/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py index 0c3885120210..96d39402d563 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Model200Response(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): '_class': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): '_class': 'class', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """model200_response.Model200Response - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (int): [optional] # noqa: E501 _class (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/model_return.py b/samples/client/petstore/python-experimental/petstore_api/models/model_return.py index 75c3cea6318b..f9213c37ea7e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/model_return.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/model_return.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ModelReturn(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): '_return': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): '_return': 'return', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """model_return.ModelReturn - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) _return (int): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/name.py b/samples/client/petstore/python-experimental/petstore_api/models/name.py index db81ae16916d..b2fce89ec9b7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/name.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Name(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -80,7 +83,7 @@ def openapi_types(): '_123_number': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -91,9 +94,7 @@ def discriminator(): '_123_number': '123Number', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -101,9 +102,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """name.Name - a model defined in OpenAPI Args: @@ -123,6 +126,21 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) snake_case (int): [optional] # noqa: E501 _property (str): [optional] # noqa: E501 _123_number (int): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/number_only.py index 0c91e2ae62d0..896757360765 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/number_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class NumberOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'just_number': (float,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'just_number': 'JustNumber', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """number_only.NumberOnly - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) just_number (float): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/order.py b/samples/client/petstore/python-experimental/petstore_api/models/order.py index 673295a8610c..6ff62a572333 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/order.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/order.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class Order(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -87,7 +90,7 @@ def openapi_types(): 'complete': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -100,9 +103,7 @@ def discriminator(): 'complete': 'complete', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -110,9 +111,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """order.Order - a model defined in OpenAPI Keyword Args: @@ -129,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 pet_id (int): [optional] # noqa: E501 quantity (int): [optional] # noqa: E501 @@ -142,6 +160,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py index c654c51daffe..d34d654e0845 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class OuterComposite(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -84,7 +87,7 @@ def openapi_types(): 'my_boolean': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -94,9 +97,7 @@ def discriminator(): 'my_boolean': 'my_boolean', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -104,9 +105,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_composite.OuterComposite - a model defined in OpenAPI Keyword Args: @@ -123,6 +126,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) my_number (outer_number.OuterNumber): [optional] # noqa: E501 my_string (str): [optional] # noqa: E501 my_boolean (bool): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py index 9a933b28169b..e85ac1b87ebb 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -64,7 +67,7 @@ class OuterEnum(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,13 +81,11 @@ def openapi_types(): 'value': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -92,9 +93,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_enum.OuterEnum - a model defined in OpenAPI Args: @@ -114,6 +117,21 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -121,6 +139,7 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py index 9f7b3de76d91..df65a2d3d047 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class OuterNumber(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,13 +80,11 @@ def openapi_types(): 'value': (float,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -91,9 +92,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_number.OuterNumber - a model defined in OpenAPI Args: @@ -113,6 +116,21 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -120,6 +138,7 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent.py b/samples/client/petstore/python-experimental/petstore_api/models/parent.py index f62abd94ceed..16bb62ed0fbd 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/parent.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Parent(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'tele_vision': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -103,12 +106,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """parent.Parent - a model defined in OpenAPI Keyword Args: @@ -125,6 +130,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) radio_waves (bool): [optional] # noqa: E501 tele_vision (bool): [optional] # noqa: E501 """ @@ -134,12 +154,14 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { } @@ -169,7 +191,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py index f927649600bd..6ee6983a4abc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ParentAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'tele_vision': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'tele_vision': 'teleVision', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """parent_all_of.ParentAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) tele_vision (bool): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py b/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py index e7f2a6fb63f9..8d708aadf4fb 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -83,7 +86,7 @@ class ParentPet(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -97,7 +100,7 @@ def openapi_types(): 'pet_type': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { 'ChildCat': child_cat.ChildCat, @@ -118,12 +121,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """parent_pet.ParentPet - a model defined in OpenAPI Args: @@ -143,6 +148,21 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -150,12 +170,14 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'pet_type': pet_type, @@ -186,7 +208,7 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -206,12 +228,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/pet.py b/samples/client/petstore/python-experimental/petstore_api/models/pet.py index 74cd8afef1af..1b34db901312 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/pet.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/pet.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -78,7 +81,7 @@ class Pet(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -97,7 +100,7 @@ def openapi_types(): 'status': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -110,9 +113,7 @@ def discriminator(): 'status': 'status', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -120,9 +121,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """pet.Pet - a model defined in OpenAPI Args: @@ -143,6 +146,21 @@ def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 category (category.Category): [optional] # noqa: E501 tags ([tag.Tag]): [optional] # noqa: E501 @@ -154,6 +172,7 @@ def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name self.photo_urls = photo_urls diff --git a/samples/client/petstore/python-experimental/petstore_api/models/player.py b/samples/client/petstore/python-experimental/petstore_api/models/player.py index ea8d2a99456d..147bf2ff6f97 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/player.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/player.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Player(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'enemy_player': (Player,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'enemy_player': 'enemyPlayer', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """player.Player - a model defined in OpenAPI Args: @@ -119,6 +122,21 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) enemy_player (Player): [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py b/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py index 329ec017d435..8c6d80c71f16 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ReadOnlyFirst(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'baz': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'baz': 'baz', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """read_only_first.ReadOnlyFirst - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bar (str): [optional] # noqa: E501 baz (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py b/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py index d4ffc608a579..168554fa343e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class SpecialModelName(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'special_property_name': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'special_property_name': '$special[property.name]', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """special_model_name.SpecialModelName - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) special_property_name (int): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py index 7f797f5f1b5d..10d0a9882261 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class StringBooleanMap(ModelNormal): additional_properties_type = (bool,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -76,16 +79,14 @@ def openapi_types(): return { } - @staticmethod + @cached_property def discriminator(): return None attribute_map = { } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -93,9 +94,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """string_boolean_map.StringBooleanMap - a model defined in OpenAPI Keyword Args: @@ -112,6 +115,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -119,6 +137,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/tag.py b/samples/client/petstore/python-experimental/petstore_api/models/tag.py index 9af85413b39d..fdd4ff690009 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/tag.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/tag.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Tag(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -79,7 +82,7 @@ def openapi_types(): 'full_name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -89,9 +92,7 @@ def discriminator(): 'full_name': 'fullName', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -99,9 +100,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """tag.Tag - a model defined in OpenAPI Keyword Args: @@ -118,6 +121,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 name (str): [optional] # noqa: E501 full_name (str): [optional] # noqa: E501 @@ -128,6 +146,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py index acde27d37ab4..442f9837881b 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class TypeHolderDefault(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -83,7 +86,7 @@ def openapi_types(): 'datetime_item': (datetime,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -97,9 +100,7 @@ def discriminator(): 'datetime_item': 'datetime_item', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -107,9 +108,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, array_item, string_item='what', number_item=1.234, integer_item=-2, bool_item=True, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, array_item, string_item='what', number_item=1.234, integer_item=-2, bool_item=True, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """type_holder_default.TypeHolderDefault - a model defined in OpenAPI Args: @@ -133,6 +136,21 @@ def __init__(self, array_item, string_item='what', number_item=1.234, integer_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) date_item (date): [optional] # noqa: E501 datetime_item (datetime): [optional] # noqa: E501 """ @@ -142,6 +160,7 @@ def __init__(self, array_item, string_item='what', number_item=1.234, integer_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.string_item = string_item self.number_item = number_item diff --git a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py index dc8b5116da09..0c08758bf04a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -72,7 +75,7 @@ class TypeHolderExample(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -90,7 +93,7 @@ def openapi_types(): 'array_item': ([int],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -102,9 +105,7 @@ def discriminator(): 'array_item': 'array_item', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -112,9 +113,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, integer_item=-2, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, integer_item=-2, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """type_holder_example.TypeHolderExample - a model defined in OpenAPI Args: @@ -138,6 +141,21 @@ def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -145,6 +163,7 @@ def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.string_item = string_item self.number_item = number_item diff --git a/samples/client/petstore/python-experimental/petstore_api/models/user.py b/samples/client/petstore/python-experimental/petstore_api/models/user.py index 3b2eeb54b3d9..1f1095d3773c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/user.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/user.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class User(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -84,7 +87,7 @@ def openapi_types(): 'user_status': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -99,9 +102,7 @@ def discriminator(): 'user_status': 'userStatus', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -109,9 +110,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """user.User - a model defined in OpenAPI Keyword Args: @@ -128,6 +131,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 username (str): [optional] # noqa: E501 first_name (str): [optional] # noqa: E501 @@ -143,6 +161,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py b/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py index 3bcd62804dda..aad4db483aa4 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class XmlItem(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -105,7 +108,7 @@ def openapi_types(): 'prefix_ns_wrapped_array': ([int],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -141,9 +144,7 @@ def discriminator(): 'prefix_ns_wrapped_array': 'prefix_ns_wrapped_array', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -151,9 +152,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """xml_item.XmlItem - a model defined in OpenAPI Keyword Args: @@ -170,6 +173,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) attribute_string (str): [optional] # noqa: E501 attribute_number (float): [optional] # noqa: E501 attribute_integer (int): [optional] # noqa: E501 @@ -206,6 +224,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/client/petstore/python-experimental/test/test_child.py b/samples/client/petstore/python-experimental/test/test_child.py index 96023582c4fd..43f1341b9233 100644 --- a/samples/client/petstore/python-experimental/test/test_child.py +++ b/samples/client/petstore/python-experimental/test/test_child.py @@ -81,7 +81,7 @@ def testChild(self): # make sure that the ModelComposed class properties are correct # model.composed_schemas() stores the anyOf/allOf/oneOf info self.assertEqual( - child._composed_schemas(), + child._composed_schemas, { 'anyOf': [], 'allOf': [ diff --git a/samples/client/petstore/python-experimental/test/test_dog.py b/samples/client/petstore/python-experimental/test/test_dog.py index cb1f3230a067..cc165d8b27df 100644 --- a/samples/client/petstore/python-experimental/test/test_dog.py +++ b/samples/client/petstore/python-experimental/test/test_dog.py @@ -81,7 +81,7 @@ def testDog(self): # make sure that the ModelComposed class properties are correct # model.composed_schemas() stores the anyOf/allOf/oneOf info self.assertEqual( - dog._composed_schemas(), + dog._composed_schemas, { 'anyOf': [], 'allOf': [ diff --git a/samples/openapi3/client/petstore/python-experimental/README.md b/samples/openapi3/client/petstore/python-experimental/README.md index b2158bd96594..75c709986b76 100644 --- a/samples/openapi3/client/petstore/python-experimental/README.md +++ b/samples/openapi3/client/petstore/python-experimental/README.md @@ -139,11 +139,13 @@ Class | Method | HTTP request | Description - [category.Category](docs/Category.md) - [class_model.ClassModel](docs/ClassModel.md) - [client.Client](docs/Client.md) + - [complex_quadrilateral.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [dog.Dog](docs/Dog.md) - [dog_all_of.DogAllOf](docs/DogAllOf.md) - [enum_arrays.EnumArrays](docs/EnumArrays.md) - [enum_class.EnumClass](docs/EnumClass.md) - [enum_test.EnumTest](docs/EnumTest.md) + - [equilateral_triangle.EquilateralTriangle](docs/EquilateralTriangle.md) - [file.File](docs/File.md) - [file_schema_test_class.FileSchemaTestClass](docs/FileSchemaTestClass.md) - [foo.Foo](docs/Foo.md) @@ -160,6 +162,7 @@ Class | Method | HTTP request | Description - [inline_object4.InlineObject4](docs/InlineObject4.md) - [inline_object5.InlineObject5](docs/InlineObject5.md) - [inline_response_default.InlineResponseDefault](docs/InlineResponseDefault.md) + - [isosceles_triangle.IsoscelesTriangle](docs/IsoscelesTriangle.md) - [list.List](docs/List.md) - [mammal.Mammal](docs/Mammal.md) - [map_test.MapTest](docs/MapTest.md) @@ -176,10 +179,18 @@ Class | Method | HTTP request | Description - [outer_enum_integer.OuterEnumInteger](docs/OuterEnumInteger.md) - [outer_enum_integer_default_value.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [pet.Pet](docs/Pet.md) + - [quadrilateral.Quadrilateral](docs/Quadrilateral.md) + - [quadrilateral_interface.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [read_only_first.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [scalene_triangle.ScaleneTriangle](docs/ScaleneTriangle.md) + - [shape.Shape](docs/Shape.md) + - [shape_interface.ShapeInterface](docs/ShapeInterface.md) + - [simple_quadrilateral.SimpleQuadrilateral](docs/SimpleQuadrilateral.md) - [special_model_name.SpecialModelName](docs/SpecialModelName.md) - [string_boolean_map.StringBooleanMap](docs/StringBooleanMap.md) - [tag.Tag](docs/Tag.md) + - [triangle.Triangle](docs/Triangle.md) + - [triangle_interface.TriangleInterface](docs/TriangleInterface.md) - [user.User](docs/User.md) - [whale.Whale](docs/Whale.md) - [zebra.Zebra](docs/Zebra.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/ComplexQuadrilateral.md b/samples/openapi3/client/petstore/python-experimental/docs/ComplexQuadrilateral.md new file mode 100644 index 000000000000..6a7288abcb8e --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/ComplexQuadrilateral.md @@ -0,0 +1,11 @@ +# complex_quadrilateral.ComplexQuadrilateral + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | +**quadrilateral_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/EquilateralTriangle.md b/samples/openapi3/client/petstore/python-experimental/docs/EquilateralTriangle.md new file mode 100644 index 000000000000..46c822e9db42 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/EquilateralTriangle.md @@ -0,0 +1,11 @@ +# equilateral_triangle.EquilateralTriangle + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | +**triangle_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/IsoscelesTriangle.md b/samples/openapi3/client/petstore/python-experimental/docs/IsoscelesTriangle.md new file mode 100644 index 000000000000..335edad8c0fe --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/IsoscelesTriangle.md @@ -0,0 +1,11 @@ +# isosceles_triangle.IsoscelesTriangle + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | +**triangle_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Quadrilateral.md b/samples/openapi3/client/petstore/python-experimental/docs/Quadrilateral.md new file mode 100644 index 000000000000..bc43f1e9351c --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Quadrilateral.md @@ -0,0 +1,11 @@ +# quadrilateral.Quadrilateral + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**quadrilateral_type** | **str** | | +**shape_type** | **str** | | defaults to nulltype.Null + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/QuadrilateralInterface.md b/samples/openapi3/client/petstore/python-experimental/docs/QuadrilateralInterface.md new file mode 100644 index 000000000000..d3600c6c5ba7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/QuadrilateralInterface.md @@ -0,0 +1,10 @@ +# quadrilateral_interface.QuadrilateralInterface + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**quadrilateral_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/ScaleneTriangle.md b/samples/openapi3/client/petstore/python-experimental/docs/ScaleneTriangle.md new file mode 100644 index 000000000000..a99a1f761c2f --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/ScaleneTriangle.md @@ -0,0 +1,11 @@ +# scalene_triangle.ScaleneTriangle + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | +**triangle_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Shape.md b/samples/openapi3/client/petstore/python-experimental/docs/Shape.md new file mode 100644 index 000000000000..6fbc1b6d2c70 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Shape.md @@ -0,0 +1,12 @@ +# shape.Shape + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | +**quadrilateral_type** | **str** | | defaults to nulltype.Null +**triangle_type** | **str** | | defaults to nulltype.Null + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/ShapeInterface.md b/samples/openapi3/client/petstore/python-experimental/docs/ShapeInterface.md new file mode 100644 index 000000000000..adb207397a49 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/ShapeInterface.md @@ -0,0 +1,10 @@ +# shape_interface.ShapeInterface + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/SimpleQuadrilateral.md b/samples/openapi3/client/petstore/python-experimental/docs/SimpleQuadrilateral.md new file mode 100644 index 000000000000..fe93f4173476 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/SimpleQuadrilateral.md @@ -0,0 +1,11 @@ +# simple_quadrilateral.SimpleQuadrilateral + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shape_type** | **str** | | +**quadrilateral_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Triangle.md b/samples/openapi3/client/petstore/python-experimental/docs/Triangle.md new file mode 100644 index 000000000000..b6cf81066821 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Triangle.md @@ -0,0 +1,11 @@ +# triangle.Triangle + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**triangle_type** | **str** | | +**shape_type** | **str** | | defaults to nulltype.Null + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/TriangleInterface.md b/samples/openapi3/client/petstore/python-experimental/docs/TriangleInterface.md new file mode 100644 index 000000000000..7a32b8572145 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/TriangleInterface.md @@ -0,0 +1,10 @@ +# triangle_interface.TriangleInterface + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**triangle_type** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py index 3aa279dd15d6..8b55c4a48b2a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py @@ -57,11 +57,13 @@ from petstore_api.models.category import Category from petstore_api.models.class_model import ClassModel from petstore_api.models.client import Client +from petstore_api.models.complex_quadrilateral import ComplexQuadrilateral from petstore_api.models.dog import Dog from petstore_api.models.dog_all_of import DogAllOf from petstore_api.models.enum_arrays import EnumArrays from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_test import EnumTest +from petstore_api.models.equilateral_triangle import EquilateralTriangle from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.foo import Foo @@ -78,6 +80,7 @@ from petstore_api.models.inline_object4 import InlineObject4 from petstore_api.models.inline_object5 import InlineObject5 from petstore_api.models.inline_response_default import InlineResponseDefault +from petstore_api.models.isosceles_triangle import IsoscelesTriangle from petstore_api.models.list import List from petstore_api.models.mammal import Mammal from petstore_api.models.map_test import MapTest @@ -94,10 +97,18 @@ from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue from petstore_api.models.pet import Pet +from petstore_api.models.quadrilateral import Quadrilateral +from petstore_api.models.quadrilateral_interface import QuadrilateralInterface from petstore_api.models.read_only_first import ReadOnlyFirst +from petstore_api.models.scalene_triangle import ScaleneTriangle +from petstore_api.models.shape import Shape +from petstore_api.models.shape_interface import ShapeInterface +from petstore_api.models.simple_quadrilateral import SimpleQuadrilateral from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.string_boolean_map import StringBooleanMap from petstore_api.models.tag import Tag +from petstore_api.models.triangle import Triangle +from petstore_api.models.triangle_interface import TriangleInterface from petstore_api.models.user import User from petstore_api.models.whale import Whale from petstore_api.models.zebra import Zebra diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py index b905f7d347a5..519b5f7a5ed5 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py @@ -43,6 +43,24 @@ from builtins import int, str +class cached_property(object): + # this caches the result of the function call for fn with no inputs + # use this as a decorator on fuction methods that you want converted + # into cached properties + result_key = '_results' + + def __init__(self, fn): + self._fn = fn + + def __get__(self, instance, cls=None): + try: + return vars(self)[self.result_key] + except KeyError: + result = self._fn() + setattr(self, self.result_key, result) + return result + + class OpenApiModel(object): """The base class for all OpenAPIModels""" @@ -54,9 +72,8 @@ def set_attribute(self, name, value): path_to_item.extend(self._path_to_item) path_to_item.append(name) - openapi_types = self.openapi_types() - if name in openapi_types: - required_types_mixed = openapi_types[name] + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] elif self.additional_properties_type is None: raise ApiKeyError( "{0} has no key '{1}'".format(type(self).__name__, name), @@ -113,6 +130,55 @@ def __ne__(self, other): """Returns true if both objects are not equal""" return not self == other + def __new__(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # we don't have a discriminator + # or we have already visited this class before and are sure that we + # want to instantiate it this time + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_classes = [] + oneof_anyof_classes.extend(cls._composed_schemas.get('oneOf', ())) + oneof_anyof_classes.extend(cls._composed_schemas.get('anyOf', ())) + new_cls = cls.get_discriminator_class(kwargs) + if new_cls is None: + disc_prop_name_py = list(cls.discriminator.keys())[0] + disc_prop_name_js = cls.attribute_map[disc_prop_name_py] + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + disc_prop_name_js, kwargs.get(disc_prop_name_py)) + raise ApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (disc_prop_name_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are coming from the chosen new_cls use cls instead + return super(OpenApiModel, cls).__new__(cls) + + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = super(OpenApiModel, cls).__new__(cls) + self_inst.__init__(*args, **kwargs) + + new_inst = new_cls.__new__(new_cls, *args, **kwargs) + new_inst.__init__(*args, **kwargs) + return new_inst + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their @@ -735,10 +801,12 @@ def change_keys_js_to_python(input_dict, model_class): document). """ + if getattr(model_class, 'attribute_map', None) is None: + return input_dict output_dict = {} reversed_attr_map = {value: key for key, value in - six.iteritems(model_class.attribute_map)} - for javascript_key, value in six.iteritems(input_dict): + model_class.attribute_map.items()} + for javascript_key, value in input_dict.items(): python_key = reversed_attr_map.get(javascript_key) if python_key is None: # if the key is unknown, it is in error or it is an @@ -815,21 +883,6 @@ def deserialize_primitive(data, klass, path_to_item): ) -def fix_model_input_data(model_data, model_class): - # this is only called on classes where the input data is a dict - fixed_model_data = change_keys_js_to_python( - model_data, - model_class - ) - if model_class._composed_schemas() is not None: - for allof_class in model_class._composed_schemas()['allOf']: - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - allof_class - ) - return fixed_model_data - - def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -858,23 +911,14 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, _configuration=configuration, _from_server=from_server) - used_model_class = model_class - if model_class.discriminator() is not None: - used_model_class = model_class.get_discriminator_class( - from_server, model_data) - - if issubclass(used_model_class, ModelSimple): - instance = used_model_class(value=model_data, **kw_args) + if issubclass(model_class, ModelSimple): + instance = model_class(value=model_data, **kw_args) return instance if isinstance(model_data, list): - instance = used_model_class(*model_data, **kw_args) + instance = model_class(*model_data, **kw_args) if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - model_data, - used_model_class - ) - kw_args.update(fixed_model_data) - instance = used_model_class(**kw_args) + kw_args.update(model_data) + instance = model_class(**kw_args) return instance @@ -1095,7 +1139,7 @@ def model_to_dict(model_instance, serialize=True): result = {} model_instances = [model_instance] - if model_instance._composed_schemas() is not None: + if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): @@ -1176,6 +1220,17 @@ def get_py3_class_name(input_class): return input_class.__name__ +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(self, *args, **kwargs): + from_server = kwargs.get('_from_server', False) + if from_server: + kwargs = change_keys_js_to_python(kwargs, self.__class__) + return fn(self, *args, **kwargs) + return wrapped_init + + def get_allof_instances(self, model_args, constant_args): """ Args: @@ -1189,18 +1244,17 @@ def get_allof_instances(self, model_args, constant_args): composed_instances (list) """ composed_instances = [] - for allof_class in self._composed_schemas()['allOf']: - - # transform js keys to python keys in fixed_model_args - fixed_model_args = change_keys_js_to_python( - model_args, allof_class) + for allof_class in self._composed_schemas['allOf']: + # no need to handle changing js keys to python because + # for composed schemas, allof parameters are included in the + # composed schema and were changed to python keys in __new__ # extract a dict of only required keys from fixed_model_args kwargs = {} - var_names = set(allof_class.openapi_types().keys()) + var_names = set(allof_class.openapi_types.keys()) for var_name in var_names: - if var_name in fixed_model_args: - kwargs[var_name] = fixed_model_args[var_name] + if var_name in model_args: + kwargs[var_name] = model_args[var_name] # and use it to make the instance kwargs.update(constant_args) @@ -1212,8 +1266,8 @@ def get_allof_instances(self, model_args, constant_args): "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( - allof_class.__class__.__name__, - allof_class.__class__.__name__, + allof_class.__name__, + allof_class.__name__, self.__class__.__name__, str(ex) ) @@ -1241,13 +1295,13 @@ def get_oneof_instance(self, model_args, constant_args): Returns oneof_instance (instance/None) """ - if len(self._composed_schemas()['oneOf']) == 0: + if len(self._composed_schemas['oneOf']) == 0: return None oneof_instances = [] # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. - for oneof_class in self._composed_schemas()['oneOf']: + for oneof_class in self._composed_schemas['oneOf']: # transform js keys from input data to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( model_args, oneof_class) @@ -1257,7 +1311,7 @@ def get_oneof_instance(self, model_args, constant_args): # additionalProperties attribute in the OAS document) are not added to # the dict. kwargs = {} - var_names = set(oneof_class.openapi_types().keys()) + var_names = set(oneof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1301,16 +1355,16 @@ def get_anyof_instances(self, model_args, constant_args): anyof_instances (list) """ anyof_instances = [] - if len(self._composed_schemas()['anyOf']) == 0: + if len(self._composed_schemas['anyOf']) == 0: return anyof_instances - for anyof_class in self._composed_schemas()['anyOf']: + for anyof_class in self._composed_schemas['anyOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python(model_args, anyof_class) # extract a dict of only required keys from these_model_vars kwargs = {} - var_names = set(anyof_class.openapi_types().keys()) + var_names = set(anyof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] @@ -1351,7 +1405,7 @@ def get_var_name_to_model_instances(self, composed_instances): all_instances = [self] all_instances.extend(composed_instances) for instance in all_instances: - for var_name in instance.openapi_types(): + for var_name in instance.openapi_types: if var_name not in var_name_to_model_instances: var_name_to_model_instances[var_name] = [instance] else: @@ -1367,7 +1421,7 @@ def get_unused_args(self, composed_instances, model_args): if var_name_py in unused_args: del unused_args[var_name_py] for instance in composed_instances: - if instance.__class__ in self._composed_schemas()['allOf']: + if instance.__class__ in self._composed_schemas['allOf']: for var_name_py in instance.attribute_map: if var_name_py in unused_args: del unused_args[var_name_py] @@ -1387,9 +1441,7 @@ def validate_get_composed_info(constant_args, model_args, self): Openapi schemas are python classes. Exceptions are raised if: - - no oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data - - > 1 oneOf schema matches the model_args input data + - 0 or > 1 oneOf schema matches the model_args input data - no anyOf schema matches the model_args input data - any of the allOf schemas do not match the model_args input data @@ -1398,7 +1450,7 @@ def validate_get_composed_info(constant_args, model_args, self): model_args (dict): these are the required and optional spec args that were passed in to make this model self (class): the class that we are instantiating - This class contains self._composed_schemas() + This class contains self._composed_schemas Returns: composed_info (list): length three diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py index 30bc3cdce6f3..0dc65073d31e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AdditionalPropertiesClass(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'map_of_map_property': ({str: ({str: (str,)},)},), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'map_of_map_property': 'map_of_map_property', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """additional_properties_class.AdditionalPropertiesClass - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) map_property ({str: (str,)}): [optional] # noqa: E501 map_of_map_property ({str: ({str: (str,)},)}): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py index 05a95d57fa99..a8a541d6c21c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Address(ModelNormal): additional_properties_type = (int,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -76,16 +79,14 @@ def openapi_types(): return { } - @staticmethod + @cached_property def discriminator(): return None attribute_map = { } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -93,9 +94,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """address.Address - a model defined in OpenAPI Keyword Args: @@ -112,6 +115,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -119,6 +137,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py index 39dd9789ff8b..34ae2ab23ef5 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Animal(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'color': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { 'Cat': cat.Cat, @@ -103,9 +106,7 @@ def discriminator(): 'color': 'color', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -113,9 +114,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """animal.Animal - a model defined in OpenAPI Args: @@ -135,6 +138,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ @@ -143,6 +161,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): @@ -155,12 +174,12 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it setattr(self, var_name, var_value) @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py index f1680c87f67a..aa85a8d32c8e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ApiResponse(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -79,7 +82,7 @@ def openapi_types(): 'message': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -89,9 +92,7 @@ def discriminator(): 'message': 'message', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -99,9 +100,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """api_response.ApiResponse - a model defined in OpenAPI Keyword Args: @@ -118,6 +121,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) code (int): [optional] # noqa: E501 type (str): [optional] # noqa: E501 message (str): [optional] # noqa: E501 @@ -128,6 +146,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py index 03c502690d5d..cf86835a3295 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Apple(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'cultivar': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'cultivar': 'cultivar', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """apple.Apple - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) cultivar (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py index 7aa81bf4c776..e0209f490b43 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class AppleReq(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'mealy': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'mealy': 'mealy', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, cultivar, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, cultivar, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """apple_req.AppleReq - a model defined in OpenAPI Args: @@ -119,6 +122,21 @@ def __init__(self, cultivar, _check_type=True, _from_server=False, _path_to_item deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) mealy (bool): [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, cultivar, _check_type=True, _from_server=False, _path_to_item self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.cultivar = cultivar for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py index bf6419e5c089..8648ca8e101e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ArrayOfArrayOfNumberOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'array_array_number': ([[float]],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'array_array_number': 'ArrayArrayNumber', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """array_of_array_of_number_only.ArrayOfArrayOfNumberOnly - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) array_array_number ([[float]]): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py index f3bf89e27ba3..b457b27a8cb5 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ArrayOfNumberOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'array_number': ([float],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'array_number': 'ArrayNumber', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """array_of_number_only.ArrayOfNumberOnly - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) array_number ([float]): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py index 0a01b3cad210..3733298e843c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class ArrayTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -84,7 +87,7 @@ def openapi_types(): 'array_array_of_model': ([[read_only_first.ReadOnlyFirst]],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -94,9 +97,7 @@ def discriminator(): 'array_array_of_model': 'array_array_of_model', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -104,9 +105,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """array_test.ArrayTest - a model defined in OpenAPI Keyword Args: @@ -123,6 +126,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) array_of_string ([str]): [optional] # noqa: E501 array_array_of_integer ([[int]]): [optional] # noqa: E501 array_array_of_model ([[read_only_first.ReadOnlyFirst]]): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py index fda69a28a253..ea8e0969a483 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Banana(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'length_cm': (float,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'length_cm': 'lengthCm', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """banana.Banana - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) length_cm (float): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py index bf7d461c469c..180a51d33a62 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class BananaReq(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'sweet': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'sweet': 'sweet', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, length_cm, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, length_cm, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """banana_req.BananaReq - a model defined in OpenAPI Args: @@ -119,6 +122,21 @@ def __init__(self, length_cm, _check_type=True, _from_server=False, _path_to_ite deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) sweet (bool): [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, length_cm, _check_type=True, _from_server=False, _path_to_ite self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.length_cm = length_cm for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py index 6011db39400c..3ca42fba60be 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Capitalization(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -82,7 +85,7 @@ def openapi_types(): 'att_name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -95,9 +98,7 @@ def discriminator(): 'att_name': 'ATT_NAME', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -105,9 +106,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """capitalization.Capitalization - a model defined in OpenAPI Keyword Args: @@ -124,6 +127,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) small_camel (str): [optional] # noqa: E501 capital_camel (str): [optional] # noqa: E501 small_snake (str): [optional] # noqa: E501 @@ -137,6 +155,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py index c3641a6862b9..a99db498e685 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -78,7 +81,7 @@ class Cat(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -94,7 +97,7 @@ def openapi_types(): 'color': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -114,12 +117,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """cat.Cat - a model defined in OpenAPI Args: @@ -139,6 +144,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ @@ -148,12 +168,14 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'class_name': class_name, @@ -184,7 +206,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -206,12 +228,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py index 75e856dcbcde..f008695b43ac 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class CatAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'declawed': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'declawed': 'declawed', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """cat_all_of.CatAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py index 5d3e21ddd7e9..b34ba8ac0206 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Category(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'id': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'id': 'id', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name='default-name', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name='default-name', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """category.Category - a model defined in OpenAPI Args: @@ -119,6 +122,21 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py index 06c52dc8bee9..a492a47164e7 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ClassModel(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): '_class': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): '_class': '_class', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """class_model.ClassModel - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) _class (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py index b7184b3f2b40..195e3d4209ca 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Client(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'client': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'client': 'client', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """client.Client - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) client (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/complex_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/complex_quadrilateral.py new file mode 100644 index 000000000000..0be63bdcd2d6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/complex_quadrilateral.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import quadrilateral_interface +except ImportError: + quadrilateral_interface = sys.modules[ + 'petstore_api.models.quadrilateral_interface'] +try: + from petstore_api.models import shape_interface +except ImportError: + shape_interface = sys.modules[ + 'petstore_api.models.shape_interface'] + + +class ComplexQuadrilateral(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'quadrilateral_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'quadrilateral_type': 'quadrilateralType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, quadrilateral_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """complex_quadrilateral.ComplexQuadrilateral - a model defined in OpenAPI + + Args: + shape_type (str): + quadrilateral_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'quadrilateral_type': quadrilateral_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + quadrilateral_interface.QuadrilateralInterface, + shape_interface.ShapeInterface, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py index 5d5712d428e9..edf89695f8fa 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Dog(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'color': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { } @@ -109,12 +112,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """dog.Dog - a model defined in OpenAPI Args: @@ -134,6 +139,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ @@ -143,12 +163,14 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'class_name': class_name, @@ -179,7 +201,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -200,12 +222,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py index 0832f4b696cc..6278289267d5 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class DogAllOf(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'breed': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'breed': 'breed', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """dog_all_of.DogAllOf - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py index 358e9f680e76..107e1f3e0f8f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -71,7 +74,7 @@ class EnumArrays(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -86,7 +89,7 @@ def openapi_types(): 'array_enum': ([str],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -95,9 +98,7 @@ def discriminator(): 'array_enum': 'array_enum', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -105,9 +106,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """enum_arrays.EnumArrays - a model defined in OpenAPI Keyword Args: @@ -124,6 +127,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) just_symbol (str): [optional] # noqa: E501 array_enum ([str]): [optional] # noqa: E501 """ @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py index 5f3f1894de47..4323ac7f0856 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -64,7 +67,7 @@ class EnumClass(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,13 +81,11 @@ def openapi_types(): 'value': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -92,9 +93,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """enum_class.EnumClass - a model defined in OpenAPI Args: @@ -114,6 +117,21 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -121,6 +139,7 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py index bcd601f04ed3..83043b7c4315 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -101,7 +104,7 @@ class EnumTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -122,7 +125,7 @@ def openapi_types(): 'outer_enum_integer_default_value': (outer_enum_integer_default_value.OuterEnumIntegerDefaultValue,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -137,9 +140,7 @@ def discriminator(): 'outer_enum_integer_default_value': 'outerEnumIntegerDefaultValue', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -147,9 +148,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, enum_string_required, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, enum_string_required, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """enum_test.EnumTest - a model defined in OpenAPI Args: @@ -169,6 +172,21 @@ def __init__(self, enum_string_required, _check_type=True, _from_server=False, _ deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) enum_string (str): [optional] # noqa: E501 enum_integer (int): [optional] # noqa: E501 enum_number (float): [optional] # noqa: E501 @@ -183,6 +201,7 @@ def __init__(self, enum_string_required, _check_type=True, _from_server=False, _ self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.enum_string_required = enum_string_required for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/equilateral_triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/equilateral_triangle.py new file mode 100644 index 000000000000..90c79fd2bbcc --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/equilateral_triangle.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import shape_interface +except ImportError: + shape_interface = sys.modules[ + 'petstore_api.models.shape_interface'] +try: + from petstore_api.models import triangle_interface +except ImportError: + triangle_interface = sys.modules[ + 'petstore_api.models.triangle_interface'] + + +class EquilateralTriangle(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'triangle_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'triangle_type': 'triangleType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, triangle_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """equilateral_triangle.EquilateralTriangle - a model defined in OpenAPI + + Args: + shape_type (str): + triangle_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'triangle_type': triangle_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + shape_interface.ShapeInterface, + triangle_interface.TriangleInterface, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py index f71dc07b7ca8..0f21a84df498 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class File(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'source_uri': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'source_uri': 'sourceURI', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """file.File - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) source_uri (str): Test capitalization. [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py index 1260e8affda2..2715cfdbfd55 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class FileSchemaTestClass(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -83,7 +86,7 @@ def openapi_types(): 'files': ([file.File],), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -92,9 +95,7 @@ def discriminator(): 'files': 'files', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -102,9 +103,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """file_schema_test_class.FileSchemaTestClass - a model defined in OpenAPI Keyword Args: @@ -121,6 +124,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) file (file.File): [optional] # noqa: E501 files ([file.File]): [optional] # noqa: E501 """ @@ -130,6 +148,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py index 7a71b34dc4de..6e88c734c966 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Foo(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'bar': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'bar': 'bar', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """foo.Foo - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bar (str): [optional] if omitted the server will use the default value of 'bar' # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py index 2a7e08f4d737..e3084b719111 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -104,7 +107,7 @@ class FormatTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -132,7 +135,7 @@ def openapi_types(): 'pattern_with_digits_and_delimiter': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -154,9 +157,7 @@ def discriminator(): 'pattern_with_digits_and_delimiter': 'pattern_with_digits_and_delimiter', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -164,9 +165,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, number, byte, date, password, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, number, byte, date, password, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """format_test.FormatTest - a model defined in OpenAPI Args: @@ -189,6 +192,21 @@ def __init__(self, number, byte, date, password, _check_type=True, _from_server= deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) integer (int): [optional] # noqa: E501 int32 (int): [optional] # noqa: E501 int64 (int): [optional] # noqa: E501 @@ -207,6 +225,7 @@ def __init__(self, number, byte, date, password, _check_type=True, _from_server= self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.number = number self.byte = byte diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py index d5e71abd700f..dd0d21e3315b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class Fruit(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'length_cm': (float,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -105,12 +108,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """fruit.Fruit - a model defined in OpenAPI Keyword Args: @@ -127,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) color (str): [optional] # noqa: E501 cultivar (str): [optional] # noqa: E501 length_cm (float): [optional] # noqa: E501 @@ -137,12 +157,14 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { } @@ -172,7 +194,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py index 111326fcb4f6..a1836e551c0e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class FruitReq(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -90,7 +93,7 @@ def openapi_types(): 'sweet': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -107,12 +110,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """fruit_req.FruitReq - a model defined in OpenAPI Args: @@ -133,6 +138,21 @@ def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type= deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) mealy (bool): [optional] # noqa: E501 sweet (bool): [optional] # noqa: E501 """ @@ -142,12 +162,14 @@ def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type= self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'cultivar': cultivar, @@ -179,7 +201,7 @@ def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type= continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py index 0888743b8ec8..9afdc0ecc95b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -73,7 +76,7 @@ class GmFruit(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'length_cm': (float,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -105,12 +108,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """gm_fruit.GmFruit - a model defined in OpenAPI Keyword Args: @@ -127,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) color (str): [optional] # noqa: E501 cultivar (str): [optional] # noqa: E501 length_cm (float): [optional] # noqa: E501 @@ -137,12 +157,14 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { } @@ -172,7 +194,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py index c84cf0be3f2b..974136a56a6f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class HasOnlyReadOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'foo': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'foo': 'foo', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """has_only_read_only.HasOnlyReadOnly - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bar (str): [optional] # noqa: E501 foo (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py index 873bad5451fe..662cf79189ff 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class HealthCheckResult(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'nullable_message': (str, none_type,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'nullable_message': 'NullableMessage', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """health_check_result.HealthCheckResult - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) nullable_message (str, none_type): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py index bba44a11c13d..5de65e44476e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class InlineObject(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'status': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'status': 'status', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_object.InlineObject - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (str): Updated name of the pet. [optional] # noqa: E501 status (str): Updated status of the pet. [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py index 4262d4165fdc..03ec7a1908c9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class InlineObject1(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'file': (file_type,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'file': 'file', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_object1.InlineObject1 - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) additional_metadata (str): Additional data to pass to server. [optional] # noqa: E501 file (file_type): file to upload. [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py index 2fd4792709f5..701f8f8985b9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -72,7 +75,7 @@ class InlineObject2(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -87,7 +90,7 @@ def openapi_types(): 'enum_form_string': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -96,9 +99,7 @@ def discriminator(): 'enum_form_string': 'enum_form_string', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -106,9 +107,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_object2.InlineObject2 - a model defined in OpenAPI Keyword Args: @@ -125,6 +128,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) enum_form_string_array ([str]): Form parameter enum test (string array). [optional] # noqa: E501 enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' # noqa: E501 """ @@ -134,6 +152,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py index 209e97de6e18..e720690a0550 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -97,7 +100,7 @@ class InlineObject3(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -124,7 +127,7 @@ def openapi_types(): 'callback': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -145,9 +148,7 @@ def discriminator(): 'callback': 'callback', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -155,9 +156,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, number, double, pattern_without_delimiter, byte, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, number, double, pattern_without_delimiter, byte, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_object3.InlineObject3 - a model defined in OpenAPI Args: @@ -180,6 +183,21 @@ def __init__(self, number, double, pattern_without_delimiter, byte, _check_type= deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) integer (int): None. [optional] # noqa: E501 int32 (int): None. [optional] # noqa: E501 int64 (int): None. [optional] # noqa: E501 @@ -197,6 +215,7 @@ def __init__(self, number, double, pattern_without_delimiter, byte, _check_type= self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.number = number self.double = double diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py index 67b14d2c64e5..dd5ade491376 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class InlineObject4(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'param2': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'param2': 'param2', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, param, param2, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, param, param2, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_object4.InlineObject4 - a model defined in OpenAPI Args: @@ -120,6 +123,21 @@ def __init__(self, param, param2, _check_type=True, _from_server=False, _path_to deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -127,6 +145,7 @@ def __init__(self, param, param2, _check_type=True, _from_server=False, _path_to self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.param = param self.param2 = param2 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py index ce5fc59a4aee..b133b4026884 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class InlineObject5(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'additional_metadata': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'additional_metadata': 'additionalMetadata', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, required_file, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, required_file, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_object5.InlineObject5 - a model defined in OpenAPI Args: @@ -119,6 +122,21 @@ def __init__(self, required_file, _check_type=True, _from_server=False, _path_to deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) additional_metadata (str): Additional data to pass to server. [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, required_file, _check_type=True, _from_server=False, _path_to self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.required_file = required_file for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py index ad0f356ab50b..1ef604607e67 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class InlineResponseDefault(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -82,7 +85,7 @@ def openapi_types(): 'string': (foo.Foo,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -90,9 +93,7 @@ def discriminator(): 'string': 'string', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -100,9 +101,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """inline_response_default.InlineResponseDefault - a model defined in OpenAPI Keyword Args: @@ -119,6 +122,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) string (foo.Foo): [optional] # noqa: E501 """ @@ -127,6 +145,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/isosceles_triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/isosceles_triangle.py new file mode 100644 index 000000000000..6ef7500c2c62 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/isosceles_triangle.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import shape_interface +except ImportError: + shape_interface = sys.modules[ + 'petstore_api.models.shape_interface'] +try: + from petstore_api.models import triangle_interface +except ImportError: + triangle_interface = sys.modules[ + 'petstore_api.models.triangle_interface'] + + +class IsoscelesTriangle(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'triangle_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'triangle_type': 'triangleType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, triangle_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """isosceles_triangle.IsoscelesTriangle - a model defined in OpenAPI + + Args: + shape_type (str): + triangle_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'triangle_type': triangle_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + shape_interface.ShapeInterface, + triangle_interface.TriangleInterface, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py index c7c80e8bd28b..3f85acb2e4d3 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class List(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): '_123_list': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): '_123_list': '123-list', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """list.List - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) _123_list (str): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py index d5ee114fe25f..d57315bdd61a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -78,7 +81,7 @@ class Mammal(ModelComposed): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -95,7 +98,7 @@ def openapi_types(): 'type': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): val = { 'whale': whale.Whale, @@ -118,12 +121,14 @@ def discriminator(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', '_composed_instances', '_var_name_to_model_instances', '_additional_properties_model_instances', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """mammal.Mammal - a model defined in OpenAPI Args: @@ -143,6 +148,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) has_baleen (bool): [optional] # noqa: E501 has_teeth (bool): [optional] # noqa: E501 type (str): [optional] # noqa: E501 @@ -153,12 +173,14 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) constant_args = { '_check_type': _check_type, '_path_to_item': _path_to_item, '_from_server': _from_server, '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, } required_args = { 'class_name': class_name, @@ -189,7 +211,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it continue setattr(self, var_name, var_value) - @staticmethod + @cached_property def _composed_schemas(): # we need this here to make our import statements work # we must store _composed_schemas in here so the code is only run @@ -210,12 +232,12 @@ def _composed_schemas(): } @classmethod - def get_discriminator_class(cls, from_server, data): + def get_discriminator_class(cls, data): """Returns the child class specified by the discriminator""" - discriminator = cls.discriminator() + discriminator = cls.discriminator discr_propertyname_py = list(discriminator.keys())[0] discr_propertyname_js = cls.attribute_map[discr_propertyname_py] - if from_server: + if discr_propertyname_js in data: class_name = data[discr_propertyname_js] else: class_name = data[discr_propertyname_py] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py index 8cc47c0a6922..e3510cef772f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -72,7 +75,7 @@ class MapTest(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -89,7 +92,7 @@ def openapi_types(): 'indirect_map': (string_boolean_map.StringBooleanMap,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -100,9 +103,7 @@ def discriminator(): 'indirect_map': 'indirect_map', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -110,9 +111,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """map_test.MapTest - a model defined in OpenAPI Keyword Args: @@ -129,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) map_map_of_string ({str: ({str: (str,)},)}): [optional] # noqa: E501 map_of_enum_string ({str: (str,)}): [optional] # noqa: E501 direct_map ({str: (bool,)}): [optional] # noqa: E501 @@ -140,6 +158,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py index 143a79bfa266..36f5add3db88 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -84,7 +87,7 @@ def openapi_types(): 'map': ({str: (animal.Animal,)},), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -94,9 +97,7 @@ def discriminator(): 'map': 'map', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -104,9 +105,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI Keyword Args: @@ -123,6 +126,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) uuid (str): [optional] # noqa: E501 date_time (datetime): [optional] # noqa: E501 map ({str: (animal.Animal,)}): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py index 0c3885120210..96d39402d563 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Model200Response(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): '_class': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): '_class': 'class', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """model200_response.Model200Response - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) name (int): [optional] # noqa: E501 _class (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py index 75c3cea6318b..f9213c37ea7e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ModelReturn(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): '_return': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): '_return': 'return', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """model_return.ModelReturn - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) _return (int): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py index db81ae16916d..b2fce89ec9b7 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Name(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -80,7 +83,7 @@ def openapi_types(): '_123_number': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -91,9 +94,7 @@ def discriminator(): '_123_number': '123Number', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -101,9 +102,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """name.Name - a model defined in OpenAPI Args: @@ -123,6 +126,21 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) snake_case (int): [optional] # noqa: E501 _property (str): [optional] # noqa: E501 _123_number (int): [optional] # noqa: E501 @@ -133,6 +151,7 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py index c97b8227cde6..89d8720a969c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class NullableClass(ModelNormal): additional_properties_type = (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'object_items_nullable': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -107,9 +110,7 @@ def discriminator(): 'object_items_nullable': 'object_items_nullable', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -117,9 +118,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """nullable_class.NullableClass - a model defined in OpenAPI Keyword Args: @@ -136,6 +139,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) integer_prop (int, none_type): [optional] # noqa: E501 number_prop (float, none_type): [optional] # noqa: E501 boolean_prop (bool, none_type): [optional] # noqa: E501 @@ -155,6 +173,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py index 0c91e2ae62d0..896757360765 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class NumberOnly(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'just_number': (float,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'just_number': 'JustNumber', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """number_only.NumberOnly - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) just_number (float): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py index 673295a8610c..6ff62a572333 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class Order(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -87,7 +90,7 @@ def openapi_types(): 'complete': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -100,9 +103,7 @@ def discriminator(): 'complete': 'complete', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -110,9 +111,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """order.Order - a model defined in OpenAPI Keyword Args: @@ -129,6 +132,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 pet_id (int): [optional] # noqa: E501 quantity (int): [optional] # noqa: E501 @@ -142,6 +160,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py index d797e2f7d07a..da7cbd159058 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class OuterComposite(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -79,7 +82,7 @@ def openapi_types(): 'my_boolean': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -89,9 +92,7 @@ def discriminator(): 'my_boolean': 'my_boolean', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -99,9 +100,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_composite.OuterComposite - a model defined in OpenAPI Keyword Args: @@ -118,6 +121,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) my_number (float): [optional] # noqa: E501 my_string (str): [optional] # noqa: E501 my_boolean (bool): [optional] # noqa: E501 @@ -128,6 +146,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py index ad948db05274..7c09a5b8d59a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -65,7 +68,7 @@ class OuterEnum(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -79,13 +82,11 @@ def openapi_types(): 'value': (str, none_type,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -93,9 +94,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_enum.OuterEnum - a model defined in OpenAPI Args: @@ -115,6 +118,21 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -122,6 +140,7 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py index 789bf4ae86fa..fdc882ee5dba 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -64,7 +67,7 @@ class OuterEnumDefaultValue(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,13 +81,11 @@ def openapi_types(): 'value': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -92,9 +93,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value='placed', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value='placed', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_enum_default_value.OuterEnumDefaultValue - a model defined in OpenAPI Args: @@ -114,6 +117,21 @@ def __init__(self, value='placed', _check_type=True, _from_server=False, _path_t deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -121,6 +139,7 @@ def __init__(self, value='placed', _check_type=True, _from_server=False, _path_t self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py index a6323a7fc0ea..187a714b33bf 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -64,7 +67,7 @@ class OuterEnumInteger(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,13 +81,11 @@ def openapi_types(): 'value': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -92,9 +93,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_enum_integer.OuterEnumInteger - a model defined in OpenAPI Args: @@ -114,6 +117,21 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -121,6 +139,7 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py index 1098c6494504..41da57604fc8 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -64,7 +67,7 @@ class OuterEnumIntegerDefaultValue(ModelSimple): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,13 +81,11 @@ def openapi_types(): 'value': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = None required_properties = set([ '_data_store', @@ -92,9 +93,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, value=0, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, value=0, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """outer_enum_integer_default_value.OuterEnumIntegerDefaultValue - a model defined in OpenAPI Args: @@ -114,6 +117,21 @@ def __init__(self, value=0, _check_type=True, _from_server=False, _path_to_item= deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -121,6 +139,7 @@ def __init__(self, value=0, _check_type=True, _from_server=False, _path_to_item= self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.value = value for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py index 74cd8afef1af..1b34db901312 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -78,7 +81,7 @@ class Pet(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -97,7 +100,7 @@ def openapi_types(): 'status': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -110,9 +113,7 @@ def discriminator(): 'status': 'status', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -120,9 +121,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """pet.Pet - a model defined in OpenAPI Args: @@ -143,6 +146,21 @@ def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 category (category.Category): [optional] # noqa: E501 tags ([tag.Tag]): [optional] # noqa: E501 @@ -154,6 +172,7 @@ def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.name = name self.photo_urls = photo_urls diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/quadrilateral.py new file mode 100644 index 000000000000..30443f766f02 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/quadrilateral.py @@ -0,0 +1,235 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import complex_quadrilateral +except ImportError: + complex_quadrilateral = sys.modules[ + 'petstore_api.models.complex_quadrilateral'] +try: + from petstore_api.models import simple_quadrilateral +except ImportError: + simple_quadrilateral = sys.modules[ + 'petstore_api.models.simple_quadrilateral'] + + +class Quadrilateral(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'quadrilateral_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + 'ComplexQuadrilateral': complex_quadrilateral.ComplexQuadrilateral, + 'SimpleQuadrilateral': simple_quadrilateral.SimpleQuadrilateral, + } + if not val: + return None + return {'quadrilateral_type': val} + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'quadrilateral_type': 'quadrilateralType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, quadrilateral_type, shape_type=nulltype.Null, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """quadrilateral.Quadrilateral - a model defined in OpenAPI + + Args: + quadrilateral_type (str): + + Keyword Args: + shape_type (str): defaults to nulltype.Null # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'quadrilateral_type': quadrilateral_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + complex_quadrilateral.ComplexQuadrilateral, + simple_quadrilateral.SimpleQuadrilateral, + ], + } + + @classmethod + def get_discriminator_class(cls, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in data: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/quadrilateral_interface.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/quadrilateral_interface.py new file mode 100644 index 000000000000..2f60ea9362dc --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/quadrilateral_interface.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class QuadrilateralInterface(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'quadrilateral_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'quadrilateral_type': 'quadrilateralType', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, quadrilateral_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """quadrilateral_interface.QuadrilateralInterface - a model defined in OpenAPI + + Args: + quadrilateral_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.quadrilateral_type = quadrilateral_type + for var_name, var_value in six.iteritems(kwargs): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py index 329ec017d435..8c6d80c71f16 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class ReadOnlyFirst(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'baz': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'baz': 'baz', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """read_only_first.ReadOnlyFirst - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) bar (str): [optional] # noqa: E501 baz (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/scalene_triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/scalene_triangle.py new file mode 100644 index 000000000000..8a9b46fd4c6f --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/scalene_triangle.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import shape_interface +except ImportError: + shape_interface = sys.modules[ + 'petstore_api.models.shape_interface'] +try: + from petstore_api.models import triangle_interface +except ImportError: + triangle_interface = sys.modules[ + 'petstore_api.models.triangle_interface'] + + +class ScaleneTriangle(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'triangle_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'triangle_type': 'triangleType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, triangle_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """scalene_triangle.ScaleneTriangle - a model defined in OpenAPI + + Args: + shape_type (str): + triangle_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'triangle_type': triangle_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + shape_interface.ShapeInterface, + triangle_interface.TriangleInterface, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/shape.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/shape.py new file mode 100644 index 000000000000..bb8ec6d238ec --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/shape.py @@ -0,0 +1,239 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import quadrilateral +except ImportError: + quadrilateral = sys.modules[ + 'petstore_api.models.quadrilateral'] +try: + from petstore_api.models import triangle +except ImportError: + triangle = sys.modules[ + 'petstore_api.models.triangle'] + + +class Shape(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'quadrilateral_type': (str,), # noqa: E501 + 'triangle_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + 'Quadrilateral': quadrilateral.Quadrilateral, + 'Triangle': triangle.Triangle, + } + if not val: + return None + return {'shape_type': val} + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'quadrilateral_type': 'quadrilateralType', # noqa: E501 + 'triangle_type': 'triangleType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, quadrilateral_type=nulltype.Null, triangle_type=nulltype.Null, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """shape.Shape - a model defined in OpenAPI + + Args: + shape_type (str): + + Keyword Args: + quadrilateral_type (str): defaults to nulltype.Null # noqa: E501 + triangle_type (str): defaults to nulltype.Null # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'quadrilateral_type': quadrilateral_type, + 'triangle_type': triangle_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + quadrilateral.Quadrilateral, + triangle.Triangle, + ], + } + + @classmethod + def get_discriminator_class(cls, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in data: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/shape_interface.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/shape_interface.py new file mode 100644 index 000000000000..1152adfc8a48 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/shape_interface.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class ShapeInterface(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """shape_interface.ShapeInterface - a model defined in OpenAPI + + Args: + shape_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.shape_type = shape_type + for var_name, var_value in six.iteritems(kwargs): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/simple_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/simple_quadrilateral.py new file mode 100644 index 000000000000..cd92ebf412e8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/simple_quadrilateral.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import quadrilateral_interface +except ImportError: + quadrilateral_interface = sys.modules[ + 'petstore_api.models.quadrilateral_interface'] +try: + from petstore_api.models import shape_interface +except ImportError: + shape_interface = sys.modules[ + 'petstore_api.models.shape_interface'] + + +class SimpleQuadrilateral(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'quadrilateral_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'quadrilateral_type': 'quadrilateralType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, shape_type, quadrilateral_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """simple_quadrilateral.SimpleQuadrilateral - a model defined in OpenAPI + + Args: + shape_type (str): + quadrilateral_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'quadrilateral_type': quadrilateral_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + quadrilateral_interface.QuadrilateralInterface, + shape_interface.ShapeInterface, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py index d4ffc608a579..168554fa343e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class SpecialModelName(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -77,7 +80,7 @@ def openapi_types(): 'special_property_name': (int,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -85,9 +88,7 @@ def discriminator(): 'special_property_name': '$special[property.name]', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -95,9 +96,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """special_model_name.SpecialModelName - a model defined in OpenAPI Keyword Args: @@ -114,6 +117,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) special_property_name (int): [optional] # noqa: E501 """ @@ -122,6 +140,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py index 7f797f5f1b5d..10d0a9882261 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class StringBooleanMap(ModelNormal): additional_properties_type = (bool,) # noqa: E501 - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -76,16 +79,14 @@ def openapi_types(): return { } - @staticmethod + @cached_property def discriminator(): return None attribute_map = { } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -93,9 +94,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """string_boolean_map.StringBooleanMap - a model defined in OpenAPI Keyword Args: @@ -112,6 +115,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) """ self._data_store = {} @@ -119,6 +137,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py index 8ffba1b13071..26cdd6f50922 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Tag(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -78,7 +81,7 @@ def openapi_types(): 'name': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -87,9 +90,7 @@ def discriminator(): 'name': 'name', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -97,9 +98,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """tag.Tag - a model defined in OpenAPI Keyword Args: @@ -116,6 +119,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 name (str): [optional] # noqa: E501 """ @@ -125,6 +143,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/triangle.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/triangle.py new file mode 100644 index 000000000000..fb3536503993 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/triangle.py @@ -0,0 +1,242 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import equilateral_triangle +except ImportError: + equilateral_triangle = sys.modules[ + 'petstore_api.models.equilateral_triangle'] +try: + from petstore_api.models import isosceles_triangle +except ImportError: + isosceles_triangle = sys.modules[ + 'petstore_api.models.isosceles_triangle'] +try: + from petstore_api.models import scalene_triangle +except ImportError: + scalene_triangle = sys.modules[ + 'petstore_api.models.scalene_triangle'] + + +class Triangle(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'shape_type': (str,), # noqa: E501 + 'triangle_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + val = { + 'EquilateralTriangle': equilateral_triangle.EquilateralTriangle, + 'IsoscelesTriangle': isosceles_triangle.IsoscelesTriangle, + 'ScaleneTriangle': scalene_triangle.ScaleneTriangle, + } + if not val: + return None + return {'triangle_type': val} + + attribute_map = { + 'shape_type': 'shapeType', # noqa: E501 + 'triangle_type': 'triangleType', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, triangle_type, shape_type=nulltype.Null, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """triangle.Triangle - a model defined in OpenAPI + + Args: + triangle_type (str): + + Keyword Args: + shape_type (str): defaults to nulltype.Null # noqa: E501 + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + required_args = { + 'shape_type': shape_type, + 'triangle_type': triangle_type, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + unused_args = composed_info[3] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + for var_name, var_value in six.iteritems(kwargs): + if var_name in unused_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + not self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + equilateral_triangle.EquilateralTriangle, + isosceles_triangle.IsoscelesTriangle, + scalene_triangle.ScaleneTriangle, + ], + } + + @classmethod + def get_discriminator_class(cls, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in data: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/triangle_interface.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/triangle_interface.py new file mode 100644 index 000000000000..5881e3c94728 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/triangle_interface.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 +import nulltype # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class TriangleInterface(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + @cached_property + def openapi_types(): + """ + This must be a class method so a model may have properties that are + of type self, this ensures that we don't create a cyclic import + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'triangle_type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + attribute_map = { + 'triangle_type': 'triangleType', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, triangle_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 + """triangle_interface.TriangleInterface - a model defined in OpenAPI + + Args: + triangle_type (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.triangle_type = triangle_type + for var_name, var_value in six.iteritems(kwargs): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py index 31e9e36b1ad0..7a571040a2fa 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class User(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -88,7 +91,7 @@ def openapi_types(): 'arbitrary_nullable_type_value': (object, none_type,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -107,9 +110,7 @@ def discriminator(): 'arbitrary_nullable_type_value': 'arbitraryNullableTypeValue', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -117,9 +118,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """user.User - a model defined in OpenAPI Keyword Args: @@ -136,6 +139,21 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) id (int): [optional] # noqa: E501 username (str): [optional] # noqa: E501 first_name (str): [optional] # noqa: E501 @@ -155,6 +173,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in six.iteritems(kwargs): if var_name not in self.attribute_map and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py index 0c166e663015..c89497b6b556 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -63,7 +66,7 @@ class Whale(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -79,7 +82,7 @@ def openapi_types(): 'has_teeth': (bool,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -89,9 +92,7 @@ def discriminator(): 'has_teeth': 'hasTeeth', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -99,9 +100,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """whale.Whale - a model defined in OpenAPI Args: @@ -121,6 +124,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) has_baleen (bool): [optional] # noqa: E501 has_teeth (bool): [optional] # noqa: E501 """ @@ -130,6 +148,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py index 56c0b34c2672..53c8a1dc2dee 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py @@ -21,6 +21,9 @@ ModelComposed, ModelNormal, ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, date, datetime, file_type, @@ -68,7 +71,7 @@ class Zebra(ModelNormal): additional_properties_type = None - @staticmethod + @cached_property def openapi_types(): """ This must be a class method so a model may have properties that are @@ -83,7 +86,7 @@ def openapi_types(): 'type': (str,), # noqa: E501 } - @staticmethod + @cached_property def discriminator(): return None @@ -92,9 +95,7 @@ def discriminator(): 'type': 'type', # noqa: E501 } - @staticmethod - def _composed_schemas(): - return None + _composed_schemas = {} required_properties = set([ '_data_store', @@ -102,9 +103,11 @@ def _composed_schemas(): '_from_server', '_path_to_item', '_configuration', + '_visited_composed_classes', ]) - def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + @convert_js_args_to_python_args + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, _visited_composed_classes=(), **kwargs): # noqa: E501 """zebra.Zebra - a model defined in OpenAPI Args: @@ -124,6 +127,21 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) type (str): [optional] # noqa: E501 """ @@ -132,6 +150,7 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_complex_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/test/test_complex_quadrilateral.py new file mode 100644 index 000000000000..b1d4fc9079bd --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_complex_quadrilateral.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestComplexQuadrilateral(unittest.TestCase): + """ComplexQuadrilateral unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testComplexQuadrilateral(self): + """Test ComplexQuadrilateral""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ComplexQuadrilateral() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_equilateral_triangle.py b/samples/openapi3/client/petstore/python-experimental/test/test_equilateral_triangle.py new file mode 100644 index 000000000000..cdef216105eb --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_equilateral_triangle.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestEquilateralTriangle(unittest.TestCase): + """EquilateralTriangle unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEquilateralTriangle(self): + """Test EquilateralTriangle""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.EquilateralTriangle() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py b/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py index ee32229a8bbd..3b16da852e3d 100644 --- a/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py +++ b/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py @@ -66,9 +66,9 @@ def testFruit(self): invalid_variable = getattr(fruit, 'cultivar', 'some value') # make sure that the ModelComposed class properties are correct - # model.composed_schemas() stores the anyOf/allOf/oneOf info + # model._composed_schemas stores the anyOf/allOf/oneOf info self.assertEqual( - fruit._composed_schemas(), + fruit._composed_schemas, { 'anyOf': [], 'allOf': [], @@ -79,7 +79,7 @@ def testFruit(self): } ) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.Banana: banana_instance = composed_instance @@ -147,7 +147,7 @@ def testFruit(self): ) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.Apple: apple_instance = composed_instance diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py b/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py index 2fa26fac0aa5..89905eca7504 100644 --- a/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py +++ b/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py @@ -61,9 +61,9 @@ def testFruitReq(self): invalid_variable = getattr(fruit, 'cultivar', 'some value') # make sure that the ModelComposed class properties are correct - # model.composed_schemas() stores the anyOf/allOf/oneOf info + # model._composed_schemas stores the anyOf/allOf/oneOf info self.assertEqual( - fruit._composed_schemas(), + fruit._composed_schemas, { 'anyOf': [], 'allOf': [], @@ -74,7 +74,7 @@ def testFruitReq(self): } ) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.BananaReq: banana_instance = composed_instance @@ -137,7 +137,7 @@ def testFruitReq(self): ) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.AppleReq: apple_instance = composed_instance diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py b/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py index dd9605bd8a1b..b8e02ed45a74 100644 --- a/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py +++ b/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py @@ -66,9 +66,9 @@ def testGmFruit(self): invalid_variable = getattr(fruit, 'cultivar', 'some value') # make sure that the ModelComposed class properties are correct - # model.composed_schemas() stores the anyOf/allOf/oneOf info + # model._composed_schemas stores the anyOf/allOf/oneOf info self.assertEqual( - fruit._composed_schemas(), + fruit._composed_schemas, { 'anyOf': [ petstore_api.Apple, @@ -79,7 +79,7 @@ def testGmFruit(self): } ) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.Banana: banana_instance = composed_instance @@ -137,7 +137,7 @@ def testGmFruit(self): self.assertEqual(getattr(fruit, 'length_cm'), length_cm) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.Apple: apple_instance = composed_instance @@ -180,7 +180,7 @@ def testGmFruit(self): ) # model._composed_instances is a list of the instances that were - # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + # made from the anyOf/allOf/OneOf classes in model._composed_schemas for composed_instance in fruit._composed_instances: if composed_instance.__class__ == petstore_api.Apple: apple_instance = composed_instance diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_isosceles_triangle.py b/samples/openapi3/client/petstore/python-experimental/test/test_isosceles_triangle.py new file mode 100644 index 000000000000..1f27f751d061 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_isosceles_triangle.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestIsoscelesTriangle(unittest.TestCase): + """IsoscelesTriangle unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testIsoscelesTriangle(self): + """Test IsoscelesTriangle""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.IsoscelesTriangle() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/test/test_quadrilateral.py new file mode 100644 index 000000000000..9bb838811892 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_quadrilateral.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestQuadrilateral(unittest.TestCase): + """Quadrilateral unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testQuadrilateral(self): + """Test Quadrilateral""" + complex_quadrilateral = petstore_api.Quadrilateral(shape_type="Quadrilateral", quadrilateral_type="ComplexQuadrilateral") + assert isinstance(complex_quadrilateral, petstore_api.ComplexQuadrilateral) + simple_quadrilateral = petstore_api.Quadrilateral(shape_type="Quadrilateral", quadrilateral_type="SimpleQuadrilateral") + assert isinstance(simple_quadrilateral, petstore_api.SimpleQuadrilateral) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_quadrilateral_interface.py b/samples/openapi3/client/petstore/python-experimental/test/test_quadrilateral_interface.py new file mode 100644 index 000000000000..7a48ce64a9df --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_quadrilateral_interface.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestQuadrilateralInterface(unittest.TestCase): + """QuadrilateralInterface unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testQuadrilateralInterface(self): + """Test QuadrilateralInterface""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.QuadrilateralInterface() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_scalene_triangle.py b/samples/openapi3/client/petstore/python-experimental/test/test_scalene_triangle.py new file mode 100644 index 000000000000..8452fc183137 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_scalene_triangle.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestScaleneTriangle(unittest.TestCase): + """ScaleneTriangle unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testScaleneTriangle(self): + """Test ScaleneTriangle""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ScaleneTriangle() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_shape.py b/samples/openapi3/client/petstore/python-experimental/test/test_shape.py new file mode 100644 index 000000000000..c8296aad8ef8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_shape.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestShape(unittest.TestCase): + """Shape unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testShape(self): + """Test Shape""" + equilateral_triangle = petstore_api.Triangle( + shape_type="Triangle", + triangle_type="EquilateralTriangle" + ) + assert isinstance(equilateral_triangle, petstore_api.EquilateralTriangle) + + isosceles_triangle = petstore_api.Triangle( + shape_type="Triangle", + triangle_type="IsoscelesTriangle" + ) + assert isinstance(isosceles_triangle, petstore_api.IsoscelesTriangle) + + scalene_triangle = petstore_api.Triangle( + shape_type="Triangle", + triangle_type="ScaleneTriangle" + ) + assert isinstance(scalene_triangle, petstore_api.ScaleneTriangle) + + complex_quadrilateral = petstore_api.Shape( + shape_type="Quadrilateral", + quadrilateral_type="ComplexQuadrilateral" + ) + assert isinstance(complex_quadrilateral, petstore_api.ComplexQuadrilateral) + + simple_quadrilateral = petstore_api.Shape( + shape_type="Quadrilateral", + quadrilateral_type="SimpleQuadrilateral" + ) + assert isinstance(simple_quadrilateral, petstore_api.SimpleQuadrilateral) + + # invalid shape_type (first discriminator) + err_msg = ("Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '{}'='{}' at path: ()" + ) + with self.assertRaisesRegexp( + petstore_api.ApiValueError, + err_msg.format("shapeType", "Circle") + ): + petstore_api.Shape(shape_type="Circle") + + # invalid quadrilateral_type (second discriminator) + with self.assertRaisesRegexp( + petstore_api.ApiValueError, + err_msg.format("quadrilateralType", "Triangle") + ): + petstore_api.Shape( + shape_type="Quadrilateral", + quadrilateral_type="Triangle" + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_shape_interface.py b/samples/openapi3/client/petstore/python-experimental/test/test_shape_interface.py new file mode 100644 index 000000000000..a768951489a0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_shape_interface.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestShapeInterface(unittest.TestCase): + """ShapeInterface unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testShapeInterface(self): + """Test ShapeInterface""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ShapeInterface() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_simple_quadrilateral.py b/samples/openapi3/client/petstore/python-experimental/test/test_simple_quadrilateral.py new file mode 100644 index 000000000000..f51722093445 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_simple_quadrilateral.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestSimpleQuadrilateral(unittest.TestCase): + """SimpleQuadrilateral unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testSimpleQuadrilateral(self): + """Test SimpleQuadrilateral""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.SimpleQuadrilateral() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_triangle.py b/samples/openapi3/client/petstore/python-experimental/test/test_triangle.py new file mode 100644 index 000000000000..42037a1ec79b --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_triangle.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestTriangle(unittest.TestCase): + """Triangle unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTriangle(self): + """Test Triangle""" + equilateral_triangle = petstore_api.Triangle(shape_type="Triangle", triangle_type="EquilateralTriangle") + assert isinstance(equilateral_triangle, petstore_api.EquilateralTriangle) + isosceles_triangle = petstore_api.Triangle(shape_type="Triangle", triangle_type="IsoscelesTriangle") + assert isinstance(isosceles_triangle, petstore_api.IsoscelesTriangle) + scalene_triangle = petstore_api.Triangle(shape_type="Triangle", triangle_type="ScaleneTriangle") + assert isinstance(scalene_triangle, petstore_api.ScaleneTriangle) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_triangle_interface.py b/samples/openapi3/client/petstore/python-experimental/test/test_triangle_interface.py new file mode 100644 index 000000000000..4d87e647e61e --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_triangle_interface.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestTriangleInterface(unittest.TestCase): + """TriangleInterface unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTriangleInterface(self): + """Test TriangleInterface""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.TriangleInterface() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py b/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py index f1a71a67378b..1cff538a15fc 100644 --- a/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py +++ b/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py @@ -27,6 +27,48 @@ def setUp(self): self.api_client = petstore_api.ApiClient() self.deserialize = self.api_client.deserialize + def test_deserialize_shape(self): + """ + + deserialize Shape to an instance of: + - EquilateralTriangle + - IsoscelesTriangle + - IsoscelesTriangle + - ScaleneTriangle + - ComplexQuadrilateral + - SimpleQuadrilateral + by traveling through 2 discriminators + """ + shape_type, triangle_type = ['Triangle', 'EquilateralTriangle'] + data = { + 'shapeType': shape_type, + 'triangleType': triangle_type, + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, (petstore_api.Shape,), True) + self.assertTrue(isinstance(deserialized, petstore_api.EquilateralTriangle)) + self.assertEqual(deserialized.shape_type, shape_type) + self.assertEqual(deserialized.triangle_type, triangle_type) + + # invalid second discriminator value + shape_type, quadrilateral_type = ['Quadrilateral', 'Triangle'] + data = { + 'shapeType': shape_type, + 'quadrilateralType': quadrilateral_type, + } + response = MockResponse(data=json.dumps(data)) + + err_msg = ("Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '{}'='{}' at path: ()" + ) + with self.assertRaisesRegexp( + petstore_api.ApiValueError, + err_msg.format("quadrilateralType", "Triangle") + ): + self.deserialize(response, (petstore_api.Shape,), True) + def test_deserialize_animal(self): """ deserialize Animal to a Dog instance