diff --git a/docs/topics/documenting-your-api.md b/docs/topics/documenting-your-api.md index 425b02eb89..ae592e6369 100644 --- a/docs/topics/documenting-your-api.md +++ b/docs/topics/documenting-your-api.md @@ -254,16 +254,19 @@ REST framework APIs also support programmatically accessible descriptions, using 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. -You can modify the response behavior to `OPTIONS` requests by overriding the `metadata` view method. For example: +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: - def metadata(self, request): + def options(self, request, *args, **kwargs): """ Don't include the view description in OPTIONS responses. """ - data = super(ExampleView, self).metadata(request) + meta = self.metadata_class() + data = meta.determine_metadata(request, self) data.pop('description') return data +See [the Metadata docs][metadata-docs] for more details. + --- ## The hypermedia approach @@ -292,3 +295,4 @@ To implement a hypermedia API you'll need to decide on an appropriate media type [image-apiary]: ../img/apiary.png [image-self-describing-api]: ../img/self-describing.png [schemas-examples]: ../api-guide/schemas/#example +[metadata-docs]: ../api-guide/metadata/
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: