Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Method docstrings not included in generated docs #537

Closed
jwineinger opened this issue Aug 23, 2016 · 13 comments
Closed

Method docstrings not included in generated docs #537

jwineinger opened this issue Aug 23, 2016 · 13 comments

Comments

@jwineinger
Copy link

I recently upgraded from 0.3.5 to 2.0.4. Previously, docstrings on view methods (MyView.get) would be included in the swagger generated docs, but with the new version I don't get any docs included. It does seem to introspect serializer fields and such, but the docstrings help users of the API understand what an endpoint does and when to use it. Is there any way to get those included with the current release?

@jwineinger
Copy link
Author

Looks like django-rest-framework doesn't support it yet =P

encode/django-rest-framework#4241

Add descriptions to schema generation, and document use of describe.

@tawanda
Copy link

tawanda commented Aug 23, 2016

I also have this problem, the old version of rest swagger imported doc strings, and also showed dictionaries in the doc string nicely formatted, Is there an option to manually include them?

@NickStefan
Copy link

Also looking for a solution

@tomatotiger
Copy link

I also have this problem

@alexmicrosrv
Copy link

Also the same problem. But when I make a GET request with the DRF API, docstrings appear on top of the result page.
So it's a posible django-rest-swagger problem ?

@blurrcat
Copy link

It seems this project has nothing to do with the problem. The schema generation part is now(restframework 3.4+) done by restframework and this project merely uses generated coreapi objects to render swagger.json.

@jwineinger
Copy link
Author

This project will have to implement it with DRF supports it. I did a quick hack to my local DRF to include the docstrings, verified that they are output in the XHR request, but did not appear in the django-rest-swagger front-end.

@blurrcat
Copy link

As a quick workaround, try the following:

class SchemaGenerator(schemas.SchemaGenerator):
    def get_link(self, path, method, callback, view):
        # link is an instance of `coreapi.Link`
        link = super(
            SchemaGenerator, self).get_link(path, method, callback, view)
        action = self.get_action(path, method, callback)
        func = getattr(view, action, None)
        if func:
            link._description = func.__doc__
        return link

@jwineinger
Copy link
Author

jwineinger commented Aug 24, 2016

Yeah, that was the quick hack I did. Seems like something similar to this could be used to workaround #536 as well. Seems like swagger uses the "tags" list that is output so we'd just need to munge that a bit

@paulosuzart
Copy link

I think it also doesn't support the Generic Views doc strings.

@c-bata
Copy link

c-bata commented Sep 9, 2016

@paulosuzart Yeah, that's right.
It requires a further discussion on django-rest-framework repository.
encode/django-rest-framework#4444

@abondar
Copy link

abondar commented Sep 15, 2016

@paulosuzart For generic views you can see my attempt in encode/django-rest-framework#4444

@marcgibbons
Copy link
Owner

Docstring introspection is now provided in DRF 3.5+. Closing out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants