Skip to content

compare Field.method to the Link method in AutoSchema manual fields #5621

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion rest_framework/schemas/inspectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def __init__(self, manual_fields=None):

* `manual_fields`: list of `coreapi.Field` instances that
will be added to auto-generated fields, overwriting on `Field.name`
if the link method matches the manual field method.
"""

self._manual_fields = manual_fields
Expand All @@ -184,7 +185,14 @@ def get_link(self, path, method, base_url):
if self._manual_fields is not None:
by_name = {f.name: f for f in fields}
for f in self._manual_fields:
by_name[f.name] = f

try:
if method in f.method:
by_name[f.name] = f
except AttributeError:
by_name[f.name] = f
warnings.warn('coreapi.Field has no attribute "method", please update coreapi')

fields = list(by_name.values())

if fields and any([field.location in ('form', 'body') for field in fields]):
Expand Down