Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when model default value is a list #721

Open
maxbergmark opened this issue Jan 23, 2023 · 0 comments
Open

TypeError when model default value is a list #721

maxbergmark opened this issue Jan 23, 2023 · 0 comments
Labels
🐞bug Something isn't working

Comments

@maxbergmark
Copy link

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 maxbergmark added the 🐞bug Something isn't working label Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant