Skip to content

TypeError when model default value is a list #721

Open
@maxbergmark

Description

@maxbergmark

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

Metadata

Metadata

Assignees

No one assigned

    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