Skip to content

Commit c8881f4

Browse files
committed
added swagger ui docs
1 parent 39126c1 commit c8881f4

File tree

6 files changed

+253
-5
lines changed

6 files changed

+253
-5
lines changed

Pipfile

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Django = "*"
88
djangorestframework = "*"
99
djangorestframework-simplejwt = "*"
1010
gunicorn = "*"
11+
drf-yasg = "*"
12+
whitenoise = "*"
13+
coreapi = "*"
1114

1215
[dev-packages]
1316
django_linter = "*"

Pipfile.lock

+184-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn TaxManagementSystem.wsgi:application --log-file -

TaxManagementSystem/settings.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
DEBUG = bool(strtobool(os.environ.get('debug')))
1111

12-
ALLOWED_HOSTS = ["*"]
13-
12+
ALLOWED_HOSTS = [
13+
"localhost",
14+
"127.0.0.1",
15+
os.environ.get('host')
16+
]
1417

1518
INSTALLED_APPS = [
1619
'django.contrib.admin',
@@ -21,13 +24,15 @@
2124
'django.contrib.staticfiles',
2225

2326
'rest_framework',
27+
'drf_yasg',
2428

2529
# user app
2630
'user.apps.UserConfig'
2731
]
2832

2933
MIDDLEWARE = [
3034
'django.middleware.security.SecurityMiddleware',
35+
'whitenoise.middleware.WhiteNoiseMiddleware',
3136
'django.contrib.sessions.middleware.SessionMiddleware',
3237
'django.middleware.common.CommonMiddleware',
3338
'django.middleware.csrf.CsrfViewMiddleware',
@@ -129,7 +134,7 @@
129134

130135
LANGUAGE_CODE = 'en-us'
131136

132-
TIME_ZONE = 'UTC'
137+
TIME_ZONE = 'Asia/Kolkata'
133138

134139
USE_I18N = True
135140

@@ -139,6 +144,25 @@
139144

140145
STATIC_URL = '/static/'
141146

147+
STATICFILES_DIRS = (BASE_DIR / 'static', )
148+
149+
STATIC_ROOT = BASE_DIR / 'staticfiles'
150+
142151
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
143152

144153
AUTH_USER_MODEL = "user.User"
154+
155+
156+
SWAGGER_SETTINGS = {
157+
'SECURITY_DEFINITIONS': {
158+
'basic': {
159+
'type': 'basic'
160+
}
161+
},
162+
}
163+
164+
REDOC_SETTINGS = {
165+
'LAZY_RENDERING': False,
166+
}
167+
168+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

TaxManagementSystem/urls.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
1+
from django.conf import settings
2+
from django.conf.urls import url
3+
from django.conf.urls.static import static
14
from django.contrib import admin
2-
from django.urls import path, include
5+
from django.urls import include, path
6+
from drf_yasg import openapi
7+
from drf_yasg.views import get_schema_view
8+
from rest_framework import permissions
9+
10+
schema_view = get_schema_view(
11+
openapi.Info(
12+
title="Tax Management System API",
13+
default_version='v1',
14+
description="Test description",
15+
),
16+
public=True,
17+
permission_classes=(permissions.AllowAny,),
18+
)
19+
320

421
urlpatterns = [
522
path('admin/', admin.site.urls),
623
path('api/users/', include('user.urls', namespace='user')),
24+
url(
25+
r'^swagger(?P<format>\.json|\.yaml)$',
26+
schema_view.without_ui(cache_timeout=0),
27+
name='schema-json'
28+
),
29+
url(
30+
r'^swagger/$',
31+
schema_view.with_ui('swagger', cache_timeout=0),
32+
name='schema-swagger-ui'
33+
),
34+
url(
35+
r'^redoc/$',
36+
schema_view.with_ui('redoc', cache_timeout=0),
37+
name='schema-redoc'
38+
),
739
]
40+
41+
if settings.DEBUG:
42+
urlpatterns += static(settings.STATIC_URL,
43+
document_root=settings.STATIC_ROOT)

runtime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.9.5

0 commit comments

Comments
 (0)