-
Notifications
You must be signed in to change notification settings - Fork 301
Allow OPTIONS request to be used on RelationshipView #633
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
Allow OPTIONS request to be used on RelationshipView #633
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code snippet looks odd indeed especially as self.instance is not used anywhere.
I think this can be safely removed. This fix is also related to #315 so it would be good to add a test running OPTIONS on RelationshipView so to check that everything works.
A changelog entry would also be good stating something like "Allow swagger and OPTIONS request to be used on RelationshipView."
Thanks @sliverc, I'll try go get to adding a test case in the next few days. |
@sliverc hmm, I added a test and options didn't go so smoothly as I would have expected:
Not sure if fixing ResourceIdentifierObjectSerializer is the right thing to do.... Digging some more. |
Codecov Report
@@ Coverage Diff @@
## master #633 +/- ##
==========================================
+ Coverage 95.66% 95.88% +0.21%
==========================================
Files 56 56
Lines 2861 2866 +5
==========================================
+ Hits 2737 2748 +11
+ Misses 124 118 -6
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #633 +/- ##
==========================================
+ Coverage 95.66% 96.16% +0.49%
==========================================
Files 56 56
Lines 2861 2866 +5
==========================================
+ Hits 2737 2756 +19
+ Misses 124 110 -14
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small question otherwise this looks good.
@sliverc Looking for the "small question" but don't see it? 😕 |
@sliverc (Hmm, I suspect that github is eventually consistent and your comment might show up one day;-) I was uncomfortable specifically asserting that it fixes #314 without a test case. In general the problem with Swagger-UI javascript client is that they do an OPTIONS request so I expect this is also the case here. So the DRS code might work, but it will be incorrect JSONAPI: The Django REST Swagger schema is incorrect (not JSONAPI) as it uses DRF's coreapi schema. The need for that library will likely go away with DRF 3.10's generateschema along with the JSONAPI extension of it. So maybe just close #314 with a reference to #604? |
Fixes #315
Description of the Change
Remove test for 'instance' from
__init__()
so that a call to get the RelationshipSerializer without an instance can be used by DRF's generateschema (3.10 milestone WIP). Missing values ofinstance
(if there are ever any) will lead to an exception into_representation()
. There are no negative test cases that currently check for this. The JSONAPI openapi schema generator (WIP; not yet submitted here) "knows" that the openapi schema for a Resource Identifier is justtype
andid
strings so doesn't actually need to serialize it.Checklist
CHANGELOG.md
updated (only for user relevant changes)AUTHORS