Skip to content

Conversation

terencehonles
Copy link
Contributor

This fixes the auto generated operation keys and operation ID. For list views which have a parameter in their last path segment.

@terencehonles terencehonles force-pushed the fix-list-views-not-identified-as-list-views branch from d664f9d to e2707c5 Compare March 14, 2025 11:07
@JoelLefkowitz JoelLefkowitz added bug Bug report 1.21.x Release target in 1.21.x labels Mar 17, 2025
@terencehonles terencehonles force-pushed the fix-list-views-not-identified-as-list-views branch from e2707c5 to e0a649d Compare March 19, 2025 13:50
@JoelLefkowitz
Copy link
Collaborator

Thanks for digging into this @terencehonles, looks really good. I'd like to have a unit test for this to validate the behaviour when there is and isn't a detail attribute before we merge. Could we also move the if method.lower() != "get": clause into the previous if statement so it's a little easier to follow?

@terencehonles terencehonles force-pushed the fix-list-views-not-identified-as-list-views branch from e0a649d to 0d6e382 Compare April 18, 2025 11:41
@terencehonles
Copy link
Contributor Author

terencehonles commented Apr 18, 2025

Thanks for digging into this @terencehonles, looks really good. I'd like to have a unit test for this to validate the behaviour when there is and isn't a detail attribute before we merge.

Isn't this what the reference schema is testing? I effectively fixed the test with https://github.com/axnsan12/drf-yasg/pull/917/files#diff-741bf237457101c6d297e385e111f8b5477fbbd9369c53a05c08c64e307d0e17

See:

  • path("views/<int:snippet_pk>/", views.SnippetViewerList.as_view()),
  • class SnippetViewerList(generics.ListAPIView):
    """SnippetViewerList classdoc"""
    serializer_class = SnippetViewerSerializer
    pagination_class = PageNumberPagination
    parser_classes = (FormParser, CamelCaseJSONParser, FileUploadParser)
    renderer_classes = (CamelCaseJSONRenderer,)
    swagger_schema = CamelCaseOperationIDAutoSchema
    lookup_url_kwarg = "snippet_pk"
    def get_object(self):
    queryset = Snippet.objects.all()
    # Perform the lookup filtering.
    lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
    filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
    obj = get_object_or_404(queryset, **filter_kwargs)
    # May raise a permission denied
    self.check_object_permissions(self.request, obj)
    return obj
    def get_queryset(self):
    return SnippetViewer.objects.filter(snippet=self.get_object())

The detail attribute comes from the viewset handling, and this is a view class.

Could we also move the if method.lower() != "get": clause into the previous if statement so it's a little easier to follow?

Done

@terencehonles terencehonles force-pushed the fix-list-views-not-identified-as-list-views branch from 0d6e382 to 984d59f Compare May 2, 2025 08:59
@terencehonles
Copy link
Contributor Author

@JoelLefkowitz I updated this to include the commit that fixed the CI

@terencehonles
Copy link
Contributor Author

Thanks for looking at the other PR and merging in master @JoelLefkowitz. It looks like this is still green, is there anything blocking merging this?

…views

This fixes the auto generated operation keys and operation ID. For list
views which have a parameter in their last path segment.
@terencehonles terencehonles force-pushed the fix-list-views-not-identified-as-list-views branch from 6e80809 to 0398e87 Compare July 22, 2025 13:16
@JoelLefkowitz
Copy link
Collaborator

Looks all good, thanks @terencehonles 🥳

@JoelLefkowitz JoelLefkowitz merged commit 2983251 into axnsan12:master Jul 22, 2025
9 checks passed
@terencehonles terencehonles deleted the fix-list-views-not-identified-as-list-views branch July 22, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.x Release target in 1.21.x bug Bug report
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants