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

drf-spectacular raises warnings about enums after 0.27 release #53

Closed
OttoAndrey opened this issue Dec 20, 2023 · 2 comments
Closed

drf-spectacular raises warnings about enums after 0.27 release #53

OttoAndrey opened this issue Dec 20, 2023 · 2 comments

Comments

@OttoAndrey
Copy link

OttoAndrey commented Dec 20, 2023

Hello! I use
Django==4.2.8
djangorestframework==3.14.0
drf-spectacular==0.27.0
drf-standardized-errors==0.12.6

settings from here

    "ENUM_NAME_OVERRIDES": {
        "ValidationErrorEnum": "drf_standardized_errors.openapi_serializers.ValidationErrorEnum.values",
        "ClientErrorEnum": "drf_standardized_errors.openapi_serializers.ClientErrorEnum.values",
        "ServerErrorEnum": "drf_standardized_errors.openapi_serializers.ServerErrorEnum.values",
        "ErrorCode401Enum": "drf_standardized_errors.openapi_serializers.ErrorCode401Enum.values",
        "ErrorCode403Enum": "drf_standardized_errors.openapi_serializers.ErrorCode403Enum.values",
        "ErrorCode404Enum": "drf_standardized_errors.openapi_serializers.ErrorCode404Enum.values",
        "ErrorCode405Enum": "drf_standardized_errors.openapi_serializers.ErrorCode405Enum.values",
        "ErrorCode406Enum": "drf_standardized_errors.openapi_serializers.ErrorCode406Enum.values",
        "ErrorCode415Enum": "drf_standardized_errors.openapi_serializers.ErrorCode415Enum.values",
        "ErrorCode429Enum": "drf_standardized_errors.openapi_serializers.ErrorCode429Enum.values",
        "ErrorCode500Enum": "drf_standardized_errors.openapi_serializers.ErrorCode500Enum.values",    
    },

but command

python3 manage.py spectacular --file .tmp/schema.yaml --validate --fail-on-warn

raises error

Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Type982Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.
Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Type566Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.

and I see next enums on open-api page
image

@ghazi-git
Copy link
Owner

I realized it last week when I was running tests against django 5. drf-spectacular has updated its postprocessing hook in the latest release and this package ships a customized copy of it. I took a quick look at it but couldn't figure out why this is happening, I'll need to spend more time to figure out what's going on.

In any case, thanks for opening the issue, this way it will be clear there is a known issue with drf-spectacular 0.27.0 and the solution is to use 0.26.5 to avoid the warnings (for now).

@TheSuperiorStanislav
Copy link
Contributor

@ghazi-git dee0073 didn't helped me

Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Type982Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.
Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Type21bEnum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.
Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Type566Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants