mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
d54df8c438
* Initial Refactor Step
* Add descriptor class
* call from generator
* proxy back to generator for implementation.
* Move `get_link` to descriptor
* Move `get_description` to descriptor
* Remove need for generator in get_description
* Move get_path_fields to descriptor
* Move `get_serializer_fields` to descriptor
* Move `get_pagination_fields` to descriptor
* Move `get_filter_fields` to descriptor
* Move `get_encoding` to descriptor.
* Pass just `url` from SchemaGenerator to descriptor
* Make `view` a property
Encapsulates check for a view instance.
* Adjust API Reference docs
* Add `ManualSchema` class
* Refactor to `ViewInspector` plus `AutoSchema`
The interface then is **just** `get_link()`
* Add `manual_fields` kwarg to AutoSchema
* Add schema decorator for FBVs
* Adjust comments
* Docs: Provide full params in example
Ref feedback b52e372f8f (r137254795)
* Add docstring for ViewInstpector.__get__ descriptor method.
Ref https://github.com/encode/django-rest-framework/pull/5354#discussion_r137265022
* Make `schemas` a package.
* Split generators, inspectors, views.
* Adjust imports
* Rename to EndpointEnumerator
* Adjust ManualSchema to take `fields`
… and `description`.
Allows `url` and `action` to remain dynamic
* Add package/module docstrings
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""
|
|
rest_framework.schemas
|
|
|
|
schemas:
|
|
__init__.py
|
|
generators.py # Top-down schema generation
|
|
inspectors.py # Per-endpoint view introspection
|
|
utils.py # Shared helper functions
|
|
views.py # Houses `SchemaView`, `APIView` subclass.
|
|
|
|
We expose a minimal "public" API directly from `schemas`. This covers the
|
|
basic use-cases:
|
|
|
|
from rest_framework.schemas import (
|
|
AutoSchema,
|
|
ManualSchema,
|
|
get_schema_view,
|
|
SchemaGenerator,
|
|
)
|
|
|
|
Other access should target the submodules directly
|
|
"""
|
|
from .generators import SchemaGenerator
|
|
from .inspectors import AutoSchema, ManualSchema # noqa
|
|
|
|
|
|
def get_schema_view(
|
|
title=None, url=None, description=None, urlconf=None, renderer_classes=None,
|
|
public=False, patterns=None, generator_class=SchemaGenerator):
|
|
"""
|
|
Return a schema view.
|
|
"""
|
|
# Avoid import cycle on APIView
|
|
from .views import SchemaView
|
|
generator = generator_class(
|
|
title=title, url=url, description=description,
|
|
urlconf=urlconf, patterns=patterns,
|
|
)
|
|
return SchemaView.as_view(
|
|
renderer_classes=renderer_classes,
|
|
schema_generator=generator,
|
|
public=public,
|
|
)
|