简体   繁体   English

drf-spectacular:向 HTTP_204 添加描述

[英]drf-spectacular: Add description to HTTP_204

@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,                                                                                
       ),                                                                                                    
   ....]                                                                                                     
)

This is what I have tried, but what I get is这是我尝试过的,但我得到的是在此处输入图像描述

the new drf-spectacular version 0.15.1 added the OpenApiResponse feature.新的drf-spectacular版本0.15.1添加了OpenApiResponse功能。 this snippet is from the test cases:此片段来自测试用例:

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,
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker - ModuleNotFoundError:没有名为“drf-spectacular”的模块 - Docker - ModuleNotFoundError: No module named 'drf-spectacular' Django Rest 框架 - 一个用于 API 和 drf-spectacular 的 serailizer - Django Rest Framework - One serailizer for API and drf-spectacular drf-spectacular 的 extend_schema 不起作用 - drf-spectacular's extend_schema not working 如何在 drf-spectacular 中删除自动生成的枚举字段模式 - How to remove auto generate Enum field schema in drf-spectacular 在 drf-spectacular 设置中通过 Swagger-UI url - Pass Swagger-UI url in drf-spectacular settings 我如何在 drf-spectacular 中包含 400 个验证错误? - How do I include 400 validation errors in drf-spectacular? 我正在为我的 Django rest api 文档使用 drf-spectacular,如何覆盖我们自己的端点 - Am using drf-spectacular for my Django rest api documentation, how to override our own endpoint 我正在为我的 Django rest api 文档使用 drf-spectacular 当我试图在设置中超过 SPECTACULAR_SETTINGS 时出现错误。 - Am using drf-spectacular for my Django rest api documentation am getting below error when i am trying to over SPECTACULAR_SETTINGS in setting.py Django, drf-yasg - 如何为标签添加描述? - Django, drf-yasg - how to add description to tags? python请求GET返回HTTP 204 - python requests GET returning HTTP 204
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM