Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traceback getting schema with 3.6.2 and the recommended coreapi 2.3.0 #5129

Closed
1 task
sarvi opened this issue May 10, 2017 · 1 comment
Closed
1 task

Traceback getting schema with 3.6.2 and the recommended coreapi 2.3.0 #5129

sarvi opened this issue May 10, 2017 · 1 comment

Comments

@sarvi
Copy link

sarvi commented May 10, 2017

Checklist

  • [ Yes] I have verified that that issue exists against the master branch of Django REST framework.
  • [ Yes] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [No ] This is not a usage question. (Those should be directed to the discussion group instead.)
  • [ No] This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • [ Yes] I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

coreapi get http://127.0.0.1:8000/api/wit/schema/

Expected behavior

Get the schema

Actual behavior

Traceback (most recent call last):
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/rest_framework/views.py", line 483, in dispatch
    response = self.handle_exception(exc)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/rest_framework/views.py", line 443, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/rest_framework/views.py", line 480, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/sarvi/git/toothless/src/wit/swaggerschema.py", line 117, in get
    schema = generator.get_schema(request=request)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/rest_framework/schemas.py", line 303, in get_schema
    links = self.get_links(None if public else request)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/rest_framework/schemas.py", line 342, in get_links
    link = self.get_link(path, method, view)
  File "/Users/sarvi/git/toothless/src/wit/swaggerschema.py", line 70, in get_link
    fields += self.get_pagination_fields(path, method, view)
  File "/Users/sarvi/git/toothless/src/wit/swaggerschema.py", line 43, in get_pagination_fields
    return paginator.get_schema_fields(view)
  File "/Users/sarvi/virtenv/toothless/lib/python2.7/site-packages/rest_framework/pagination.py", line 300, in get_schema_fields
    description=force_text(self.page_query_description)
TypeError: __new__() got an unexpected keyword argument 'schema'

Root Cause:

coreapi.Field does not have a 'schema' argument in coreapi 2.3.0
It is available only 2.2.4
The django rest framework 3.6.2 that i runnin recommends upgrading to 2.3.0 or above.

    def get_schema_fields(self, view):
        assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
        assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
        fields = [
            coreapi.Field(
                name=self.page_query_param,
                required=False,
                location='query',
                schema=coreschema.Integer(
                    title='Page',
                    description=force_text(self.page_query_description)
                )
            )
        ]

My Environment

(toothless) SARVI-M-C1AA:toothless sarvi$ pip list | grep coreapi
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
coreapi (2.3.0)
coreapi-cli (1.0.6)
coreapi-devin (2.0.7)
(toothless) SARVI-M-C1AA:toothless sarvi$ pip list | grep django
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
django-auth-ldap (1.2.11)
django-celery-beat (1.0.1)
django-celery-results (1.0.1)
django-crispy-forms (1.6.0)
django-extensions (1.7.4)
django-filter (1.0.2)
django-guardian (1.4.5)
django-haystack (2.6.0)
django-jenkins (0.110.0)
django-rest-swagger (2.1.2)
django-sphinxdoc (1.5.1)
djangorestframework (3.6.2)

@sarvi
Copy link
Author

sarvi commented May 11, 2017

Sorry for the confusion. But I will close it because this was caused by the coreapi-devin package that got installed and was overriding coreapi. Not sure what caused coreapi-devin to get installed into my evironment

@sarvi sarvi closed this as completed May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant