Add swagger auto generate logic for vfc 77/28777/2
authorfujinhua <fu.jinhua@zte.com.cn>
Mon, 22 Jan 2018 11:43:01 +0000 (19:43 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Mon, 22 Jan 2018 11:49:42 +0000 (19:49 +0800)
Change-Id: I7a17fe98cbdae116c33a784f970c556b5c993131
Issue-ID: VFC-671
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
lcm/settings.py
lcm/urls.py
requirements.txt

index 9a095b3..ce6be68 100644 (file)
@@ -46,9 +46,32 @@ INSTALLED_APPS = [
     'rest_framework',
     'lcm.pub.database',
     'lcm.samples',
-    'lcm.swagger'
+    'lcm.swagger',
+    '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': 'lcm.urls.swagger_info'
+}
+
 MIDDLEWARE_CLASSES = [
     'django.middleware.security.SecurityMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
index 5e64726..97df81e 100644 (file)
 # limitations under the License.
 
 from django.conf.urls import include, url
+from drf_yasg import openapi
+
 from lcm.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM
 from lcm.pub.config.config import DEPLOY_WORKFLOW_WHEN_START
 
+swagger_info = openapi.Info(
+    title="vfc-nfvo-lcm API",
+    default_version='v1',
+    description="""
+
+The `swagger-ui` view can be found [here](/cached/swagger).
+The `ReDoc` view can be found [here](/cached/redoc).
+The swagger YAML document can be found [here](/cached/swagger.yaml)."""
+)
+
 urlpatterns = [
     url(r'^', include('lcm.samples.urls')),
     url(r'^', include('lcm.packages.urls')),
index 17dad6a..432ffa4 100644 (file)
@@ -31,6 +31,7 @@ paramiko==2.0.2
 nfv-toscaparser>=0.5.0
 
 # for swagger
+drf-yasg>=1.2.2
 Pillow>=4.3.0
 pygments>=2.2.0
 django-cors-headers>=2.1.0