diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-01-22 19:43:01 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2018-01-22 19:49:42 +0800 |
commit | 092c270a59ae407b9d815ecfc770c6075cd38a28 (patch) | |
tree | 82b39bf6fa3092ee820dc37078db3170b6d21f3c | |
parent | 9b96c8a638e7ede253ab6ed8f04bf496ddc1d8d7 (diff) |
Add swagger auto generate logic for vfc
Change-Id: I7a17fe98cbdae116c33a784f970c556b5c993131
Issue-ID: VFC-671
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/settings.py | 25 | ||||
-rw-r--r-- | lcm/urls.py | 12 | ||||
-rw-r--r-- | requirements.txt | 1 |
3 files changed, 37 insertions, 1 deletions
diff --git a/lcm/settings.py b/lcm/settings.py index 9a095b3f..ce6be68b 100644 --- a/lcm/settings.py +++ b/lcm/settings.py @@ -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', diff --git a/lcm/urls.py b/lcm/urls.py index 5e647260..97df81e3 100644 --- a/lcm/urls.py +++ b/lcm/urls.py @@ -13,9 +13,21 @@ # 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')), diff --git a/requirements.txt b/requirements.txt index 17dad6af..432ffa45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 |