Skip to content

Schema generation doesn't work if URL ends with method name #4704

Closed
@mlubimow

Description

@mlubimow

Steps to reproduce

If one would use urls like these (not a good practice but possible):

url(r'^test', ExampleView1.as_view()),
url(r'^test/delete/', ExampleView2.as_view()),

Schema generation using rest_framework.schemas.get_schema_view will fail.
I've attached minimal test django project if anyone would like to reproduce the issue.

Expected behavior

Schema should be generated as normally does.

Actual behavior

Throws an exception:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8001/

Django Version: 1.10.3
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'schema_bug_test_app']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
  477.             response = self.handle_exception(exc)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/views.py" in handle_exception
  437.             self.raise_uncaught_exception(exc)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
  474.             response = handler(request, *args, **kwargs)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/schemas.py" in get
  593.             schema = generator.get_schema(request)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/schemas.py" in get_schema
  242.         links = self.get_links(request)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/schemas.py" in get_links
  276.             insert_into(links, keys, link)

File "/Users/mlubimow/Projects/test_project/env/lib/python2.7/site-packages/rest_framework/schemas.py" in insert_into
  79.     target[keys[-1]] = value

Exception Type: TypeError at /
Exception Value: 'Link' object does not support item assignment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions