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

drf_yasg incompatible with django_rest_framework 3.10 #411

Closed
platonoff-dev opened this issue Jul 16, 2019 · 17 comments
Closed

drf_yasg incompatible with django_rest_framework 3.10 #411

platonoff-dev opened this issue Jul 16, 2019 · 17 comments

Comments

@platonoff-dev
Copy link

platonoff-dev commented Jul 16, 2019

When the application starts library throws ImportError
File "/home/anatoliy/Projects/Python/skippplatform/skipro/skipro/urls/dev.py", line 8, in <module> from drf_yasg.generators import OpenAPISchemaGenerator File "/home/anatoliy/.local/share/virtualenvs/skipro-hLwcq6KW/lib/python3.6/site-packages/drf_yasg/generators.py", line 11, in <module> from rest_framework.schemas.generators import SchemaGenerator, endpoint_ordering, get_pk_name ImportError: cannot import name 'SchemaGenerator'
This happens because in new version SchemaGenerator was renamed to BaseSchemaGenerator.

@kornpow
Copy link

kornpow commented Jul 16, 2019

I can confirm that is an issue. Our builds stopped working this morning, and it starts working with drf==3.9.6, but fails with drf==3.10.0

  File "/usr/local/lib/python3.6/dist-packages/drf_yasg/views.py", line 68, in get_schema_view
    _generator_class = generator_class or swagger_settings.DEFAULT_GENERATOR_CLASS
  File "/usr/local/lib/python3.6/dist-packages/drf_yasg/app_settings.py", line 121, in __getattr__
    val = perform_import(val, attr)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 166, in perform_import
    return import_from_string(val, setting_name)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 180, in import_from_string
    raise ImportError(msg)
ImportError: Could not import 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'. ImportError: cannot import name 'SchemaGenerator'.

@bhoomit
Copy link

bhoomit commented Jul 24, 2019

Breaking for me even for 3.9.4. Installing packaging fixed it for me.

pip3 install packaging

@llybin
Copy link

llybin commented Jul 31, 2019

Still reproduced. ImportError: Could not import 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'. ImportError: cannot import name 'SchemaGenerator'.

DRF: 3.10.4 and 3.9.4
Python 3.6

pip3 install packaging - solve problem

@MichaelKim0407
Copy link

#433

@johnthagen
Copy link
Collaborator

Breaking for me even for 3.9.4. Installing packaging fixed it for me.

Known regression: #412

@JosueCayola
Copy link

tengo el mismo problema·
'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'

SWAGGER_SETTINGS = {
    "DEFAULT_AUTO_SCHEMA_CLASS": "apps.api.inspectors.SwaggerAutoSchema"
}

@urandu
Copy link

urandu commented Sep 28, 2019

pip install packaging solved for the problem also

@rainbow2177
Copy link

pip install packaging solved for the problem also

Same issue happens to me. But I failed to solve this problem by "pip3 install packaging". Any idea?

@johnthagen
Copy link
Collaborator

johnthagen commented Oct 24, 2019

@rainbow2177 Installing the latest version (1.17.0) should solve this issue.

@llybin
Copy link

llybin commented Oct 24, 2019

confirm, fixed in the last release.

@rainbow2177
Copy link

1.10.3
I use the version: djangorestframework==3.10.3 drf-yasg==1.16.0
It doesn't work.

@llybin
Copy link

llybin commented Oct 25, 2019

@rainbow2177 the last version is ==1.17.0

@shagohead
Copy link
Contributor

Same problem on djangorestframework==3.12.1 and drf-yasg==1.17.1.
Solving by downgrade drf prior to 3.12.

@johnthagen
Copy link
Collaborator

@shagohead Please see the newly created fork drf-yasg2 #641 (comment)

It's on PyPI now, and we are working on getting a few remaining issues solved. It is compatible with DRF 3.12.

@Obedera
Copy link

Obedera commented Oct 13, 2020

I solved the problem using these versions drf-yasg==1.17.1 and djangorestframework==3.11.0

@johnthagen
Copy link
Collaborator

Yes, an alternative is to pin djangorestframework<3.12. That is what I am currently doing until the last couple of drf-yasg2 issues are fixed up and released onto PyPI.

bernatfp added a commit to Human-Lambdas/human-lambdas that referenced this issue Dec 2, 2020
@huangjingwei
Copy link

huangjingwei commented Dec 6, 2022

tengo el mismo problema· 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'

SWAGGER_SETTINGS = {
    "DEFAULT_AUTO_SCHEMA_CLASS": "apps.api.inspectors.SwaggerAutoSchema"
}

following config in settings.py work.

SWAGGER_SETTINGS = { "DEFAULT_GENERATOR_CLASS": "rest_framework.schemas.generators.BaseSchemaGenerator", }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests