Comments (7)
@Dean-Christian-Armada Did you solve this?
from django-rest-framework-docs.
Actually no, I switched to class-based views
from django-rest-framework-docs.
Ok. I imagine as there is not a serializers_class
decorator, neither a property that can be extracted from function based views, it's not possible get the fields description
from django-rest-framework-docs.
Exactly, besides I found out that the class-based view is much better
from django-rest-framework-docs.
I am working with the DRF and got struck at this point. I am using fuction based views , and I am not getting the details of input parameters in API doc page. Please help on this one , if someone came across it.
from django-rest-framework-docs.
@niscp have you found a solution ?
from django-rest-framework-docs.
So, if you are using a decorator like @api_view
, the pattern.callback
in rest_framework_docs.api_endpoint.py
will not be api_section
as you might suspect. But the callable api_view
which apparently doesn't contain a docstring.
So there is a way to get a docstring out of api_view
function however. It is written here:
http://stackoverflow.com/questions/1782843/python-decorator-handling-docstrings
Basically you need to rewrite api_view
in that way that it will contain a decorator functools.wraps()
which will update the attrs of the decorator.
like so:
from functools import wraps
def decorator(f):
@wraps(f)
def _decorator():
print 'decorator active'
f()
return _decorator
@decorator
def foo():
'''the magic foo function'''
print 'this is function foo'
help(foo)
from django-rest-framework-docs.
Related Issues (20)
- Muliple line doc strings appearing as one HOT 6
- Show field of nested serializers in Live API Endpoints HOT 3
- Decorator to show fields for api views
- Can't figure out how to enter data in ListField and DictField.
- It is possible to listing param in comment section of API?
- Does it support function based views?
- DRF docs not taking the data fields HOT 1
- get_serializer_class doesn't recreate same conditions as would be used by DRF HOT 1
- Its not working with viewset HOT 2
- doesn't support read_only_fields in serializer
- DRFDocs not showing delete, post, etc. options but regular docs do? HOT 7
- Hide OPTIONS method?
- Django 2.0 Support HOT 16
- Override template
- Error in import HOT 5
- RegexURLPattern and RegexURLResolver must be changed to URLPattern and URLResolver respectively
- api_endpoint __get_permissions_class__ missing __name__
- ModuleNotFoundError: No module named 'django.core.urlresolvers' error HOT 4
- Need to add token field in header
- from django.conf.urls import url
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rest-framework-docs.