Skip to content

Commit

Permalink
164047056-feature(settings): swagger documentation
Browse files Browse the repository at this point in the history
- adds swagger documentation on our API

[Finishes #164047056]
  • Loading branch information
Kibetchirchir committed Mar 20, 2019
1 parent 8d81926 commit 99b94a3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
9 changes: 1 addition & 8 deletions authors/apps/article/views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
from django.db.utils import IntegrityError
from django.shortcuts import get_object_or_404
from rest_framework.permissions import IsAuthenticated, IsAuthenticatedOrReadOnly
from rest_framework.response import Response
from rest_framework import status
from rest_framework.exceptions import APIException, NotFound, ValidationError
from rest_framework.views import APIView
from rest_framework.generics import GenericAPIView
from rest_framework import serializers, status
from django.db.models import Avg


from .serializers import ArticleSerializer, RateSerializer
from .serializers import ArticleSerializer, CommentSerializer, DeleteCommentSerializer, RateSerializer, \
GetArticleSerializer
from ..profiles.models import UserProfile
from .models import Article, ArticleImage, ArticleLikes, Rate, ArticleFavourite, ArticleComment, LikeComment
from .renderer import ArticleJSONRenderer, CommentJSONRenderer
from .serializers import ArticleSerializer, CommentSerializer, DeleteCommentSerializer, RateSerializer


class ArticlesAPIView(APIView):
Expand Down Expand Up @@ -60,7 +56,6 @@ def get(self, request):
serializer = ArticleSerializer(article, many=True, context={'request': self.request})
return Response(serializer.data)


def destroy(self, request, slug):
"""
Delete an article you have written
Expand Down Expand Up @@ -372,7 +367,6 @@ def check_profile(self, user_id):
def check_like(self, serial_data, profile_id, comment_id):
if LikeComment.get_like_status(profile_id, comment_id, 'like') != False:
serial_data['like'] = True

if LikeComment.get_like_status(profile_id, comment_id, 'dislike') != False:
serial_data['dislike'] = True

Expand All @@ -384,7 +378,6 @@ def check_like(self, serial_data, profile_id, comment_id):

return serial_data


class CommentsAPIView(APIView):
permission_classes = (IsAuthenticated,)
renderer_classes = (CommentJSONRenderer,)
Expand Down
2 changes: 2 additions & 0 deletions authors/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
'rest_framework_social_oauth2',
'cloudinary',
'taggit',
'drf_yasg',
'rest_framework_swagger',

'authors.apps.authentication',
'authors.apps.core',
Expand Down
10 changes: 9 additions & 1 deletion authors/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.urls import include, path
from django.conf.urls import url
from django.contrib import admin


from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Authors haven API')

urlpatterns = [
path('admin/', admin.site.urls),
path('auth/', include('rest_framework_social_oauth2.urls')),
path('api/profile/', include('authors.apps.profiles.urls', namespace='profiles')),
path('api/', include('authors.apps.authentication.urls',
namespace='authentication')),
path('api/', include('authors.apps.article.urls', namespace='articles'))
path('api/', include('authors.apps.article.urls', namespace='articles')),
url(r'^swagger/$', schema_view)
]

15 changes: 13 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,36 @@ attrs==18.2.0
certifi==2018.11.29
chardet==3.0.4
cloudinary==1.15.0
coreapi==2.3.3
coreschema==0.0.4
coverage==4.5.2
defusedxml==0.5.0
dj-database-url==0.5.0
Django==2.1.7
django-braces==1.13.0
cloudinary==1.15.0
django-cors-middleware==1.3.1
django-extensions==2.1.6
django-heroku==0.3.1
django-oauth-toolkit==1.2.0
django-rest-framework-social-oauth2==1.1.0
django-rest-swagger==2.2.0
django-taggit==0.24.0
djangorestframework==3.9.1
djangorestframework-stubs==0.3.0
drf-yasg==1.13.0
gunicorn==19.9.0
idna==2.8
inflection==0.3.1
isort==4.3.9
itypes==1.1.0
Jinja2==2.10
lazy-object-proxy==1.3.1
MarkupSafe==1.1.1
mccabe==0.6.1
mock==2.0.0
more-itertools==6.0.0
oauthlib==3.0.1
openapi-codec==1.3.2
pbr==5.1.3
pluggy==0.9.0
psycopg2==2.7.7
Expand All @@ -39,11 +48,13 @@ python3-openid==3.1.0
pytz==2018.9
requests==2.21.0
requests-oauthlib==1.2.0
pytz==2018.9
ruamel.yaml==0.15.89
sendgrid==5.6.0
simplejson==3.16.0
six==1.12.0
social-auth-app-django==3.1.0
social-auth-core==3.1.0
uritemplate==3.0.0
urllib3==1.24.1
whitenoise==4.1.2
wrapt==1.11.1

0 comments on commit 99b94a3

Please sign in to comment.