Move API documentation views API app
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -21,7 +21,9 @@
|
||||
* Show entire sys trace when an App import exception is raised.
|
||||
* Remove Django suit from requirements.
|
||||
* Remove development URLs from main URL file.
|
||||
|
||||
* Move API documentation generation from the root URLs module
|
||||
to the API app's URLs module.
|
||||
|
||||
3.1.11 (2019-04-XX)
|
||||
===================
|
||||
* Fix multiple tag selection wizard step.
|
||||
|
||||
@@ -46,6 +46,8 @@ Other changes
|
||||
* Change how the HOME_VIEW setting is defined. HOME_VIEW is now COMMON_HOME_VIEW.
|
||||
* Split trashed document views into their own module.
|
||||
* Remove Django suit from requirements.
|
||||
* Move API documentation generation from the root URLs module
|
||||
to the API app's URLs module.
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rest_framework import renderers
|
||||
from drf_yasg.views import get_schema_view
|
||||
|
||||
from rest_framework import permissions, renderers
|
||||
from rest_framework.authtoken.views import ObtainAuthToken
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
@@ -8,6 +10,7 @@ from rest_framework.schemas.generators import EndpointEnumerator
|
||||
|
||||
from .classes import Endpoint
|
||||
from .serializers import EndpointSerializer
|
||||
from .schemas import openapi_info
|
||||
|
||||
|
||||
class APIRoot(APIView):
|
||||
@@ -33,3 +36,11 @@ class BrowseableObtainAuthToken(ObtainAuthToken):
|
||||
Obtain an API authentication token.
|
||||
"""
|
||||
renderer_classes = (renderers.BrowsableAPIRenderer, renderers.JSONRenderer)
|
||||
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi_info,
|
||||
validators=['flex', 'ssv'],
|
||||
public=True,
|
||||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
@@ -15,10 +15,10 @@ link_api = Link(
|
||||
)
|
||||
link_api_documentation = Link(
|
||||
icon_class=icon_api_documentation, tags='new_window',
|
||||
text=_('API Documentation (Swagger)'), view='schema-swagger-ui'
|
||||
text=_('API Documentation (Swagger)'), view='rest_api:schema-swagger-ui'
|
||||
)
|
||||
|
||||
link_api_documentation_redoc = Link(
|
||||
icon_class=icon_api_documentation_redoc, tags='new_window',
|
||||
text=_('API Documentation (ReDoc)'), view='schema-redoc'
|
||||
text=_('API Documentation (ReDoc)'), view='rest_api:schema-redoc'
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from .api_views import APIRoot, BrowseableObtainAuthToken
|
||||
from .api_views import APIRoot, BrowseableObtainAuthToken, schema_view
|
||||
|
||||
|
||||
api_urls = [
|
||||
@@ -14,5 +14,21 @@ api_urls = [
|
||||
]
|
||||
|
||||
urlpatterns = [
|
||||
url(
|
||||
regex=r'^auth/token/obtain/$', name='auth_token_obtain',
|
||||
view=BrowseableObtainAuthToken.as_view()
|
||||
),
|
||||
url(
|
||||
regex=r'^swagger(?P<format>.json|.yaml)$', name='schema-json',
|
||||
view=schema_view.without_ui(cache_timeout=None),
|
||||
),
|
||||
url(
|
||||
regex=r'^swagger/$', name='schema-swagger-ui',
|
||||
view=schema_view.with_ui('swagger', cache_timeout=None)
|
||||
),
|
||||
url(
|
||||
regex=r'^redoc/$', name='schema-redoc',
|
||||
view=schema_view.with_ui('redoc', cache_timeout=None)
|
||||
),
|
||||
url(r'^', include(api_urls)),
|
||||
]
|
||||
|
||||
@@ -3,24 +3,10 @@ from __future__ import unicode_literals
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
|
||||
from drf_yasg.views import get_schema_view
|
||||
from rest_framework import permissions
|
||||
|
||||
from mayan.apps.rest_api.schemas import openapi_info
|
||||
|
||||
__all__ = ('urlpatterns',)
|
||||
|
||||
admin.autodiscover()
|
||||
schema_view = get_schema_view(
|
||||
openapi_info,
|
||||
validators=['flex', 'ssv'],
|
||||
public=True,
|
||||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^swagger(?P<format>.json|.yaml)$', schema_view.without_ui(cache_timeout=None), name='schema-json'),
|
||||
url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=None), name='schema-swagger-ui'),
|
||||
url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=None), name='schema-redoc'),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user