From a58caae14d9508c0c8a3645b1eef9f1f184dc76a Mon Sep 17 00:00:00 2001 From: the-akhil-nair Date: Fri, 22 Apr 2022 16:47:55 -0400 Subject: [PATCH] [get_item_all_of_bug] Added samples, test cases to validate all_of schema. --- ...odels-for-testing-with-http-signature.yaml | 30 +- .../petstore/python/.openapi-generator/FILES | 12 + .../openapi3/client/petstore/python/README.md | 4 + .../python/docs/EgressThresholdOptions.md | 12 + .../petstore/python/docs/PublishOptions.md | 12 + .../python/docs/PublishOptionsPublish.md | 13 + .../petstore/python/docs/StreamOptions.md | 13 + .../python/petstore_api/api/fake_api.py | 122 +++++++ .../model/egress_threshold_options.py | 263 ++++++++++++++ .../petstore_api/model/publish_options.py | 269 ++++++++++++++ .../model/publish_options_publish.py | 267 ++++++++++++++ .../petstore_api/model/stream_options.py | 328 ++++++++++++++++++ .../python/petstore_api/models/__init__.py | 4 + .../test/test_egress_threshold_options.py | 35 ++ .../python/test/test_publish_options.py | 37 ++ .../test/test_publish_options_publish.py | 35 ++ .../python/test/test_stream_options.py | 41 +++ .../python/tests_manual/test_fake_api.py | 34 ++ .../python/tests_manual/test_fruit.py | 4 +- .../python/tests_manual/test_gm_fruit.py | 6 +- 20 files changed, 1535 insertions(+), 6 deletions(-) create mode 100644 samples/openapi3/client/petstore/python/docs/EgressThresholdOptions.md create mode 100644 samples/openapi3/client/petstore/python/docs/PublishOptions.md create mode 100644 samples/openapi3/client/petstore/python/docs/PublishOptionsPublish.md create mode 100644 samples/openapi3/client/petstore/python/docs/StreamOptions.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/egress_threshold_options.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/publish_options.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/publish_options_publish.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/model/stream_options.py create mode 100644 samples/openapi3/client/petstore/python/test/test_egress_threshold_options.py create mode 100644 samples/openapi3/client/petstore/python/test/test_publish_options.py create mode 100644 samples/openapi3/client/petstore/python/test/test_publish_options_publish.py create mode 100644 samples/openapi3/client/petstore/python/test/test_stream_options.py diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 758c546fe918..2f4ce208f363 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -2503,4 +2503,32 @@ components: items: type: object prop2: - type: object \ No newline at end of file + type: object + StreamOptions: + allOf: + - $ref: "#/components/schemas/EgressThresholdOptions" + - $ref: "#/components/schemas/PublishOptions" + + EgressThresholdOptions: + type: object + properties: + egressThresholds: + type: object + additionalProperties: + type: number + minimum: 0 + maximum: 1 + example: 0.9 + + PublishOptions: + type: object + properties: + publish: + type : object + properties: + egressUnknownDetections: + type: boolean + example: true + filterZeroDetections: + type: boolean + example: true diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index ce697552769f..97992f8553b9 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -35,6 +35,7 @@ docs/DefaultApi.md docs/Dog.md docs/DogAllOf.md docs/Drawing.md +docs/EgressThresholdOptions.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -82,6 +83,8 @@ docs/ParentPet.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PublishOptions.md +docs/PublishOptionsPublish.md docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md @@ -95,6 +98,7 @@ docs/SomeObject.md docs/SomeObjectWithSelfAttr.md docs/SpecialModelName.md docs/StoreApi.md +docs/StreamOptions.md docs/StringBooleanMap.md docs/StringEnum.md docs/StringEnumWithDefaultValue.md @@ -151,6 +155,7 @@ petstore_api/model/danish_pig.py petstore_api/model/dog.py petstore_api/model/dog_all_of.py petstore_api/model/drawing.py +petstore_api/model/egress_threshold_options.py petstore_api/model/enum_arrays.py petstore_api/model/enum_class.py petstore_api/model/enum_test.py @@ -195,6 +200,8 @@ petstore_api/model/order.py petstore_api/model/parent_pet.py petstore_api/model/pet.py petstore_api/model/pig.py +petstore_api/model/publish_options.py +petstore_api/model/publish_options_publish.py petstore_api/model/quadrilateral.py petstore_api/model/quadrilateral_interface.py petstore_api/model/read_only_first.py @@ -207,6 +214,7 @@ petstore_api/model/simple_quadrilateral.py petstore_api/model/some_object.py petstore_api/model/some_object_with_self_attr.py petstore_api/model/special_model_name.py +petstore_api/model/stream_options.py petstore_api/model/string_boolean_map.py petstore_api/model/string_enum.py petstore_api/model/string_enum_with_default_value.py @@ -225,4 +233,8 @@ setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_egress_threshold_options.py +test/test_publish_options.py +test/test_publish_options_publish.py +test/test_stream_options.py tox.ini diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 4eaa47c54ee2..f4ce37db621f 100644 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -166,6 +166,7 @@ Class | Method | HTTP request | Description - [Dog](docs/Dog.md) - [DogAllOf](docs/DogAllOf.md) - [Drawing](docs/Drawing.md) + - [EgressThresholdOptions](docs/EgressThresholdOptions.md) - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) @@ -210,6 +211,8 @@ Class | Method | HTTP request | Description - [ParentPet](docs/ParentPet.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PublishOptions](docs/PublishOptions.md) + - [PublishOptionsPublish](docs/PublishOptionsPublish.md) - [Quadrilateral](docs/Quadrilateral.md) - [QuadrilateralInterface](docs/QuadrilateralInterface.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) @@ -222,6 +225,7 @@ Class | Method | HTTP request | Description - [SomeObject](docs/SomeObject.md) - [SomeObjectWithSelfAttr](docs/SomeObjectWithSelfAttr.md) - [SpecialModelName](docs/SpecialModelName.md) + - [StreamOptions](docs/StreamOptions.md) - [StringBooleanMap](docs/StringBooleanMap.md) - [StringEnum](docs/StringEnum.md) - [StringEnumWithDefaultValue](docs/StringEnumWithDefaultValue.md) diff --git a/samples/openapi3/client/petstore/python/docs/EgressThresholdOptions.md b/samples/openapi3/client/petstore/python/docs/EgressThresholdOptions.md new file mode 100644 index 000000000000..d578b2836f3e --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/EgressThresholdOptions.md @@ -0,0 +1,12 @@ +# EgressThresholdOptions + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**egress_thresholds** | **{str: (float,)}** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[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/docs/PublishOptions.md b/samples/openapi3/client/petstore/python/docs/PublishOptions.md new file mode 100644 index 000000000000..2f654b33683b --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/PublishOptions.md @@ -0,0 +1,12 @@ +# PublishOptions + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**publish** | [**PublishOptionsPublish**](PublishOptionsPublish.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[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/docs/PublishOptionsPublish.md b/samples/openapi3/client/petstore/python/docs/PublishOptionsPublish.md new file mode 100644 index 000000000000..016c2745dff2 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/PublishOptionsPublish.md @@ -0,0 +1,13 @@ +# PublishOptionsPublish + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**egress_unknown_detections** | **bool** | | [optional] +**filter_zero_detections** | **bool** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[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/docs/StreamOptions.md b/samples/openapi3/client/petstore/python/docs/StreamOptions.md new file mode 100644 index 000000000000..4bb016c450e3 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/StreamOptions.md @@ -0,0 +1,13 @@ +# StreamOptions + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**egress_thresholds** | **{str: (float,)}** | | [optional] +**publish** | [**PublishOptionsPublish**](PublishOptionsPublish.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[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/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index e36e3b013121..b7a734978005 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -30,6 +30,7 @@ from petstore_api.model.enum_test import EnumTest from petstore_api.model.file_schema_test_class import FileSchemaTestClass from petstore_api.model.gm_fruit_no_properties import GmFruitNoProperties +from petstore_api.model.stream_options import StreamOptions from petstore_api.model.health_check_result import HealthCheckResult from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload from petstore_api.model.inline_object6 import InlineObject6 @@ -1533,6 +1534,54 @@ def __init__(self, api_client=None): }, api_client=api_client ) + self.tx_rx_all_of_model_endpoint = _Endpoint( + settings={ + 'response_type': (StreamOptions,), + 'auth': [], + 'endpoint_path': '/fake/TxRxAllOfModel', + 'operation_id': 'tx_rx_all_of_model', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'stream_options', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'stream_options': + (StreamOptions,), + }, + 'attribute_map': { + }, + 'location_map': { + 'stream_options': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client + ) self.upload_download_file_endpoint = _Endpoint( settings={ 'response_type': (file_type,), @@ -3759,6 +3808,79 @@ def tx_rx_any_of_model( kwargs['_request_auths'] = kwargs.get('_request_auths', None) return self.tx_rx_any_of_model_endpoint.call_with_http_info(**kwargs) + def tx_rx_all_of_model( + self, + **kwargs + ): + """tx_rx_any_of_model # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.tx_rx_any_of_model(async_req=True) + >>> result = thread.get() + Keyword Args: + stream_options (StreamOptions): [optional] + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _content_type (str/None): force body content-type. + Default is None and content-type will be predicted by allowed + content-types and body. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + _request_auths (list): set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + Default is None + async_req (bool): execute request asynchronously + Returns: + GmFruitNoProperties + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_spec_property_naming'] = kwargs.get( + '_spec_property_naming', False + ) + kwargs['_content_type'] = kwargs.get( + '_content_type') + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['_request_auths'] = kwargs.get('_request_auths', None) + return self.tx_rx_all_of_model_endpoint.call_with_http_info(**kwargs) + def upload_download_file( self, body, diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/egress_threshold_options.py b/samples/openapi3/client/petstore/python/petstore_api/model/egress_threshold_options.py new file mode 100644 index 000000000000..e4ba9523546a --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/egress_threshold_options.py @@ -0,0 +1,263 @@ +""" + 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 +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel +) +from petstore_api.exceptions import ApiAttributeError + + + +class EgressThresholdOptions(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 = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'egress_thresholds': ({str: (float,)},), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'egress_thresholds': 'egressThresholds', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """EgressThresholdOptions - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + egress_thresholds ({str: (float,)}): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', True) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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 kwargs.items(): + 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) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """EgressThresholdOptions - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + egress_thresholds ({str: (float,)}): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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 kwargs.items(): + 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) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/publish_options.py b/samples/openapi3/client/petstore/python/petstore_api/model/publish_options.py new file mode 100644 index 000000000000..1bcba6c3b88f --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/publish_options.py @@ -0,0 +1,269 @@ +""" + 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 +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel +) +from petstore_api.exceptions import ApiAttributeError + + +def lazy_import(): + from petstore_api.model.publish_options_publish import PublishOptionsPublish + globals()['PublishOptionsPublish'] = PublishOptionsPublish + + +class PublishOptions(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 = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'publish': (PublishOptionsPublish,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'publish': 'publish', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PublishOptions - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + publish (PublishOptionsPublish): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', True) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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 kwargs.items(): + 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) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """PublishOptions - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + publish (PublishOptionsPublish): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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 kwargs.items(): + 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) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/publish_options_publish.py b/samples/openapi3/client/petstore/python/petstore_api/model/publish_options_publish.py new file mode 100644 index 000000000000..e6231b2abff9 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/publish_options_publish.py @@ -0,0 +1,267 @@ +""" + 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 +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel +) +from petstore_api.exceptions import ApiAttributeError + + + +class PublishOptionsPublish(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 = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'egress_unknown_detections': (bool,), # noqa: E501 + 'filter_zero_detections': (bool,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'egress_unknown_detections': 'egressUnknownDetections', # noqa: E501 + 'filter_zero_detections': 'filterZeroDetections', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """PublishOptionsPublish - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + egress_unknown_detections (bool): [optional] # noqa: E501 + filter_zero_detections (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', True) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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 kwargs.items(): + 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) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """PublishOptionsPublish - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + egress_unknown_detections (bool): [optional] # noqa: E501 + filter_zero_detections (bool): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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 kwargs.items(): + 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) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/stream_options.py b/samples/openapi3/client/petstore/python/petstore_api/model/stream_options.py new file mode 100644 index 000000000000..0a6e6fc06c95 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/stream_options.py @@ -0,0 +1,328 @@ +""" + 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 +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel +) +from petstore_api.exceptions import ApiAttributeError + + +def lazy_import(): + from petstore_api.model.egress_threshold_options import EgressThresholdOptions + from petstore_api.model.publish_options import PublishOptions + from petstore_api.model.publish_options_publish import PublishOptionsPublish + globals()['EgressThresholdOptions'] = EgressThresholdOptions + globals()['PublishOptions'] = PublishOptions + globals()['PublishOptionsPublish'] = PublishOptionsPublish + + +class StreamOptions(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 = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'egress_thresholds': ({str: (float,)},), # noqa: E501 + 'publish': (PublishOptionsPublish,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'egress_thresholds': 'egressThresholds', # noqa: E501 + 'publish': 'publish', # noqa: E501 + } + + read_only_vars = { + } + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """StreamOptions - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + egress_thresholds ({str: (float,)}): [optional] # noqa: E501 + publish (PublishOptionsPublish): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_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, *args, **kwargs): # noqa: E501 + """StreamOptions - a model defined in OpenAPI + + 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 + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (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,) + egress_thresholds ({str: (float,)}): [optional] # noqa: E501 + publish (PublishOptionsPublish): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + 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, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") + + @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 because 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 + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + EgressThresholdOptions, + PublishOptions, + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index 170e786575f3..fd0b04c706cb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -40,6 +40,7 @@ from petstore_api.model.dog import Dog from petstore_api.model.dog_all_of import DogAllOf from petstore_api.model.drawing import Drawing +from petstore_api.model.egress_threshold_options import EgressThresholdOptions from petstore_api.model.enum_arrays import EnumArrays from petstore_api.model.enum_class import EnumClass from petstore_api.model.enum_test import EnumTest @@ -84,6 +85,8 @@ from petstore_api.model.parent_pet import ParentPet from petstore_api.model.pet import Pet from petstore_api.model.pig import Pig +from petstore_api.model.publish_options import PublishOptions +from petstore_api.model.publish_options_publish import PublishOptionsPublish from petstore_api.model.quadrilateral import Quadrilateral from petstore_api.model.quadrilateral_interface import QuadrilateralInterface from petstore_api.model.read_only_first import ReadOnlyFirst @@ -96,6 +99,7 @@ from petstore_api.model.some_object import SomeObject from petstore_api.model.some_object_with_self_attr import SomeObjectWithSelfAttr from petstore_api.model.special_model_name import SpecialModelName +from petstore_api.model.stream_options import StreamOptions from petstore_api.model.string_boolean_map import StringBooleanMap from petstore_api.model.string_enum import StringEnum from petstore_api.model.string_enum_with_default_value import StringEnumWithDefaultValue diff --git a/samples/openapi3/client/petstore/python/test/test_egress_threshold_options.py b/samples/openapi3/client/petstore/python/test/test_egress_threshold_options.py new file mode 100644 index 000000000000..04c4c46142f8 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_egress_threshold_options.py @@ -0,0 +1,35 @@ +""" + 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 +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.egress_threshold_options import EgressThresholdOptions + + +class TestEgressThresholdOptions(unittest.TestCase): + """EgressThresholdOptions unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEgressThresholdOptions(self): + """Test EgressThresholdOptions""" + # FIXME: construct object with mandatory attributes with example values + # model = EgressThresholdOptions() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_publish_options.py b/samples/openapi3/client/petstore/python/test/test_publish_options.py new file mode 100644 index 000000000000..819ff51bb7f4 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_publish_options.py @@ -0,0 +1,37 @@ +""" + 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 +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.publish_options_publish import PublishOptionsPublish +globals()['PublishOptionsPublish'] = PublishOptionsPublish +from petstore_api.model.publish_options import PublishOptions + + +class TestPublishOptions(unittest.TestCase): + """PublishOptions unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testPublishOptions(self): + """Test PublishOptions""" + # FIXME: construct object with mandatory attributes with example values + # model = PublishOptions() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_publish_options_publish.py b/samples/openapi3/client/petstore/python/test/test_publish_options_publish.py new file mode 100644 index 000000000000..1e848058661f --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_publish_options_publish.py @@ -0,0 +1,35 @@ +""" + 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 +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.publish_options_publish import PublishOptionsPublish + + +class TestPublishOptionsPublish(unittest.TestCase): + """PublishOptionsPublish unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testPublishOptionsPublish(self): + """Test PublishOptionsPublish""" + # FIXME: construct object with mandatory attributes with example values + # model = PublishOptionsPublish() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_stream_options.py b/samples/openapi3/client/petstore/python/test/test_stream_options.py new file mode 100644 index 000000000000..807e24596fff --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_stream_options.py @@ -0,0 +1,41 @@ +""" + 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 +""" + + +import sys +import unittest + +import petstore_api +from petstore_api.model.egress_threshold_options import EgressThresholdOptions +from petstore_api.model.publish_options import PublishOptions +from petstore_api.model.publish_options_publish import PublishOptionsPublish +globals()['EgressThresholdOptions'] = EgressThresholdOptions +globals()['PublishOptions'] = PublishOptions +globals()['PublishOptionsPublish'] = PublishOptionsPublish +from petstore_api.model.stream_options import StreamOptions + + +class TestStreamOptions(unittest.TestCase): + """StreamOptions unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testStreamOptions(self): + """Test StreamOptions""" + # FIXME: construct object with mandatory attributes with example values + # model = StreamOptions() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py b/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py index f9ac740e4ef7..3dbd56720400 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py @@ -747,5 +747,39 @@ def test_post_tx_rx_any_of_payload(self): assert isinstance(response, GmFruitNoProperties) assert model_to_dict(response) == expected_json_body + def test_post_tx_rx_all_of_payload(self): + """Test case for postInlineAdditionlPropertiesPayload + """ + from petstore_api.model.stream_options import StreamOptions + from petstore_api.model.publish_options_publish import PublishOptionsPublish + endpoint = self.api.tx_rx_all_of_model_endpoint + assert endpoint.openapi_types['stream_options'] == (StreamOptions,) + assert endpoint.settings['response_type'] == (StreamOptions,) + + # serialization + deserialization works + from petstore_api.rest import RESTClientObject, RESTResponse + with patch.object(RESTClientObject, 'request') as mock_method: + expected_json_body = { + "egressThresholds": { + "person":0.8 + }, + "publish": { + "egressUnknownDetections": False + } + } + stream_option_instance = StreamOptions(**expected_json_body) + mock_method.return_value = self.mock_response(expected_json_body) + + response = self.api.tx_rx_all_of_model(stream_options=stream_option_instance) + self.assert_request_called_with( + mock_method, + 'http://petstore.swagger.io:80/v2/fake/TxRxAllOfModel', + body=expected_json_body + ) + + assert isinstance(response, StreamOptions) + assert model_to_dict(response) == expected_json_body + assert response.publish == PublishOptionsPublish(**{"egress_unknown_detections": False}) + if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py b/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py index f95c07755f85..a0f97a4a97dc 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_fruit.py @@ -147,7 +147,7 @@ def test_banana_fruit(self): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit, banana_instance], + 'color': [fruit], 'length_cm': [fruit, banana_instance], } ) @@ -206,7 +206,7 @@ def test_apple_fruit(self): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit, apple_instance], + 'color': [fruit], 'cultivar': [fruit, apple_instance], } ) diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py b/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py index ad5907ee4436..4a803267db2a 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_gm_fruit.py @@ -110,7 +110,7 @@ def test_banana_fruit(self): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit, banana_instance], + 'color': [fruit], 'length_cm': [fruit, banana_instance], } ) @@ -153,7 +153,7 @@ def test_combo_fruit(self): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit, apple_instance, banana_instance], + 'color': [fruit], 'length_cm': [fruit, apple_instance, banana_instance], 'cultivar': [fruit, apple_instance, banana_instance], } @@ -204,7 +204,7 @@ def test_apple_fruit(self): self.assertEqual( fruit._var_name_to_model_instances, { - 'color': [fruit, apple_instance], + 'color': [fruit], 'cultivar': [fruit, apple_instance], 'origin': [fruit, apple_instance], }