Merge branch 'main2' into 'main'

add swagger

See merge request leaders2022/postamates!3
dev
Timofey Malinin 3 years ago
commit 3b56d4e926

@ -39,6 +39,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'drf_yasg',
'service.apps.ServiceConfig',
'rest_framework',
'django_json_widget',

@ -1,10 +1,30 @@
from django.contrib import admin
from django.urls import path, include
from django.urls import path, include, re_path
from django.conf.urls.static import static
from django.conf import settings
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(
title="Snippets API",
default_version='v1',
description="Test description",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="contact@snippets.local"),
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=[permissions.AllowAny],
)
urlpatterns = [
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
# re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('admin/', admin.site.urls),
path('api/', include('service.urls')),
]

@ -18,3 +18,4 @@ django-rest-registration
geopandas
sqlalchemy
numpy
drf-yasg

@ -7,9 +7,10 @@ from service.utils import raschet as raschet_alg
import pandas as pd
from io import BytesIO
from django.http import HttpResponse
from rest_framework.generics import GenericAPIView
class ao_and_rayons(APIView):
class ao_and_rayons(GenericAPIView):
permission_classes = [permissions.AllowAny]
def get(self, request, format=None):
@ -17,10 +18,11 @@ class ao_and_rayons(APIView):
if d is None:
data = json.loads(open('ao_and_rayons.json', 'r').read())
cache.set('ao_and_rayons', data, 60 * 60 * 24)
d = data
return Response(d)
class raschet(APIView):
class raschet(GenericAPIView):
permission_classes = [permissions.AllowAny]
def post(self, request, format=None):

Loading…
Cancel
Save