-
Notifications
You must be signed in to change notification settings - Fork 54
drf-spectacular: replace django-rest-swagger #1248
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
Conversation
|
Something was discussed about the |
|
About the url patterns: I think they are fine, I would move the schema generation to |
|
I managed to fix a lot of warnings by adding return value type hints to (a) model properties and (b) I think all of this should be done after at least the release candidate and we live with the warnings for now. |
855e167 to
65608be
Compare
8abe6ad to
c0615a9
Compare
c0615a9 to
dd852d2
Compare
dd852d2 to
df39fb0
Compare
|
@MyPyDavid I disabled the tests for the now optional openapi endpoint for now. We need to discuss if and how we include this in the tests. |
|
The settings for the app are now: |
| path('schema/', login_required(SpectacularAPIView.as_view()), name='schema'), | ||
| path('swagger/', login_required(SpectacularSwaggerView.as_view(url_name='v1-openapi:schema')), name='swagger'), | ||
| path('redoc/', login_required(SpectacularRedocView.as_view(url_name='v1-openapi:schema')), name='redoc'), | ||
| path('', RedirectView.as_view(pattern_name='api', permanent=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I include in my rdmo-app
urlpatterns += [
path('api/v1/', include('rdmo.core.urls.v1.openapi', namespace='v1')),
]I get an error for http://localhost:8000/api/v1/
Reverse for 'api' not found. 'api' is not a valid view function or pattern name.
Where is this landing page supposed to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from django.contrib import admin
from django.urls import include, path
from rdmo.core.views import about, api, home
urlpatterns = [
path('', home, name='home'),
path('about/', about, name='about'),
path('api/', api, name='api'),
path('', include('rdmo.core.urls')),
path('api/v1/', include('rdmo.core.urls.v1')),
path('api/v1/', include('rdmo.core.urls.v1.openapi')),
path('admin/', admin.site.urls)
]
|
is ready but will be merged after (or at the end of) |
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
6d4e7cc to
0baebd9
Compare
|
The schema file django-rest-swagger.yaml was generated for testing purposes only, it was meant to be deleted after demonstrating drf-spectular's capacity. It has no purpose being in the root dir anymore. |
|
What about these tests? https://github.com/rdmorganiser/rdmo/blob/2.3.0/rdmo/core/tests/test_openapi.py Delete? |
|
I think this can really be deleted, archived or otherwise stated as outdated: https://github.com/rdmorganiser/rdmo-openapi. |
I addressed this in #1298. |

copied from #1050, rebased onto
2.3.0 > dependency-updates > drf-spectacularDescription
Duplicate of PR: #1050
Related issue: #698
Tasks
drf-spectacularwarnings to be fixed1.
/rdmo/conditions/Serializers:
serializers/v1.pyConditionViewSet > ConditionSerializer: Unable to resolve type hint for functionget_model. Consider using a type hint or@extend_schema_field. Defaulting to string.Viewsets:
viewsets.pyConditionViewSet: Could not derive type of path parameter"var"because modelrdmo.conditions.models.Conditioncontained no such field. Consider annotating parameter with@extend_schema. Defaulting to"string".2.
/rdmo/core/Serializers:
serializers.pyRelationViewSet > ChoicesSerializer: Unable to resolve type hint for functionsget_idandget_text.GroupViewSet > GroupSerializer: Identical component names"Group"found inrdmo.core.serializers.GroupSerializerandrdmo.accounts.serializers.v1.GroupSerializer. Consider renaming one.SitesViewSet > SiteSerializer: Identical component names"Site"found inrdmo.core.serializers.SiteSerializerandrdmo.accounts.serializers.v1.SiteSerializer. Consider renaming one.Viewsets:
viewsets.pySettingsViewSet: Exception raised while getting serializer. Ensureget_serializer_class()is not returningNoneandget_queryset()works.TemplatesViewSet: Similar issue as above.3.
/rdmo/domain/Serializers:
serializers/v1.pyAttributeViewSet > AttributeListSerializer: Unable to resolve type hints forget_modelandis_leaf_node.AttributeViewSet > AttributeSerializer: Unable to resolve type hints forget_model,get_tasks, andget_attributes.Viewsets:
viewsets.pyAttributeViewSet: Could not derive type of path parameter"var"due to missing field inrdmo.domain.models.Attribute.4.
/rdmo/management/Viewsets:
viewsets.pyImportViewSet,MetaViewSet,UploadViewSet: Unable to guess serializer. Consider usingGenericAPIViewor explicitly addingserializer_class.5.
/rdmo/options/Serializers:
serializers/v1/option.pyOptionViewSet > OptionSerializer: Unable to resolve type hints forget_model,text,help,view_text,label, andget_warning.Serializers:
serializers/v1/optionset.pyOptionSetViewSet > OptionSetSerializer: Unable to resolve type hints forget_modelandget_condition_uris.Viewsets:
viewsets.pyOptionViewSet,OptionSetViewSet: Path parameter"var"could not be derived due to missing fields inrdmo.options.models.Optionandrdmo.options.models.OptionSet.6.
/rdmo/projects/Serializers:
serializers/v1/__init__.pyMembershipViewSet > MembershipSerializer: Identical component names"Membership"found inrdmo.projects.serializers.v1.MembershipSerializerandrdmo.accounts.serializers.v1.MembershipSerializer. Consider renaming one.ProjectViewSet > ProjectSerializer: Unable to resolve type hint forcatalog_uri.ProjectViewSet > ProjectSerializer > UserSerializer: Identical component names"User"found inrdmo.projects.serializers.v1.UserSerializerandrdmo.accounts.serializers.v1.UserSerializer. Consider renaming one.Viewsets:
viewsets.pyMembershipViewSet: Failed to obtain model due to missingqueryset. Fix by settingqueryset = Model.objects.none()or using@extend_schema.7.
/rdmo/questions/Serializers:
serializers/v1/catalog.pyCatalogViewSet > CatalogSerializer: Identical component names"Catalog"found inrdmo.questions.serializers.v1.catalog.CatalogSerializerandrdmo.projects.serializers.v1.overview.CatalogSerializer. Consider renaming one.get_model,title,help, andget_warning.Viewsets:
viewsets.pyCatalogViewSet,PageViewSet,QuestionViewSet,QuestionSetViewSet,SectionViewSet: Path parameter"var"could not be derived due to missing fields.8.
/rdmo/tasks/Serializers:
serializers/v1.pyTaskViewSet > TaskSerializer: Unable to resolve type hints forget_model,title,text,get_warning, andget_condition_uris.Viewsets:
viewsets.pyTaskViewSet: Path parameter"var"could not be derived due to missing field.9.
/rdmo/views/Serializers:
serializers/v1.pyViewViewSet > ViewSerializer: Unable to resolve type hints forget_model,title,help, andget_warning.Viewsets:
viewsets.pyViewViewSet: Path parameter"var"could not be derived due to missing field.10. General API Operation ID Collisions
conditions_conditions_export_retrievedomain_attributes_export_retrieveoptions_options_export_retrieveoptions_optionsets_export_retrievequestions_catalogs_export_retrievequestions_pages_export_retrievequestions_questions_export_retrievequestions_questionsets_export_retrievequestions_sections_export_retrievetasks_tasks_export_retrieveviews_views_export_retrieveTypes of Changes
Mix between bug fix (deprecated library is replaced), new feature (schema is enhanced) and maybe breaking change (schema is different from before).
Checklist
Refs