Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.4.1.dev11",
"regenerated": "2021-08-09 14:31:45.996631",
"spec_repo_commit": "f7db18b"
"regenerated": "2021-08-10 08:29:52.303572",
"spec_repo_commit": "9684c06"
},
"v2": {
"apigentools_version": "1.4.1.dev11",
"regenerated": "2021-08-09 14:32:10.644831",
"spec_repo_commit": "f7db18b"
"regenerated": "2021-08-10 08:30:15.608867",
"spec_repo_commit": "9684c06"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
value, required_types_mixed, path_to_item, self._spec_property_naming,
self._check_type, configuration=self._configuration)
if (name,) in self.allowed_values:
check_allowed_values(
self.allowed_values,
(name,),
value
)
try:
check_allowed_values(self.allowed_values, (name,), value)
except ApiValueError:
self.__dict__["_data_store"][name] = value
self._unparsed = True
return
if (name,) in self.validations:
check_validations(
self.validations,
Expand All @@ -49,3 +50,5 @@
self._configuration
)
self.__dict__['_data_store'][name] = value
if isinstance(value, OpenApiModel) and value._unparsed:
self._unparsed = True
58 changes: 45 additions & 13 deletions .generator/templates/model_utils.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class OpenApiModel(object):
self._path_to_item = _path_to_item
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
self._unparsed = False

@classmethod
def _from_openapi_data(cls, kwargs):
Expand Down Expand Up @@ -396,6 +397,7 @@ class ModelSimple(OpenApiModel):
'_path_to_item',
'_configuration',
'_visited_composed_classes',
'_unparsed',
])

{{> model_templates/methods_setattr_getattr_normal }}
Expand All @@ -414,6 +416,7 @@ class ModelNormal(OpenApiModel):
'_path_to_item',
'_configuration',
'_visited_composed_classes',
'_unparsed',
])

{{> model_templates/methods_setattr_getattr_normal }}
Expand Down Expand Up @@ -484,6 +487,7 @@ class ModelComposed(OpenApiModel):
'_composed_instances',
'_var_name_to_model_instances',
'_additional_properties_model_instances',
'_unparsed',
])

def __init__(self, kwargs):
Expand Down Expand Up @@ -1654,21 +1658,12 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
constant_kwargs['_check_type'],
configuration=constant_kwargs['_configuration']
)
oneof_instances.append(oneof_instance)
if not oneof_instance._unparsed:
oneof_instances.append(oneof_instance)
except Exception:
pass
if len(oneof_instances) == 0:
raise ApiValueError(
"Invalid inputs given to generate an instance of %s. None "
"of the oneOf schemas matched the input data." %
cls.__name__
)
elif len(oneof_instances) > 1:
raise ApiValueError(
"Invalid inputs given to generate an instance of %s. Multiple "
"oneOf schemas matched the inputs, but a max of one is allowed." %
cls.__name__
)
if len(oneof_instances) != 1:
return UnparsedObject(**model_kwargs)
return oneof_instances[0]


Expand Down Expand Up @@ -1822,3 +1817,40 @@ def validate_get_composed_info(constant_args, model_args, self):
additional_properties_model_instances,
discarded_args
]


class UnparsedObject(ModelNormal):
"""A model for an oneOf we don't know about."""

allowed_values = {}

validations = {}

additional_properties_type = None

_nullable = False

openapi_types = {}

discriminator = None

attribute_map = {}

_composed_schemas = {}

required_properties = set(
[
"_data_store",
"_unparsed",
]
)

@convert_js_args_to_python_args
def __init__(self, **kwargs):

self._data_store = {}
self._unparsed = True

for var_name, var_value in kwargs.items():
self.__dict__[var_name] = var_value
self.__dict__["_data_store"][var_name] = var_value
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ exclude = tests
where=src

[tool:pytest]
addopts = --cov=datadog_api_client --cov-config .coveragerc
# addopts = --black --cov=datadog_api_client --cov-config .coveragerc --cov-report=term-missing

[flake8]
Expand Down
65 changes: 53 additions & 12 deletions src/datadog_api_client/v1/model_utils.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 53 additions & 12 deletions src/datadog_api_client/v2/model_utils.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def pytest_bdd_apply_tag(tag, function):
if not _disable_recording():
# ignore integration-only scenarios if the recording is enabled
skip_tags.add("integration-only")
if os.getenv("RECORD", "false").lower() != "false":
skip_tags.add("replay-only")
if tag in skip_tags:
marker = pytest.mark.skip(reason=f"skipped because '{tag}' in {skip_tags}")
marker(function)
Expand Down
Loading