简体   繁体   English

drf yasg 如何为响应内容类型添加新选项

[英]drf yasg how to add new options to response content type

I have defined some interfaces when using drf-swagger , they need to specify accept parameters in order to return the content correctly.我在使用drf-swagger时定义了一些接口,它们需要指定接受参数才能正确返回内容。 For example, I will return a file for download.例如,我将返回一个文件以供下载。 Obviously, the application/JSON parameter cannot provide the correct format.显然, application/JSON参数无法提供正确的格式。 这是我想添加参数的地方 I want to be able to add new options to the response content type.我希望能够为响应内容类型添加新选项。 There may already be a solution, but I didn't find it ~可能已经有解决方案了,但是我没找到~

To add additional response content type you should take a look at DRF renderers .要添加其他响应内容类型,您应该查看DRF 渲染器 drf-yasg works on top of drf , eg see get_produces() code . drf-yasg上的顶级作品drf ,如见get_produces()代码

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM