You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide an easy way to document query params for detail_routes #5382
There does not seem to be an easy way to document query parameters for a detail
view.
Would it be feasible to support something like a input_serializer_class
argument, from where CoreAPI Link Fields (with query for the "Query
Parameters" used in docs/link.html) could be derived from?
This could then even set validated_data on the request (or pass a new
argument for/with it)?
Given that you're using @detail_route you'll need to inspect self.view.action to determine when to add the extra fields.
I'm not sure about your other points. I'm inclined to think that whatever machinery would be needed to drop the two lines — and go straight to request.validated_data — would not be worth it. I quite like that you explicitly create the serialiser and call is_valid()...
Is generating query parameter documentation in the documentation anywhere? I feel like the 'Documenting your API' page is pretty sparse on details or examples. If an example of what it takes for query parameter documentation to be generated was provided, that would be fantastic.
Reacted by Daniel Hahler, brianjsw, Juan Medina, Olof Haglund, valerpok, Sergey Kozlovskiy, Bo Shepelinski, Jeancarlo Barrios, Yi, Keoni Mahelona and 51 more
Activity
carltongibson commentedon Sep 29, 2017
From v3.7 you'll be able to subclass
AutoSchemaon your view to customise theLinkgeneration.You can either override
get_linkdirectly (callingsuperI guess) or any of theget_X_fieldsmethods, as you see fit:django-rest-framework/rest_framework/schemas/inspectors.py
Lines 165 to 169 in 5c2290d
Given that you're using
@detail_routeyou'll need to inspectself.view.actionto determine when to add the extra fields.I'm not sure about your other points. I'm inclined to think that whatever machinery would be needed to drop the two lines — and go straight to
request.validated_data— would not be worth it. I quite like that you explicitly create the serialiser and callis_valid()...JoshAddington commentedon Jan 26, 2018
Is generating query parameter documentation in the documentation anywhere? I feel like the 'Documenting your API' page is pretty sparse on details or examples. If an example of what it takes for query parameter documentation to be generated was provided, that would be fantastic.