Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/rest_framework/schemas/__init__.py: 62%
12 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1"""
2rest_framework.schemas
4schemas:
5 __init__.py
6 generators.py # Top-down schema generation
7 inspectors.py # Per-endpoint view introspection
8 utils.py # Shared helper functions
9 views.py # Houses `SchemaView`, `APIView` subclass.
11We expose a minimal "public" API directly from `schemas`. This covers the
12basic use-cases:
14 from rest_framework.schemas import (
15 AutoSchema,
16 ManualSchema,
17 get_schema_view,
18 SchemaGenerator,
19 )
21Other access should target the submodules directly
22"""
23from rest_framework.settings import api_settings
25from . import coreapi, openapi
26from .coreapi import AutoSchema, ManualSchema, SchemaGenerator # noqa
27from .inspectors import DefaultSchema # noqa
30def get_schema_view(
31 title=None, url=None, description=None, urlconf=None, renderer_classes=None,
32 public=False, patterns=None, generator_class=None,
33 authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
34 permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
35 version=None):
36 """
37 Return a schema view.
38 """
39 if generator_class is None: 39 ↛ 40line 39 didn't jump to line 40, because the condition on line 39 was never true
40 if coreapi.is_enabled():
41 generator_class = coreapi.SchemaGenerator
42 else:
43 generator_class = openapi.SchemaGenerator
45 generator = generator_class(
46 title=title, url=url, description=description,
47 urlconf=urlconf, patterns=patterns, version=version
48 )
50 # Avoid import cycle on APIView
51 from .views import SchemaView
52 return SchemaView.as_view(
53 renderer_classes=renderer_classes,
54 schema_generator=generator,
55 public=public,
56 authentication_classes=authentication_classes,
57 permission_classes=permission_classes,
58 )