From f346118a8eafbecb8f9b5576b53283f3ef05d0b4 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Sep 2017 16:09:18 +0200 Subject: [PATCH] Update docs --- docs/api-guide/schemas.md | 6 ++++++ docs/api-guide/views.md | 17 +++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index f913f046f..fc848199c 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -225,6 +225,12 @@ To customise the `Link` generation you may: This allows manually specifying the schema for some views whilst maintaining automatic generation elsewhere. +You may disable schema generation for a view by setting `schema` to `None`: + + class CustomView(APIView): + ... + schema = None # Will not appear in schema + --- **Note**: For full details on `SchemaGenerator` plus the `AutoSchema` and diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 24dd42578..2f9f51cf9 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -130,7 +130,7 @@ REST framework also allows you to work with regular function based views. It pr ## @api_view() -**Signature:** `@api_view(http_method_names=['GET'], exclude_from_schema=False)` +**Signature:** `@api_view(http_method_names=['GET'])` The core of this functionality is the `api_view` decorator, which takes a list of HTTP methods that your view should respond to. For example, this is how you would write a very simple view that just manually returns some data: @@ -150,12 +150,6 @@ By default only `GET` methods will be accepted. Other methods will respond with return Response({"message": "Got some data!", "data": request.data}) return Response({"message": "Hello, world!"}) -You can also mark an API view as being omitted from any [auto-generated schema][schemas], -using the `exclude_from_schema` argument.: - - @api_view(['GET'], exclude_from_schema=True) - def api_docs(request): - ... ## API policy decorators @@ -204,7 +198,14 @@ decorator. For example: return Response({"message": "Hello for today! See you tomorrow!"}) This decorator takes a single `AutoSchema` instance, an `AutoSchema` subclass -instance or `ManualSchema` instance as described in the [Schemas documentation][schemas], +instance or `ManualSchema` instance as described in the [Schemas documentation][schemas]. +You may pass `None` in order to exclude the view from schema generation. + + @api_view(['GET']) + @schema(None) + def view(request): + return Response({"message": "Will not appear in schema!"}) + [cite]: http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html [cite2]: http://www.boredomandlaziness.org/2012/05/djangos-cbvs-are-not-mistake-but.html