openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

TypeError when model default value is a list

Open maxbergmark opened this issue 2 years ago • 0 comments

Describe the bug When generating models for an API where a default argument is a list of enums, a TypeError is raised on this line:

return f"{prop.class_info.name}.{inverse_values[default]}"

A possible fix could be to explicitly check for this case. Below is a proposed fix, but I'm not familiar enough with the codebase to know whether this is a correct fix. However, I was able to parse the API docs correctly with this fix in place:

if type(default) is list:
    return [f"prop.class_info.name.inverse_values[d]" for d in default]
else:
    return f"{prop.class_info.name}.{inverse_values[default]}"

To Reproduce Steps to reproduce the behavior:

  1. Run openapi-python-client generate --url https://sand-docs.ilevelsolutions.eu/openapi.yaml
  2. See error

Expected behavior The API docs should be able to be parsed

OpenAPI Spec File https://sand-docs.ilevelsolutions.eu/openapi.yaml

Desktop (please complete the following information):

  • OS: macOS 13.1
  • Python Version: 3.10
  • openapi-python-client version: 0.13.1

maxbergmark avatar Jan 23 '23 15:01 maxbergmark