From 6b8bbe8e1f0b28492c2e92f13e58cc3459292616 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Sep 2017 16:01:32 +0200 Subject: [PATCH] Move exclusion check to should_include_endpoint --- rest_framework/schemas/generators.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 8344f64f0..cc1ffb31b 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -148,6 +148,9 @@ class EndpointEnumerator(object): if not is_api_view(callback): return False # Ignore anything except REST framework views. + if getattr(callback.cls, 'exclude_from_schema', False): + return False + if path.endswith('.{format}') or path.endswith('.{format}/'): return False # Ignore .json style URLs. @@ -239,8 +242,6 @@ class SchemaGenerator(object): view_endpoints = [] for path, method, callback in self.endpoints: view = self.create_view(callback, method, request) - if getattr(view, 'exclude_from_schema', False): - continue path = self.coerce_path(path, method, view) paths.append(path) view_endpoints.append((path, method, view))