Repository navigation
Conversation
|
Hi @vdejager. Thanks for the input here. We actually decided against this kind of per-method adjustment for the We don't want to add a Rather the approach we considered was to allow passing a dictionary to specify fields on a per-method basis... It's then obvious that you'll end with repetition here. Looking at ways of handling this led to the decision to just handle the All Methods case, as the most common requirement. (The example we have in mind is adding an additional path or query parameter that is then used in The solution for your use-case is to subclass You are welcome to adjust how I would be open to a PR applying Extract Method to the django-rest-framework/rest_framework/schemas/inspectors.py Lines 184 to 188 in c63e35c This would allow easier customisation of the behaviour here. In general a PR will need to add tests covering the suggested change, have the test suite pass, and add relevant documentation. |
|
Ah, thanks.
Would it be possible to add a complete example to the documentation? Obviously there is a tradeoff between more code in the views or in the schema inspection.
|
|
@vdejager We've extracted the The docs there add an example of how you might handle branching on Since we're all still learning/developing the patterns here, I'm very happy to look at examples on the issue tracker here. |
Description
when adding a manual field to AutoSchema it appears on all methods of a Link objects.
When you add a 'body' parameter it ends up on the GET method of a link as well. (although allowed, normally GET requests do not do anything with body or form parameters and as such they do not show up in request.data
This pull request adds a check if a manual field specified a method to which it belongs.
i.e inside your endpoint view add:
This field will now only appear in a 'POST' Link
See the necessary patch in core-api as well core-api/python-client#147