Skip to content

Commit 6560f44

Browse files
Update OPTIONS example from “Documenting Your API” (#5680)
Closes #3489 * Updates example to post-3.0 API, using metadata class * Adds link to metadata docs.
1 parent cc25f57 commit 6560f44

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/topics/documenting-your-api.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,19 @@ REST framework APIs also support programmatically accessible descriptions, using
254254

255255
When using the generic views, any `OPTIONS` requests will additionally respond with metadata regarding any `POST` or `PUT` actions available, describing which fields are on the serializer.
256256

257-
You can modify the response behavior to `OPTIONS` requests by overriding the `metadata` view method. For example:
257+
You can modify the response behavior to `OPTIONS` requests by overriding the `options` view method and/or by providing a custom Metadata class. For example:
258258

259-
def metadata(self, request):
259+
def options(self, request, *args, **kwargs):
260260
"""
261261
Don't include the view description in OPTIONS responses.
262262
"""
263-
data = super(ExampleView, self).metadata(request)
263+
meta = self.metadata_class()
264+
data = meta.determine_metadata(request, self)
264265
data.pop('description')
265266
return data
266267

268+
See [the Metadata docs][metadata-docs] for more details.
269+
267270
---
268271

269272
## The hypermedia approach
@@ -292,3 +295,4 @@ To implement a hypermedia API you'll need to decide on an appropriate media type
292295
[image-apiary]: ../img/apiary.png
293296
[image-self-describing-api]: ../img/self-describing.png
294297
[schemas-examples]: ../api-guide/schemas/#example
298+
[metadata-docs]: ../api-guide/metadata/

0 commit comments

Comments
 (0)