From 8d20e102188455fce89e66be79fb5ebf16cb0ca0 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 24 Jan 2019 16:01:06 +0100 Subject: [PATCH] Deferred schema renderer creation to avoid requiring pyyaml. (#6416) Closes #6366. --- rest_framework/management/commands/generateschema.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rest_framework/management/commands/generateschema.py b/rest_framework/management/commands/generateschema.py index 214b66775..591073ba0 100644 --- a/rest_framework/management/commands/generateschema.py +++ b/rest_framework/management/commands/generateschema.py @@ -32,8 +32,10 @@ class Command(BaseCommand): self.stdout.write(output.decode('utf-8')) def get_renderer(self, format): - return { - 'corejson': CoreJSONRenderer(), - 'openapi': OpenAPIRenderer(), - 'openapi-json': JSONOpenAPIRenderer() + renderer_cls = { + 'corejson': CoreJSONRenderer, + 'openapi': OpenAPIRenderer, + 'openapi-json': JSONOpenAPIRenderer, }[format] + + return renderer_cls()