Coder Social home page Coder Social logo

django-rest-framework-docs's Issues

"Expected string or buffer" bug

Immediately after following configuration instructions, I tried loading the main page, but encountered the following error screen.

rest_framework version: 2.3.4

TypeError at /
expected string or buffer
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value:
expected string or buffer
Exception Location: /usr/lib/python2.7/re.py in sub, line 151
Python Executable: /usr/bin/python
Python Version: 2.7.4
Python Path:
['/home/alex/workspace/Masters/Fingerprints_django',
'/home/alex/workspace/Masters/Fingerprints_django',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
Server time: Wed, 5 Jun 2013 18:00:15 +1000

Add support for ViewSets

django-rest-framework-docs can't see ViewSet classes because they don't inherit from APIView.
It would be great to generate the doc from the methods marked with @link and @action

Request not sent via https

When i send a request from https site, the request URL is generated with http protocol and browser doesn't execute it, because mixing content is depricated. How can i solve this?

Thank you.

Add an option to filter api urls in DocumentGenerator

Maybe using django url namespace? It could be parameter of .get_docs method. It would be nice feature to have separate docs for different versions of API and I think that using different namespaces for different API versions is good way to achieve this.

There could be also other kinds of filters e.g. regex.

request attribute is not set in views

request attribute is not set in views while generating documentation so if you some custom methods accessing self.request it raises an AttributeError:
'MyAPIView' object has no attribute 'request'.

In my project, I access self.request overriding get_serializer_class and I have the following stacktrace:

Traceback:
File "[...]/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "[...]/local/lib/python2.7/site-packages/rest_framework_docs/views.py" in documentation
  7.     docs = DocumentationGenerator().get_docs(as_objects=True)
File "[...]/local/lib/python2.7/site-packages/rest_framework_docs/docs.py" in get_docs
  36.         docs = self.__process_urlpatterns()
File "[...]/local/lib/python2.7/site-packages/rest_framework_docs/docs.py" in __process_urlpatterns
  128.             doc.fields = self.__get_serializer_fields__(callback)
File "[...]/local/lib/python2.7/site-packages/rest_framework_docs/docs.py" in __get_serializer_fields__
  220.             serializer = callback().get_serializer_class()
File "[...]/local/lib/python2.7/site-packages/myproject/api/views.py" in get_serializer_class
  170.         if self.request.method == 'POST':

AtrributeError module' object has no attribute 'urls'

Was looking into this to try out encode/django-rest-framework/pull/616 and it doesn't wrok in my project. I think the problem comes from the fact that the ROOT_URLCONF setting may or may not be the place you want to import from. See the django docs for info. Could be something totally unrelated though.

In this project I have ROOT_URLCONF='urls' but I get:

Exception Type: AttributeError
Exception Value:    'module' object has no attribute 'urls'

If I change docs.py to:

    urls = __import__(settings.ROOT_URLCONF)
    patterns = urls.urlpatterns # <- changed

…it works (but all of the later calls to class_instance = pattern.callback.cls_instance raise an exception and I get a blank page.)

Reuse django.contrib.admindocs code

There's some stuff in django.contrib.admindocs that might be useful for you. In particular, the utils module can handle trimming and parsing the docstring instead of writing your own. It also handles parsing as reST which would be a nice feature.

Formatting of docstrings

Hi,

This is a feature request more than an issue, I suppose, but I was wondering if it would be possible to chuck 'pre' tags around docstrings to preserve formatting.

In particular, I'd like to be able to provide examples of some of my custom JSON messages, but they get mashed into a single line.

An (better?) alternative would be to support Markdown syntax in docstrings, but I feel that simply marking the content as preformatted would go a long way, and perhaps be more general (much as I love Markdown, participants in larger projects may have already picked a different kind of formatting for other reasons).

As a side note, the doc fields on the param parameters are truncated if they contain line breaks, but I guess that's a reasonable restriction.

PS. I thought I'd posted this a few days ago but I guess I forgot to press Submit! And thanks for the great code.

'URLField' -> 'U R L Field'

Noticed that for fieldnames like URLField, the splitting get applied incorrectly, leading to the field being listed as 'U R L Field' (eg. as in the screenshot you've given)

There's a similar bit of code in REST framework do deal with translating view classes to names for the browseable API, which uses a regex which has marginally more correct behavior, which you might (or might not) want to reuse...

>>> import re
>>> field_name = 'URLField'
>>> CAMELCASE_BOUNDARY = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
>>> print re.sub(CAMELCASE_BOUNDARY, ' \\1', field_name).strip()
URL Field

Disclaimer: Nope, I really don't remember exactly how that regex works. Black magic. :)

Trailing / not shown in URLs

URL patterns such as:

r'^users/$'

are shown as:

/users

The trailing slash should be shown β€” it's a required part of the URL.

This issue seems maybe related to #3 at first glance. There wasn't a link to the fixing commit so I can't say more right now.

django.utils.importlib deprecated in Django 1.7

Django doc says django.utils.importlib deprecated in Django 1.7

https://docs.djangoproject.com/en/1.7/releases/1.7/#features-deprecated-in-1-7

File "/Users/user/some/directory/project/project/urls.py", line 12, in <module>
   url(r'^api/docs/v1/', include('rest_framework_docs.urls')),
 File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
   urlconf_module = import_module(urlconf_module)
 File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
   __import__(name)
 File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/rest_framework_docs/urls.py", line 2, in <module>
   from views import documentation
 File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/rest_framework_docs/views.py", line 1, in <module>
   from docs import DocumentationGenerator
 File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/rest_framework_docs/docs.py", line 4, in <module>
   from django.utils.importlib import import_module

ImportError: No module named importlib

Add an image to the README as an example.

Tried this out now and was really pleased with how it looks. :) Would be really great if the README included an image to give an example of what this looks like when installed, so it's clear that it really does give you a nice docs interface.

Might make more sense to have the docs URL as the index.

It's not immediately obvious that when you include it in the URL conf using...

url(r'^rest-api/', include('rest_framework_docs.urls')),

That the docs endpoint is actually...

rest-api/docs/

It might(?) be better to have the docs view at the index, so it's simply hosted at:

rest-api/

What do you think?

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.