Not being able to represent array serializer in get_serializer_class so OpenAPI schema is generated nicely #8109
Unanswered
hnykda
asked this question in
Question & Answer
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey (copied from here as I didn't notice the info about starting a discussion first).
I want an endpoint that returns simple array of items of type Log. I am aware that when initializing that, I should use
many=True
. But to also nicely generate the docs, I want to somehow represent that inget_serializer_class
:But how should I do it given that it needs to return the class def, not its instance? If I try to return
ListSerializer(child=LogSerializer)
it complains about child not being initialized and when I do initialize it, then it complains aboutListSerializer object not callable
.The only workaround I found is to do:
but then I have a useless
results
key in the response.Beta Was this translation helpful? Give feedback.
All reactions