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
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
An enum v2SortDirection is defined with default value "SORT_DIRECTION_UNSPECIFIED". Another schema v2SortField has a direction field with this type. In the generated Python model, where the default value for the field is defined, the SORT_DIRECTION_ prefix is stripped off:
The default value should be V2SortDirection.SORT_DIRECTION_UNSPECIFIED, not V2SortDirection.UNSPECIFIED. This results in an AttributeError: UNSPECIFIED when the package is imported.
This doesn't appear to be because the prefix is (almost) the same as the Enum name, changing it to "SOME_OTHER_PREFIX_UNSPECIFIED" gives the same result.
Then using a $ref to refer to an enum (with a default value) the default value is not applied for the Python generators. The default value is applied if it is an inline enum.
They don't provide example output, but it seems like the problem was that the default value was not generated at all, not that it was wrong. That was resolved by #18796, it's possible the error is there.
Suggest a fix
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
An enum
v2SortDirection
is defined with default value"SORT_DIRECTION_UNSPECIFIED"
. Another schemav2SortField
has adirection
field with this type. In the generated Python model, where the default value for the field is defined, theSORT_DIRECTION_
prefix is stripped off:The default value should be
V2SortDirection.SORT_DIRECTION_UNSPECIFIED
, notV2SortDirection.UNSPECIFIED
. This results in anAttributeError: UNSPECIFIED
when the package is imported.This doesn't appear to be because the prefix is (almost) the same as the Enum name, changing it to
"SOME_OTHER_PREFIX_UNSPECIFIED"
gives the same result.openapi-generator version
7.10.0 (Docker)
OpenAPI declaration file content or url
Minimal subset of the NCBI datasets API:
Generation Details
Using the
openapitools/openapi-generator-cli
docker image (7.10.0) with-g python
, all default options.Steps to reproduce
(previous section)
Related issues/PRs
Possibly #18843:
They don't provide example output, but it seems like the problem was that the default value was not generated at all, not that it was wrong. That was resolved by #18796, it's possible the error is there.
Suggest a fix
The text was updated successfully, but these errors were encountered: