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

DjangoQLSchemaSerializer in drf Viewsets #102

Open
joenatan opened this issue Jan 23, 2023 · 1 comment
Open

DjangoQLSchemaSerializer in drf Viewsets #102

joenatan opened this issue Jan 23, 2023 · 1 comment

Comments

@joenatan
Copy link

Thanks for the awesome package!

How can I map the introspection endpoint in drf (Django Rest Framework)?

My idea would be like this:
/api/v1//introspect/

I have now implemented this with an endpoint action in my viewset:

    @action(detail=False, methods=['get'])
    def introspect(self, request):
        return Response(DjangoQLSchema(MyModel).as_dict())

But a deprecated warning appears that I should use DjangoQLSchemaSerializer. But how?

DjangoQLSchemaSerializer.serialize(MyModel)

Doesn't work.

Thanks for your help

@stebunovd
Copy link
Member

Hi @joenatan,

You can find an example in the docs. See the Using completion widget outside of Django admin section in the readme, and there will be a code sample for views.py that shows how to use DjangoQLSchemaSerializer:

introspections = DjangoQLSchemaSerializer().serialize(DjangoQLSchema(MyModel))

Thanks,

Denis

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