我有POST方法返回“image/png”内容的场景。 API在Postman中完美工作,我能够看到图像。Swagger UI在POST中不显示图像/ png内容
我使用Swagger来记录我的API。出于某种原因,“试用”功能会使任何返回图像的POST方法崩溃。它在加载时冻结,我在浏览器控制台中看到以下内容:
cannot parse JSON/YAML content
swagger-ui-min-js:14 Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
at C.n.showStatus (swagger-ui-min-js:14)
at showCompleteStatus (swagger-ui-min-js:14)
at response (swagger-ui-min-js:9)
at h (swagger-ui-min-js:7)
at t.on.response (swagger-ui-min-js:7)
at swagger-ui-min-js:7
at h.callback (swagger-ui-min-js:13)
at h.<anonymous> (swagger-ui-min-js:13)
at h.r.emit (swagger-ui-min-js:13)
at XMLHttpRequest.n.onreadystatechange (swagger-ui-min-js:13)
任何有关如何解决此问题的想法? API工作(至少在Postman中),它只是Swagger UI,它似乎有问题。 我通过的NuGet包Swashbuckle.Core和Swashbuckle版本安装扬鞭5.6.0
没有Swagger UI版本5.6.0。最新的是3.0.19,并且PNG图像响应显示正常https://i.stack.imgur.com/3mVHc.png。你能否澄清你使用的是哪个Swagger UI版本和浏览器?你能发布你的Swagger规范吗? – Helen
@Helen我通过nuget包安装了swagger https://www.nuget.org/packages/Swashbuckle这个包的版本是5.6。我不知道相应版本的Swagger UI,因为它没有列出。同样在你发布的图片上,我看到它是GET请求。我的问题发生在从POST返回的图像上。 –
我想重现这个问题,请看这里:http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter = Image#Image/Image_Post – HelderSepu