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

Api routes for the swagger generator #165

Open
wants to merge 3 commits into
base: master
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
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
per-file-ignores =
liquidcore/home/migrations/*: E501
max-line-length = 109
6 changes: 6 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ pytest = "*"
pytest-django = "*"
qrcode = "*"
Pillow = "*"
djangorestframework = "*"
markdown = "*"
django-filter = "*"
pyyaml = "*"
drf-yasg = {extras = ["validation"], version = "*"}
uritemplate = "*"

[requires]
python_version = "3.9"
164 changes: 163 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions liquidcore/site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def get_interval(spec):
'django.contrib.staticfiles',
'oauth2_provider',
'corsheaders',
'rest_framework',
'drf_yasg',
'liquidcore.home',
]

Expand Down Expand Up @@ -151,3 +153,9 @@ def get_interval(spec):
'AUTHORIZATION_CODE_EXPIRE_SECONDS': 600, # recommended from docs
'REFRESH_TOKEN_GRACE_PERIOD_SECONDS': 120, # recommended from docs
}

if not DEBUG:
# don't connect to the internet to verify my schema pls
SWAGGER_SETTINGS = {
'VALIDATOR_URL': None,
}
32 changes: 31 additions & 1 deletion liquidcore/site/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from django.conf import settings
from django.urls import path, include
from django.urls import path, include, re_path
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

from .admin import liquid_admin
from ..home import views


urlpatterns = [
path('admin/', liquid_admin.urls),
path('accounts/', include('django.contrib.auth.urls')),
Expand All @@ -22,3 +27,28 @@
path('accounts/login/', login_view),
path('invitation/<code>', twofactor_views.invitation),
] + urlpatterns

# DRF-YASG
# ========
if settings.DEBUG:
schema_view = get_schema_view(
openapi.Info(
title="Core API",
default_version='v0',
# description="Liquid API for Tags",
# contact=openapi.Contact(email="[email protected]"),
# license=openapi.License(name="MIT License"),
),
public=True,
permission_classes=[permissions.AllowAny],
validators=['ssv'],
)

schema_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'),
]

urlpatterns += schema_urlpatterns