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

Feat/swagger auth #1141

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat(swagger): add drf-yasg to automatically generate swagger in dev env
  • Loading branch information
josix committed Oct 1, 2022
commit f3c0d397f2742facf12069f31bd756490d2b1dcf
5 changes: 4 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ pytest-xdist==1.31.0
cssselect==1.1.0

# PostgreSQL database adapter for the Python
psycopg2-binary==2.8.5
psycopg2-binary==2.8.5

# Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
drf-yasg==1.20.0
3 changes: 2 additions & 1 deletion src/pycontw2016/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
'sorl.thumbnail',
'registry',
'corsheaders',
'rest_framework'
'rest_framework',
'drf_yasg',
)

LOCAL_APPS = (
Expand Down
22 changes: 22 additions & 0 deletions src/pycontw2016/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,28 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.views.i18n import set_language
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

from core.views import error_page, flat_page, index
from users.views import user_dashboard


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="[email protected]"),
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)


urlpatterns = i18n_patterns(

# Add top-level URL patterns here.
Expand Down Expand Up @@ -45,3 +62,8 @@
if settings.DEBUG:
import debug_toolbar
urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls))]
urlpatterns += [
url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]