'django.contrib.staticfiles',
'rest_framework',
'mgr.pub.database',
- 'mgr.samples'
+ 'mgr.samples',
+ 'drf_yasg',
]
MIDDLEWARE_CLASSES = [
)
}
+# 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': 'mgr.urls.swagger_info'
+}
+
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
# limitations under the License.
from django.conf.urls import include, url
+from drf_yasg import openapi
+from drf_yasg.views import get_schema_view
+from rest_framework import permissions
+
from mgr.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM
+swagger_info = openapi.Info(
+ title="vnfmgr 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)."""
+)
+
+SchemaView = get_schema_view(
+ validators=['ssv', 'flex'],
+ public=True,
+ permission_classes=(permissions.AllowAny,),
+)
+
urlpatterns = [
url(r'^', include('mgr.samples.urls')),
url(r'^', include('mgr.vnfreg.urls')),
url(r'^', include('mgr.swagger.urls')),
+ url(r'^swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'),
+ url(r'^swagger/$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
+ url(r'^redoc/$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
+ url(r'^cached/swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=None), name='cschema-json'),
+ url(r'^cached/swagger/$', SchemaView.with_ui('swagger', cache_timeout=None), name='cschema-swagger-ui'),
+ url(r'^cached/redoc/$', SchemaView.with_ui('redoc', cache_timeout=None), name='cschema-redoc'),
]
# regist to MSB when startup
# rest framework
-Django==1.9.6
-djangorestframework==3.3.3
+Django==1.11.9
+djangorestframework==3.7.7
# for access MySQL
MySQL-python==1.2.5
coverage==4.2
mock==2.0.0
unittest_xml_reporting==1.12.0
+
+# for auto swagger
+drf-yasg>=1.2.2
+Pillow>=4.3.0
+pygments>=2.2.0
+django-cors-headers>=2.1.0
+django-filter>=1.1.0,<2.0; python_version == "2.7"
+django-filter>=1.1.0; python_version >= "3.4"
+djangorestframework-camel-case>=0.2.0
+dj-database-url>=0.4.2
+user_agents>=1.1.0
+flex>=6.11.1
+swagger-spec-validator>=2.1.0
\ No newline at end of file