Giter Site home page Giter Site logo

Comments (7)

jsangilve avatar jsangilve commented on May 20, 2024

@Dean-Christian-Armada Did you solve this?

from django-rest-framework-docs.

Dean-Christian-Armada avatar Dean-Christian-Armada commented on May 20, 2024

Actually no, I switched to class-based views

from django-rest-framework-docs.

jsangilve avatar jsangilve commented on May 20, 2024

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.

Dean-Christian-Armada avatar Dean-Christian-Armada commented on May 20, 2024

Exactly, besides I found out that the class-based view is much better

from django-rest-framework-docs.

niscp avatar niscp commented on May 20, 2024

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.

EssaAlshammri avatar EssaAlshammri commented on May 20, 2024

@niscp have you found a solution ?

from django-rest-framework-docs.

dmussaku avatar dmussaku commented on May 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.