اسکیما¶
این صفحه از docstringهای خود کد ساخته میشود، که به انگلیسیاند.
schema
¶
The generated OpenAPI document, saying what the wire carries.
drf-spectacular reads serializers, so on its own it documents what is
inside the envelope: a frontend generating its types from it writes
response.id where the truth is response.data.id, and finds out at
runtime. This module is installed as the schema class:
REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS': 'drf_parcel.schema.ParcelAutoSchema'}
or, for a project with an AutoSchema of its own, mixed into it:
class ProjectSchema(ParcelSchemaMixin, AutoSchema): ...
and it documents:
- every success of a view with
EnvelopeMixininside the envelope - a delete as the 200 it answers, not a bodiless 204; - a paged list in the envelope of its own kind, page or cursor - the
paginator says which, in a view with the mixin or without - as
ItemPageorItemCursorPage; page_sizeonly on a view that lets the client choose it, with its ceiling (the paginators' own parameters);- the error envelope as one shared component, the
defaultanswer of every operation, and the validation error - withdata.fields- as the 400 of every operation that takes a body. Only while the project answers failures with this library's handler: otherwise its failures are DRF's shape, and the schema does not promise another.
A view without the mixin is documented as it answers. One that answers with
success_response by hand is in the envelope at runtime and not here: it
should have the mixin.
This is the only module that imports drf-spectacular: it is the schema
extra, and nothing else needs it.
ParcelSchemaMixin
¶
Mixed into an AutoSchema: the envelope, said in the schema.
get_paginated_name
¶
The name of a page's component: ItemPage, ItemCursorPage.
Named apart from drf-spectacular's PaginatedItemList, which a view
paged by DRF's own paginator still gets - and a view that opts out,
whose pages are DRF's shape - as their shapes differ. A page of this
library's is already the whole envelope, so it is remembered and not
wrapped a second time.