-
Notifications
You must be signed in to change notification settings - Fork 304
Description
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Linux executable
Client library/SDK language
Python
Describe the bug
I am trying to generate a library for https://developer.sophos.com/docs/endpoint-v1/1/overview
What I'm finding is that the generated python is creating invalid dataclasses for query parameters that include enums. For example in the api yaml:
- in: query
name: healthStatus
description: Find endpoints by health status.
style: form
explode: false
required: false
schema:
type: array
items:
type: string
enum:
- bad
- good
- suspicious
- unknown
Creates a parameter in dataclass:
# Find endpoints by health status.
health_status: list[GetHealthStatusQueryParameterType] = []
Which causes the error:
Exception has occurred: ValueError
mutable default <class 'list'> for field health_status is not allowed: use default_factory
I don't really see a way to fix this without editing the generated code. I'm assuming it should be wrapped with Optional[] since it's an optional value.
Expected behavior
I should be able to run a get() without running into the "Exception has occurred: ValueError
mutable default <class 'list'> for field health_status is not allowed: use default_factory" Error.
How to reproduce
Generate for python using the attached yaml.
See endpoints/endpoints_request_builder.py
Open API description file
openapi-yaml-client-generated.zip
Kiota Version
1.24.1
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
- OS: MacOS
- Arm64
Debug output
Click to expand log
```</details>
### Other information
_No response_
Metadata
Metadata
Assignees
Labels
Type
Projects
Status