Skip to content

Enums are not supported #220

@da1910

Description

@da1910

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

API models that use Enums are not supported properly at present, they present as strings and end up raising an assertion error.

  File "C:/git/demo.py", line 48, in <module>
    info_result = info_client.info_get()
  File "C:\git\openapi\api\info_api.py", line 101, in info_get
    (data) = self.info_get_with_http_info(**kwargs)  # noqa: E501
  File "C:\git\openapi\api\info_api.py", line 146, in info_get_with_http_info
    return self.api_client.call_api(
  File "C:\git\venv\lib\site-packages\ansys\openapi\common\_api_client.py", line 432, in call_api
    return self.__call_api(
  File "C:\git\venv\lib\site-packages\ansys\openapi\common\_api_client.py", line 183, in __call_api
    return_data = self.deserialize(response_data, response_type)
  File "C:\git\venv\lib\site-packages\ansys\openapi\common\_api_client.py", line 330, in deserialize
    return self.__deserialize(data, response_type)
  File "C:\git\venv\lib\site-packages\ansys\openapi\common\_api_client.py", line 377, in __deserialize
    return self.__deserialize_model(data, klass)
  File "C:\git\venv\lib\site-packages\ansys\openapi\common\_api_client.py", line 820, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
  File "C:\git\venv\lib\site-packages\ansys\openapi\common\_api_client.py", line 376, in __deserialize
    assert isinstance(data, dict)
AssertionError

We need to revisit the necessary fixes for MYPY to make sure that we're not being overzealous.

📝 Steps to reproduce

Generate a client with an enum property, calls to an endpoint that returns that model will fail with the given AssertionError above

💻 Which operating system are you using?

Windows

🐍 Which Python version are you using?

3.10

📦 Installed packages

altgraph==0.17
atomicwrites==1.4.0
attrs==21.2.0
ansys-openapi-common==1.1.0
colorama==0.4.4
future==0.18.2
importlib-metadata==3.4.0
JSON-minify==0.3.0
jsonschema==3.2.0
keyring==22.0.1
more-itertools==8.8.0
numpy==1.21.1
packaging==21.0
pandas==1.3.1
pefile==2021.5.24
pluggy==0.13.1
py==1.10.0
pyinstaller==4.5
pyinstaller-hooks-contrib==2021.3
pyparsing==3.0.9
pypiwin32==223
pyrsistent==0.18.0
python-dateutil==2.8.2
pytimeparse==1.1.8
pytz==2021.1
pywin32==301
pywin32-ctypes==0.2.0
setuptools==56.0.0
six==1.16.0
toml==0.10.2
wcwidth==0.2.5
zipp==3.5.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions