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

Can't describe GET Method for detail, and list in APIView class based views. #75

Open
SzateX opened this issue Oct 24, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@SzateX
Copy link

SzateX commented Oct 24, 2020

Hi,

I have problem, and I didn't see way to annotate class which inheriting from API View, when get method for list and detail are merged together in one class. For example:

`
class CompanyView(APIView):
company_serializer_class = CompanySerializer
single_company_serializer_class = SingleCompanySerializer

def get(self, request, pk=None, format=None):
    if pk:
        serializer = self.get_single(request, pk, format)
    else:
        serializer = self.get_many(request, format)
    return Response(serializer.data, status=status.HTTP_200_OK)

@swagger_auto_schema(operation_description="GET /company/", responses={200: SingleCompanySerializer()})
def get_single(self, request, pk, format=None):
    company = Company.objects.get(id=pk)
    return self.single_company_serializer_class(company)

@swagger_auto_schema(operation_description="GET /company/{pk}/", responses={200: CompanySerializer(many=True)})
def get_many(self, request, format=None):
    companies = Company.objects.all()
    return self.company_serializer_class(companies, many=True)

`

I have tried, as you can see above, but there is no any update in swagger. When I move swagger_auto_schema decorator into get method, I get error that duplicated decorator applied.

Could you solve this problem?

@SzateX SzateX changed the title Can't descripe GET Method for detail, and list in APIView class based views. Can't describe GET Method for detail, and list in APIView class based views. Oct 24, 2020
@JoelLefkowitz JoelLefkowitz added bug Something isn't working Upstream Migrate issue to drf-yasg labels Oct 27, 2020
@JoelLefkowitz
Copy link
Owner

When you say there's no update in swagger are you getting anything listed for that view? Can you post a screenshot?

@JoelLefkowitz JoelLefkowitz removed the Upstream Migrate issue to drf-yasg label Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants