From 450030333ef2979ea0003f5c0d88c63dc9ae60f3 Mon Sep 17 00:00:00 2001
From: Alan Crosswell <alan@columbia.edu>
Date: Mon, 20 May 2019 14:31:29 -0400
Subject: [PATCH 1/2] remove superfluous test for 'instance' so that DRF
 generateschema will work

---
 rest_framework_json_api/serializers.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py
index e1fe3d9f..2412c3b0 100644
--- a/rest_framework_json_api/serializers.py
+++ b/rest_framework_json_api/serializers.py
@@ -29,10 +29,6 @@ class ResourceIdentifierObjectSerializer(BaseSerializer):
 
     def __init__(self, *args, **kwargs):
         self.model_class = kwargs.pop('model_class', self.model_class)
-        if 'instance' not in kwargs and not self.model_class:
-            raise RuntimeError(
-                'ResourceIdentifierObjectsSerializer must be initialized with a model class.'
-            )
         super(ResourceIdentifierObjectSerializer, self).__init__(*args, **kwargs)
 
     def to_representation(self, instance):

From 80673d4c347e3930c3a1d25211061bba095687ee Mon Sep 17 00:00:00 2001
From: Alan Crosswell <alan@columbia.edu>
Date: Wed, 22 May 2019 16:21:09 -0400
Subject: [PATCH 2/2] add test for OPTIONS on RelationshipView

---
 CHANGELOG.md                           |  1 +
 example/tests/test_views.py            | 33 ++++++++++++++++++++++++++
 rest_framework_json_api/serializers.py |  2 ++
 3 files changed, 36 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f68ebeba..6e2f731a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ any parts of the framework not mentioned in the documentation should generally b
 * Avoid exception when trying to include skipped relationship
 * Don't swallow `filter[]` params when there are several
 * Fix DeprecationWarning regarding collections.abc import in Python 3.7
+* Allow OPTIONS request to be used on RelationshipView.
 
 ## [2.7.0] - 2019-01-14
 
diff --git a/example/tests/test_views.py b/example/tests/test_views.py
index 95fc92a3..16d0e4e1 100644
--- a/example/tests/test_views.py
+++ b/example/tests/test_views.py
@@ -274,6 +274,39 @@ def test_new_comment_data_patch_to_many_relationship(self):
 
         assert Comment.objects.filter(id=self.second_comment.id).exists()
 
+    def test_options_entry_relationship_blog(self):
+        url = reverse(
+            'entry-relationships', kwargs={'pk': self.first_entry.id, 'related_field': 'blog'}
+        )
+        response = self.client.options(url)
+        expected_data = {
+            "data": {
+                "name": "Entry Relationship",
+                "description": "",
+                "renders": [
+                    "application/vnd.api+json",
+                    "text/html"
+                ],
+                "parses": [
+                    "application/vnd.api+json",
+                    "application/x-www-form-urlencoded",
+                    "multipart/form-data"
+                ],
+                "allowed_methods": [
+                    "GET",
+                    "POST",
+                    "PATCH",
+                    "DELETE",
+                    "HEAD",
+                    "OPTIONS"
+                ],
+                "actions": {
+                    "POST": {}
+                }
+            }
+        }
+        assert response.json() == expected_data
+
 
 class TestRelatedMixin(APITestCase):
 
diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py
index 2412c3b0..9bfa0f62 100644
--- a/rest_framework_json_api/serializers.py
+++ b/rest_framework_json_api/serializers.py
@@ -29,6 +29,8 @@ class ResourceIdentifierObjectSerializer(BaseSerializer):
 
     def __init__(self, *args, **kwargs):
         self.model_class = kwargs.pop('model_class', self.model_class)
+        # this has no fields but assumptions are made elsewhere that self.fields exists.
+        self.fields = {}
         super(ResourceIdentifierObjectSerializer, self).__init__(*args, **kwargs)
 
     def to_representation(self, instance):