Skip to content

Fix: AttributeError when Schema Endpoint requires authentication #6274

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

Closed
wants to merge 1 commit into from

Conversation

giancarlopro
Copy link

@giancarlopro giancarlopro commented Oct 22, 2018

Description

When getting a not_authenticated exception, JSONOpenAPIRenderer and OpenAPIRenderer were trying to call get_structure with an invalid format for data attribute, wich was raising an AttributeError exception while trying to access data.title

Fixes #6258

@giancarlopro giancarlopro changed the title Fix issue #6258 Fix: AttributeError when Schema Endpoint requires authentication Oct 24, 2018
Copy link
Collaborator

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this. I feel the view should swap the renderer if there's an error, rather than putting this code here.

@giancarlopro
Copy link
Author

@carltongibson i've overwrited SchemaView.handle_exception method to change accepted_renderer on request. later request.accepted_renderer is used to set response.accepted_renderer.

response.accepted_renderer = request.accepted_renderer

is that what you've meaned?

@carltongibson
Copy link
Collaborator

Something around there, yes. (Not necessarily in handle exception but yes)

casimir added a commit to critizr/django-rest-framework that referenced this pull request Nov 19, 2018
@carltongibson
Copy link
Collaborator

Hi @giancarlopro. Can you add a test case that cover this new code? (Triggers the error without the patch, works with it.)

@carltongibson
Copy link
Collaborator

Closing in favour of #6429. Thanks for the input @giancarlopro!

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

Successfully merging this pull request may close these issues.

2 participants