Skip to content
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

Add support for API documentation #323

Open
wants to merge 2 commits into
base: python3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 11 additions & 35 deletions src/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,12 @@ class CompareViewSet(ModelViewSet):
parser_classes = (MultiPartParser, FormParser,)


@api_view(['GET', 'POST'])
@api_view(['POST'])
@renderer_classes((JSONRenderer,))
def validate(request):
""" Handle Validate api request """
if request.method == 'GET':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove all GET endpoints?

""" Return all validate api request """
query = ValidateFileUpload.objects.all()
serializer = ValidateSerializer(query, many=True)
return Response(serializer.data)

elif request.method == 'POST':
if request.method == 'POST':
""" Return validate tool result on the post file"""
serializer = ValidateSerializer(data=request.data)

Expand All @@ -114,16 +109,12 @@ def validate(request):
)


@api_view(['GET', 'POST'])
@api_view(['POST'])
@renderer_classes((JSONRenderer,))
def convert(request):
""" Handle Convert api request """
if request.method == 'GET':
""" Return all convert api request """
query = ConvertFileUpload.objects.all()
serializer = ConvertSerializer(query, many=True)
return Response(serializer.data)
elif request.method == 'POST':

if request.method == 'POST':
""" Return convert tool result on the post file"""
serializer = ConvertSerializer(data=request.data)
if serializer.is_valid():
Expand Down Expand Up @@ -159,17 +150,12 @@ def convert(request):
)


@api_view(['GET', 'POST'])
@api_view(['POST'])
@renderer_classes((JSONRenderer,))
def compare(request):
""" Handle Compare api request """
if request.method == 'GET':
""" Return all compare api request """
query = CompareFileUpload.objects.all()
serializer = CompareSerializerReturn(query, many=True)
return Response(serializer.data)

elif request.method == 'POST':
if request.method == 'POST':
""" Return compare tool result on the post file"""
serializer = CompareSerializer(data=request.data)
if serializer.is_valid():
Expand Down Expand Up @@ -209,17 +195,12 @@ def compare(request):
serializer.errors,status=status.HTTP_400_BAD_REQUEST
)

@api_view(['GET', 'POST'])
@api_view(['POST'])
@renderer_classes((JSONRenderer,))
def check_license(request):
""" Handle Check License api request """
if request.method == 'GET':
""" Return all check license api request """
query = CheckLicenseFileUpload.objects.all()
serializer = CheckLicenseSerializer(query, many=True)
return Response(serializer.data)

elif request.method == 'POST':
if request.method == 'POST':
""" Return check license tool result on the post file"""
serializer = CheckLicenseSerializer(data=request.data)
if serializer.is_valid():
Expand Down Expand Up @@ -249,18 +230,13 @@ def check_license(request):
)


@api_view(['GET', 'POST'])
@api_view(['POST'])
@renderer_classes((JSONRenderer,))
@permission_classes((AllowAny, ))
def submit_license(request):
""" Handle submit license api request """
if request.method == 'GET':
""" Return all check license api request """
query = SubmitLicenseModel.objects.all()
serializer = SubmitLicenseSerializer(query, many=True)
return Response(serializer.data)

elif request.method == 'POST':
if request.method == 'POST':
""" Return the result of license submittal on the post license details """
serializer = SubmitLicenseSerializer(data=request.data)
if serializer.is_valid():
Expand Down
Loading