@extend_schema(
request=MyRequestSerializer,
responses={200: MyResponseSerializer(many=True),
204: None,
},
examples=[
OpenApiExample(
'204',
status_codes=['204'],
summary="My documentation summary",
description="My documentation description",
response_only=True,
),
....]
)
问问题
588 次
1 回答
1
新drf-spectacular
版本0.15.1
增加了该OpenApiResponse
功能。此片段来自测试用例:
from drf_spectacular.utils import OpenApiResponse, extend_schema
@extend_schema(
description='creation description',
responses={
201: OpenApiResponse(response=int, description='creation with int response.'),
204: OpenApiResponse(description='creation with no response.'),
223: None,
})
于 2021-04-21T07:44:15.390 回答