本文整理汇总了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())