-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Serializer Examples #640
Comments
Might be a duplicate of #595 ! |
If this can help, I implemented a quick and dirty solution to this: https://github.com/N1ark/drf-spectacular. From what I understood (I am really new to this codebase), what happens (or rather, what doesn't) is that there is no actual example generation for endpoints when none is specified. So by default, the Swagger/Redoc view will generate an example from the information it has on the content of the response's schema. However adding an example will add it directly to the OA3 Right now my solution was just to obtain the paginated schema (passing an empty If you're interested I'd be happy to clean up the solution a bit, and make a PR :) |
Hey @N1ark, thanks for having a try at this. Please open a PR to make this easier to talk about, even if we end up not using it. I'll try to look into it very soon. |
Done, #641 ! Thanks for the quick reply :) |
@N1ark so thanks again for coming up with the concept. I basically reused it but accounted for several edge cases you were probably not aware of.
glad this issue is finally resolved 🚀 |
closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up. |
Describe the bug
Decorating a serializer with
@extend_schema_serializer
and example(s) removes pagination from the example.To Reproduce
Expected behavior
I would expect the generated documentation to show the example provided for the serializer (
{'user': 123}
) in the paginated display:Instead, the example of the serializer seems to also override the paginated display:
The paginated response only appears when no example is provided, and the example overrides the paginated response, rather than only the content of
"results"
.The text was updated successfully, but these errors were encountered: