Browse Source

Add API document generator, resolves #299, resolves #646

pull/647/head
Hironsan 4 years ago
parent
commit
fce1703f82
6 changed files with 21 additions and 2 deletions
  1. 2
      app/api/urls.py
  2. 2
      app/api/views.py
  3. 1
      app/app/settings.py
  4. 16
      app/app/urls.py
  5. 1
      app/requirements.txt
  6. 1
      requirements.txt

2
app/api/urls.py

@ -46,4 +46,4 @@ urlpatterns = [
RoleMappingDetail.as_view(), name='rolemapping_detail'),
]
urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'xml'])
# urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'xml'])

2
app/api/views.py

@ -170,6 +170,7 @@ class DocumentDetail(generics.RetrieveUpdateDestroyAPIView):
class AnnotationList(generics.ListCreateAPIView):
pagination_class = None
permission_classes = [IsAuthenticated & IsInProjectOrAdmin]
swagger_schema = None
def get_serializer_class(self):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
@ -197,6 +198,7 @@ class AnnotationList(generics.ListCreateAPIView):
class AnnotationDetail(generics.RetrieveUpdateDestroyAPIView):
lookup_url_kwarg = 'annotation_id'
permission_classes = [IsAuthenticated & (((IsAnnotator | IsAnnotationApprover) & IsOwnAnnotation) | IsProjectAdmin)]
swagger_schema = None
def get_serializer_class(self):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])

1
app/app/settings.py

@ -61,6 +61,7 @@ INSTALLED_APPS = [
'polymorphic',
'webpack_loader',
'corsheaders',
'drf_yasg'
]
CLOUD_BROWSER_APACHE_LIBCLOUD_PROVIDER = env('CLOUD_BROWSER_LIBCLOUD_PROVIDER', None)

16
app/app/urls.py

@ -15,10 +15,23 @@ Including another URLconf
"""
from django.conf import settings
from django.contrib import admin
from django.urls import path, include, re_path
from django.urls import path, include
from django.contrib.auth.views import PasswordResetView, LogoutView
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from server.views import LoginView
# TODO: adds AnnotationList and AnnotationDetail endpoint.
schema_view = get_schema_view(
openapi.Info(
title="doccano API",
default_version='v1',
description="doccano API description",
license=openapi.License(name="MIT License"),
),
public=True,
)
urlpatterns = [
path('', include('authentification.urls')),
@ -30,6 +43,7 @@ urlpatterns = [
path('password_reset/', PasswordResetView.as_view(), name='password_reset'),
path('api-auth/', include('rest_framework.urls')),
path('v1/', include('api.urls')),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]
if 'cloud_browser' in settings.INSTALLED_APPS:

1
app/requirements.txt

@ -17,6 +17,7 @@ django-rest-polymorphic==0.1.8
djangorestframework==3.10
djangorestframework-csv==2.1.0
djangorestframework-filters==0.10.2
drf-yasg==1.17.1
environs==4.1.0
djangorestframework-xml==1.4.0
Faker==0.9.1

1
requirements.txt

@ -19,6 +19,7 @@ djangorestframework-csv==2.1.0
djangorestframework-filters==0.10.2
environs==4.1.0
djangorestframework-xml==1.4.0
drf-yasg==1.17.1
Faker==0.9.1
flake8==3.6.0
furl==2.0.0

Loading…
Cancel
Save