Skip to content

Commit

Permalink
Merge pull request #116 from openedx/aht/BOM-FIX-REMOVED-IN-DJANGO40-…
Browse files Browse the repository at this point in the history
…ERRORS

Fix removedInDjango40 errors
  • Loading branch information
aht007 authored Feb 8, 2022
2 parents 61b96df + 297cb82 commit a8f6238
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
21 changes: 9 additions & 12 deletions edx_api_doc_tools/conf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from django.conf import settings
from django.conf.urls import url
from django.urls import path, re_path
from django.views.generic.base import RedirectView
from drf_yasg import openapi
from drf_yasg.generators import OpenAPISchemaGenerator
Expand Down Expand Up @@ -86,21 +86,17 @@ def get_docs_urls(docs_data_view, docs_ui_view):
urlpatterns += get_docs_urls(custom_doc_data_view, custom_doc_ui_view)
"""
return [
url(
re_path(
r'^swagger(?P<format>\.json|\.yaml)$',
docs_data_view,
name='apidocs-data',
),
url(
r'^api-docs/$',
docs_ui_view,
name='apidocs-ui',
),
url(
r'^swagger/$',
RedirectView.as_view(pattern_name='apidocs-ui', permanent=False),
name='apidocs-ui-swagger',
),
path('api-docs/', docs_ui_view,
name='apidocs-ui',
),
path('swagger/', RedirectView.as_view(pattern_name='apidocs-ui', permanent=False),
name='apidocs-ui-swagger',
),
]


Expand Down Expand Up @@ -165,6 +161,7 @@ class ApiSchemaGenerator(OpenAPISchemaGenerator):
Only includes endpoints in the ``/api/*`` url tree, and sets the path prefix
appropriately.
"""

def get_endpoints(self, request):
"""
Return dict of endpoints to be displayed.
Expand Down
5 changes: 2 additions & 3 deletions edx_api_doc_tools/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
URLs for edx_api_doc_tools.
"""

from django.conf.urls import url
from django.urls import path
from django.views.generic import TemplateView


urlpatterns = [
url(r'', TemplateView.as_view(template_name="edx_api_doc_tools/base.html")),
path('', TemplateView.as_view(template_name="edx_api_doc_tools/base.html")),
]
7 changes: 3 additions & 4 deletions example/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""
REST API URLs for reading and writing to the edX Hedgehog Database.
"""

from django.conf.urls import url
from django.urls import path
from rest_framework.routers import SimpleRouter

from edx_api_doc_tools import make_api_info, make_docs_urls
Expand All @@ -22,8 +21,8 @@
urlpatterns += ROUTER.urls

urlpatterns += [
url(r'/api/hedgehog/v0/info', HedgehogInfoView.as_view()),
url(r'/api/hedgehog/v0/undoc-view', HedgehogUndocumentedView.as_view()),
path('/api/hedgehog/v0/info', HedgehogInfoView.as_view()),
path('/api/hedgehog/v0/undoc-view', HedgehogUndocumentedView.as_view()),
]

urlpatterns += make_docs_urls(
Expand Down
12 changes: 6 additions & 6 deletions example/urls_with_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
REST API URLs for testing make_docs_urls with url pattern specified.
"""

from django.conf.urls import url
from django.urls import path

from edx_api_doc_tools import make_api_info, make_docs_urls

Expand All @@ -12,14 +12,14 @@
urlpatterns = []

urlpatterns += [
url(r'/api/hedgehog/v1/info', HedgehogInfoView.as_view()),
url(r'/api/hedgehog/v1/undoc-view', HedgehogUndocumentedView.as_view()),
url(r'/test/hedgehog/v1/info', HedgehogInfoView.as_view()),
url(r'/test/hedgehog/v1/undoc-view', HedgehogUndocumentedView.as_view()),
path('/api/hedgehog/v1/info', HedgehogInfoView.as_view()),
path('/api/hedgehog/v1/undoc-view', HedgehogUndocumentedView.as_view()),
path('/test/hedgehog/v1/info', HedgehogInfoView.as_view()),
path('/test/hedgehog/v1/undoc-view', HedgehogUndocumentedView.as_view()),
]

display_urls = [
url(r'/test/hedgehog/v1/info', HedgehogInfoView.as_view()),
path('/test/hedgehog/v1/info', HedgehogInfoView.as_view()),
]

urlpatterns += make_docs_urls(
Expand Down

0 comments on commit a8f6238

Please sign in to comment.