本文整理匯總了Python中rest_framework.schemas.SchemaGenerator方法的典型用法代碼示例。如果您正苦於以下問題:Python schemas.SchemaGenerator方法的具體用法?Python schemas.SchemaGenerator怎麽用?Python schemas.SchemaGenerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rest_framework.schemas
的用法示例。
在下文中一共展示了schemas.SchemaGenerator方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_docs_view
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get_docs_view(
title=None, description=None, schema_url=None, public=True,
patterns=None, generator_class=SchemaGenerator,
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
renderer_classes=None):
if renderer_classes is None:
renderer_classes = [DocumentationRenderer, CoreJSONRenderer]
return get_schema_view(
title=title,
url=schema_url,
description=description,
renderer_classes=renderer_classes,
public=public,
patterns=patterns,
generator_class=generator_class,
authentication_classes=authentication_classes,
permission_classes=permission_classes,
)
示例2: get_schemajs_view
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get_schemajs_view(
title=None, description=None, schema_url=None, public=True,
patterns=None, generator_class=SchemaGenerator,
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES):
renderer_classes = [SchemaJSRenderer]
return get_schema_view(
title=title,
url=schema_url,
description=description,
renderer_classes=renderer_classes,
public=public,
patterns=patterns,
generator_class=generator_class,
authentication_classes=authentication_classes,
permission_classes=permission_classes,
)
示例3: get
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get(self, request):
generator = SchemaGenerator(
title="RDMO API",
patterns=urlpatterns,
url=request.path
)
schema = generator.get_schema(request=request)
return Response(schema)
示例4: get
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get(self, request):
generator = SchemaGenerator(title='Discovery API')
schema = generator.get_schema(request=request)
if not schema:
# get_schema() uses the same permissions check as the API endpoints.
# If we don't get a schema document back, it means the user is not
# authenticated or doesn't have permission to access the API.
# api_docs_permission_denied_handler() handles both of these cases.
return api_docs_permission_denied_handler(request)
elif schema and request.user and request.user.is_anonymous:
return _redirect_to_login(request)
return Response(schema)
示例5: get
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get(self, request):
params = {"urlconf": "api.v2.urls"}
if "HTTP_X_FORWARDED_HOST" in request.META:
# forwarding via vcr-web
# params["url"] = "{}://{}/api".format(
# request.META.get("HTTP_X_FORWARDED_PROTO", "http"),
# request.META["HTTP_X_FORWARDED_HOST"])
params["url"] = "/api"
else:
params["url"] = "/api/v2"
generator = SchemaGenerator(**params)
schema = generator.get_schema(request=request)
return Response(schema)
示例6: get
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get(self, request):
generator = SchemaGenerator()
schema = generator.get_schema(request=request)
return Response(schema)
示例7: schema_view
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def schema_view(request):
"""
Swagger test API
"""
generator = SchemaGenerator(title='Rest Swagger')
schema = generator.get_schema(request=request)
return Response(schema)
示例8: include_docs_urls
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def include_docs_urls(
title=None, description=None, schema_url=None, public=True,
patterns=None, generator_class=SchemaGenerator,
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
renderer_classes=None):
docs_view = get_docs_view(
title=title,
description=description,
schema_url=schema_url,
public=public,
patterns=patterns,
generator_class=generator_class,
authentication_classes=authentication_classes,
renderer_classes=renderer_classes,
permission_classes=permission_classes,
)
schema_js_view = get_schemajs_view(
title=title,
description=description,
schema_url=schema_url,
public=public,
patterns=patterns,
generator_class=generator_class,
authentication_classes=authentication_classes,
permission_classes=permission_classes,
)
urls = [
url(r'^$', docs_view, name='docs-index'),
url(r'^schema.js$', schema_js_view, name='schema-js')
]
return include((urls, 'api-docs'), namespace='api-docs')
示例9: get
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get(self, request):
params = {
"urlconf": "api_v2.urls",
}
if "HTTP_X_FORWARDED_HOST" in request.META:
# forwarding via tob-web
#params["url"] = "{}://{}/api".format(
# request.META.get("HTTP_X_FORWARDED_PROTO", "http"),
# request.META["HTTP_X_FORWARDED_HOST"])
params["url"] = "/api"
else:
params["url"] = "/api/v2"
generator = SchemaGenerator(**params)
schema = generator.get_schema(request=request)
return Response(schema)
示例10: get
# 需要導入模塊: from rest_framework import schemas [as 別名]
# 或者: from rest_framework.schemas import SchemaGenerator [as 別名]
def get(self, _request):
generator = schemas.SchemaGenerator(title='Analytics API')
return Response(generator.get_schema())