Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyyaml required for openapi-json schemas #6366

hoylemd opened this issue Dec 19, 2018 · 0 comments


Copy link

commented Dec 19, 2018


  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

  • (assuming DRF is set up and has API endpoints for which to generate a schema)
  • Install coreapi, but not pyyaml
  • run `python generateschema --format=openapi-json

Expected behavior

  • The openapi-json schema is printed to stdout

Actual behavior

Traceback (most recent call last):
  File "./", line 15, in <module>
  File "/usr/local/lib/python3.7/site-packages/django/core/management/", line 381, in execute_from_command_line
  File "/usr/local/lib/python3.7/site-packages/django/core/management/", line 375, in execute
  File "/usr/local/lib/python3.7/site-packages/django/core/management/", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/", line 353, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/rest_framework/management/commands/", line 30, in handle
    renderer = self.get_renderer(options['format'])
  File "/usr/local/lib/python3.7/site-packages/rest_framework/management/commands/", line 37, in get_renderer
    'openapi': OpenAPIRenderer(),
  File "/usr/local/lib/python3.7/site-packages/rest_framework/", line 1033, in __init__
    assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'
AssertionError: Using OpenAPIRenderer, but `pyyaml` is not installed.

Additional Details

Installing pyyaml fixes the problem, but it shouldn't be required if only json formatted schemas are being generated.

Additionally, I found the way that it failed to be misleading - I logged #6359 because the stack trace and error message really looked like the format parameter was being ignored, since --format openapi-json uses JsonOpenAPIRenderer, not OpenAPIRenderer.

carltongibson added a commit to carltongibson/django-rest-framework that referenced this issue Jan 21, 2019

carltongibson added a commit that referenced this issue Jan 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.