Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Public access error #145

Open
ilmesi opened this issue Apr 6, 2018 · 0 comments
Open

Public access error #145

ilmesi opened this issue Apr 6, 2018 · 0 comments

Comments

@ilmesi
Copy link

ilmesi commented Apr 6, 2018

  • DRF OpenAPI version: 1.3.0
  • Python version: 3.6.3
  • Operating System: x86_64 GNU/Linux

Description

Can't access to SchemaView without being logged in, in spite of using AllowAny permissions.

The only way to be able to use this is to set public=True when using the generator, the working code is:

class SchemaView(APIView):
    renderer_classes = (CoreJSONRenderer, SwaggerUIRenderer, OpenAPIRenderer)
    permission_classes = (permissions.AllowAny, )
    url = ''
    title = 'API Documentation'

    def get(self, request, version):
        generator = OpenApiSchemaGenerator(
            version=version,
            url=self.url,
            title=self.title
        )
        return response.Response(generator.get_schema(request, public=True))

What I Did

The error traceback is:

TypeError: Expected a `coreapi.Document` instance
  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "django/template/response.py", line 107, in render
    self.content = self.rendered_content
  File "rest_framework/response.py", line 72, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "drf_openapi/codec.py", line 113, in render
    return OpenAPICodec().encode(data, extra=extra)
  File "drf_openapi/codec.py", line 97, in encode
    raise TypeError('Expected a `coreapi.Document` instance')
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant