You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Similar to #357, partially fixed in #500.
Client generation fails if an enum like below is present in the generated OpenAPI schema.
NullEnum:
enum:
- null
The context here is that we have a Django model with char / text fields that have null=True, blank=True set. We use Django Rest Framework / drf-spectacular to generate an OpenAPI schema from our models and REST API endpoints. This generated schema automatically includes logic like below:
NullEnum accepts a literal null / None, not a string "null" (it's not a string enum).
To Reproduce
Steps to reproduce the behavior:
Make a new OpenAPI Spec File matching the one below.
Run "openapi-python-client generate --path your_spec_file.yaml"
See an error that null / None is not allowed.
Expected behavior
API client generation succeeds. An enum with None / null as an option is valid based on #500 (comment), so we would like to see this supported in openapi-python-client if easily possible.
In version 0.10.4, we were able to generate the clients successfully by changing the enum_property.py file. If value was None / not a string, it would skip calling remove_string_escapes(value) and just store None directly into output[sanitized_key].
Desktop (please complete the following information):
OS: Linux 4.18
Python Version: 3.6.8
openapi-python-client version 0.10.5
Additional context
Error(s) encountered while generating, client was not created
Failed to parse OpenAPI document
3 validation errors for OpenAPI
components -> schemas -> NullEnum -> $ref
field required (type=value_error.missing)
components -> schemas -> NullEnum -> enum -> 0
none is not an allowed value (type=type_error.none.not_allowed)
components -> schemas -> NullEnum -> enum -> 0
none is not an allowed value (type=type_error.none.not_allowed)
The text was updated successfully, but these errors were encountered:
Describe the bug
Similar to #357, partially fixed in #500.
Client generation fails if an enum like below is present in the generated OpenAPI schema.
The context here is that we have a Django model with char / text fields that have null=True, blank=True set. We use Django Rest Framework / drf-spectacular to generate an OpenAPI schema from our models and REST API endpoints. This generated schema automatically includes logic like below:
FieldNameEnum, BlankEnum, and NullEnum are like below:
NullEnum accepts a literal null / None, not a string "null" (it's not a string enum).
To Reproduce
Steps to reproduce the behavior:
Expected behavior
API client generation succeeds. An enum with None / null as an option is valid based on #500 (comment), so we would like to see this supported in openapi-python-client if easily possible.
In version 0.10.4, we were able to generate the clients successfully by changing the enum_property.py file. If value was None / not a string, it would skip calling remove_string_escapes(value) and just store None directly into output[sanitized_key].
OpenAPI Spec File
Desktop (please complete the following information):
Additional context
Error(s) encountered while generating, client was not created
Failed to parse OpenAPI document
3 validation errors for OpenAPI
components -> schemas -> NullEnum -> $ref
field required (type=value_error.missing)
components -> schemas -> NullEnum -> enum -> 0
none is not an allowed value (type=type_error.none.not_allowed)
components -> schemas -> NullEnum -> enum -> 0
none is not an allowed value (type=type_error.none.not_allowed)
The text was updated successfully, but these errors were encountered: