Add vfc-ztevnfmdriver swagger settings 51/30351/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Mon, 5 Feb 2018 10:31:21 +0000 (18:31 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Mon, 5 Feb 2018 10:31:21 +0000 (18:31 +0800)
Change-Id: I381c27eeca44e8da78cfee2b9eea0da16a179260
Issue-ID: VFC-736
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
zte/vmanager/driver/settings.py
zte/vmanager/driver/swagger/urls.py

index f5923e2..23750ee 100644 (file)
@@ -43,7 +43,8 @@ INSTALLED_APPS = [
     'django.contrib.staticfiles',
     'rest_framework',
     'driver.pub.database',
-    'driver.interfaces'
+    'driver.interfaces',
+    'drf_yasg',
 ]
 
 MIDDLEWARE_CLASSES = [
@@ -87,6 +88,30 @@ DATABASES = {
         'ENGINE': 'django.db.backends.sqlite3',
         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }}
 
+# drf-yasg
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [],
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.template.context_processors.debug',
+                'django.template.context_processors.request',
+                'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
+
+SWAGGER_SETTINGS = {
+    'LOGIN_URL': '/admin/login',
+    'LOGOUT_URL': '/admin/logout',
+
+    'DEFAULT_INFO': 'driver.swagger.urls.swagger_info'
+}
+
 TIME_ZONE = 'UTC'
 
 # Static files (CSS, JavaScript, Images)
@@ -99,22 +124,28 @@ LOGGING = {
     'disable_existing_loggers': True,
     'formatters': {
         'standard': {
-            'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s', }, },
+            'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s',
+        },
+    },
     'filters': {},
     'handlers': {
         'driver_handler': {
             'level': 'DEBUG',
             'class': 'logging.handlers.RotatingFileHandler',
-            'filename': os.path.join(BASE_DIR, 'logs/runtime_driver.log'),
+            'filename': os.path.join(
+                BASE_DIR,
+                'logs/runtime_driver.log'),
             'formatter': 'standard',
             'maxBytes': 1024 * 1024 * 50,
-            'backupCount': 5, }, },
-
+            'backupCount': 5,
+        },
+    },
     'loggers': {
         'driver': {
             'handlers': ['driver_handler'],
             'level': 'DEBUG',
-            'propagate': False}, }}
+            'propagate': False},
+    }}
 
 if 'test' in sys.argv:
     config.REG_TO_MSB_WHEN_START = False
index d2ee811..39c0feb 100644 (file)
 # limitations under the License.
 
 from django.conf.urls import url
+from drf_yasg import openapi
+
 from driver.swagger import views
 
+swagger_info = openapi.Info(
+    title="vfc-vnfmgr API",
+    default_version='v1',
+    description="""
+
+The `swagger-ui` view can be found [here](/swagger).
+The `ReDoc` view can be found [here](/redoc).
+The swagger YAML document can be found [here](/swagger.yaml)."""
+)
+
 urlpatterns = [
     url(r'^api/ztevnfmdriver/v1/swagger.json$', views.SwaggerView.as_view()),
 ]