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

Errors & warnings on opening Swagger UI #829

Open
koeaw opened this issue May 13, 2024 · 4 comments
Open

Errors & warnings on opening Swagger UI #829

koeaw opened this issue May 13, 2024 · 4 comments

Comments

@koeaw
Copy link
Contributor

koeaw commented May 13, 2024

The Swagger UI page/API view (.../apis/swagger/schema/swagger-ui/) prints a number of errors and warnings to the console.

I'm copy/pasteing them here for reference (without further analysis):

/PATH/TO/DIR/apis-instance-frischmuth/apis_core/generic/api_views.py: Error [ModelViewSet]: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'ModelViewSet' object has no attribute 'model')
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/generic/api_views.py: Warning [ModelViewSet]: could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:id>) or annotating the parameter type with @extend_schema. Defaulting to "string".
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/core/views.py: Error [Dumpdata]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/api_routers.py: Warning [GenericVersiontemptripleViewSet]: Failed to obtain model through view's queryset due to raised exception. Prevent this either by setting "queryset = Model.objects.none()" on the view, checking for "getattr(self, "swagger_fake_view", False)" in get_queryset() or by simply using @extend_schema. (Exception: 'Manager' object has no attribute 'filter_for_user')
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/api_routers.py: Warning [GenericVersiontemptripleViewSet]: could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:id>) or annotating the parameter type with @extend_schema. Defaulting to "string".
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/apis_entities/api_views.py: Error [GetOrCreateEntity]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/apis_entities/serializers_generic.py: Warning [GetEntityGeneric > EntitySerializer]: unable to resolve type hint for function "add_url". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [GenericHistoryLog > HistoryObjectSerializer]: unable to resolve type hint for function "get_history". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [GenericHistoryLog > HistoryObjectSerializer]: unable to resolve type hint for function "get_instance". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/api_views.py: Warning [EntityHistoryLogs]: Failed to obtain model through view's queryset due to raised exception. Prevent this either by setting "queryset = Model.objects.none()" on the view, checking for "getattr(self, "swagger_fake_view", False)" in get_queryset() or by simply using @extend_schema. (Exception: 'NoneType' object has no attribute 'model_class')
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [EntityHistoryLogs > HistoryLogSerializer]: unable to resolve type hint for function "get_diff". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [EntityHistoryLogs > HistoryLogSerializer]: unable to resolve type hint for function "get_action". Consider using a type hint or @extend_schema_field. Defaulting to string.
Warning: operationId "apis_api_retrieve" has collisions [('/apis/api/{contenttype}/', 'get'), ('/apis/api/{contenttype}/{id}/', 'get')]. resolving with numeral suffixes.
@b1rger
Copy link
Contributor

b1rger commented May 16, 2024

Can you check if this is resolved with the latest apis-core? The old API was removed, so those warnings should be gone

@koeaw
Copy link
Contributor Author

koeaw commented May 16, 2024

Some are gone, but some remain, and I'm getting new ones now, too.

Split up for readability:

apis_core/core:

/PATH/TO/DIR/apis-instance-frischmuth/apis_core/core/views.py: Error [Dumpdata]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.

apis_core/apis_entities:

/PATH/TO/DIR/apis-instance-frischmuth/apis_core/apis_entities/api_views.py: Error [GetEntityGeneric]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.

apis_core/history:

/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [GenericHistoryLog > HistoryObjectSerializer]: unable to resolve type hint for function "get_history". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [GenericHistoryLog > HistoryObjectSerializer]: unable to resolve type hint for function "get_instance". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/api_views.py: Warning [EntityHistoryLogs]: Failed to obtain model through view's queryset due to raised exception. Prevent this either by setting "queryset = Model.objects.none()" on the view, checking for "getattr(self, "swagger_fake_view", False)" in get_queryset() or by simply using @extend_schema. (Exception: 'NoneType' object has no attribute 'model_class')
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [EntityHistoryLogs > HistoryLogSerializer]: unable to resolve type hint for function "get_diff". Consider using a type hint or @extend_schema_field. Defaulting to string.
/PATH/TO/DIR/apis-instance-frischmuth/apis_core/history/serializers.py: Warning [EntityHistoryLogs > HistoryLogSerializer]: unable to resolve type hint for function "get_action". Consider using a type hint or @extend_schema_field. Defaulting to string.

New warnings which originate from django_filters/filterset.py:

For classes in APIS Core:

/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > TripleFilterSet]: Unable to guess choice types from values, filter method's type hint or find "subj_class" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > TripleFilterSet]: Unable to guess choice types from values, filter method's type hint or find "obj_class" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > TempTripleFilterSet]: Unable to guess choice types from values, filter method's type hint or find "subj_class" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > TempTripleFilterSet]: Unable to guess choice types from values, filter method's type hint or find "obj_class" in model. Defaulting to string.

For entity classes in my models – looks like there is one (identical one) per model class:

/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > WorkFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > ExpressionFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > ArchiveFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > PhysicalObjectFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > PersonFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > OrganisationFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > MetaCharacterFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > CharacterFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > PlaceFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > TopicFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > ResearchPerspectiveFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > InterpretatemFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.
/PATH/TO/VENV/lib/python3.11/site-packages/django_filters/filterset.py: Warning [ModelViewSet > WorkTypeFilterSet]: Unable to guess choice types from values, filter method's type hint or find "related_property" in model. Defaulting to string.

@koeaw
Copy link
Contributor Author

koeaw commented May 16, 2024

Tested with local copy of APIS Core on latest main branch, on latest Frischmuth deploy branch.

@koeaw
Copy link
Contributor Author

koeaw commented May 16, 2024

But I guess it's possible those latter errors are unrelated and due to something that changed in Frischmuth between then and now. (?!)

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

2 participants