manosim / manosim/django-rest-framework-docs

Decorator to show fields for api views

Open
#161 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
641
Forks
178
PR merge metrics
No merged PRs in 30d

Description

I have a api view. I want to show fields in docs. Do we need a decorator to show fields in docs?

```
@api_view(['POST'])
@permission_classes((AllowAny, ))
@throttle_classes([AnonRateThrottle])
@api.doc(fields={'email': 'CharField', 'password':'CharField'})
def change_password(request):
signed_email = request.data.get('email', '')
password = request.data.get('password', '')

try:
email = loads(urlunquote(signed_email))
except BadSignature:
return Response(status=status.HTTP_400_BAD_REQUEST)

if len(password) < 6:
return Response(status=status.HTTP_400_BAD_REQUEST)

if not User.objects.filter(username=email):
return Response(status=status.HTTP_404_NOT_FOUND)

user = User.objects.get(username=email)
user.set_password(password)
user.save()

return Response(status=status.HTTP_200_OK)
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the @api_view and @api.doc(fields=...) usage shown in the issue, then inspect the existing API documentation behavior for function-based views. Define how the fields should appear in generated docs and add coverage for the expected result; the issue is done when those fields are documented correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
api, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.