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 I use swagger_auto_schema in generic views? #863

Open
lucascbenedet opened this issue Aug 10, 2023 · 1 comment
Open

Can I use swagger_auto_schema in generic views? #863

lucascbenedet opened this issue Aug 10, 2023 · 1 comment

Comments

@lucascbenedet
Copy link

I've noticed many examples using swagger_auto_schema only with api_views, and I'm encountering an error when attempting to use Swagger with generic views in the Django REST framework. Is there something I'm doing that isn't working, or am I making a mistake?

@Mubarisk
Copy link

class SampleView(GenericAPIView):
    @swagger_auto_schema(
        manual_parameters=[
            openapi.Parameter(
                name="start_date",
                in_=openapi.IN_QUERY,
                type=openapi.FORMAT_DATETIME,
                required=False,
            ),
            openapi.Parameter(
                name="end_date",
                in_=openapi.IN_QUERY,
                type=openapi.FORMAT_DATETIME,
                required=False,
            ),
        ]
    )
    def get(self, request, *args, **kwargs):
        return super().get(request, *args, **kwargs)

this is worked for me

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