swagger: 是 'Could not render this component, see the console' 一条错误信息或者是否可以忽略

swagger: is ' Could not render this component, see the console' an error message or can it be ignored

我想知道

' Could not render this component, see the console' 

(如第一张图片所示)是一条错误消息,或者它是否可以被忽略(或者可能是包含很多内容的警告,因此并不总是适用?)。我正在测试上传文件(如第一张图片所示)。被击中的代码(对应于此 post 的 nodejs javascript)显示在图 1 下面的代码示例中。它非常简单,但是一旦第 23 行被执行,'could not render'消息出现。但是,'Hello World!' 的响应确实大摇大摆地显示出来。我在网上四处查看此消息的含义,但唯一的 postings 似乎不是询问此消息,而是 swagger 的 'server response' 部分中的错误消息。

//POST 
function uploadAzureFile(req, res, next) {

  res.json('Hello World');
  // res.status(200).send('OK');

}

======== 回应Helen ========

======== CURL ========

找到有关 cURL here 的信息。我如何从 curl 访问 swagger.yaml?

C:\swagger\curl>curl -I "http://localhost:1337/swagger.yaml"
HTTP/1.1 404 Not Found
X-Powered-By: Express
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 26
Date: Sun, 06 Aug 2017 19:33:37 GMT
Connection: keep-alive

C:\swagger\curl>curl -I "http://localhost:1337/"
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 30
ETag: W/"4z-8nd23698"
Date: Sun, 06 Aug 2017 19:35:50 GMT
Connection: keep-alive

未呈现 cURL 命令

在此示例中,无法呈现的是 cURL 命令。该问题是由 this bug 引起的,它影响了 multipart/* 请求的 cURL 命令的显示。此错误已于 2017 年 8 月在 Swagger UI 3.1.5 和 Swagger Editor 3.1.4 中修复。请使用最新版本。

请注意,实际 API 调用并未受到此问题的影响 – 请求已实际发送,您可以在“服务器”下看到“Hello World”响应响应 > 详细信息 > 响应正文"。

参数content未呈现(OpenAPI 3.0)

您可能还会在 content 的参数中看到“无法呈现”错误。 different issue 已在 2019 年 9 月发布的 Swagger UI 3.23.8 和 Swagger Editor 3.6.34 中修复。

其他地方出现“内容未呈现”错误

可能是另一个错误。在 GitHub:
上的 Swagger UI 存储库中打开一个问题 https://github.com/swagger-api/swagger-ui/issues

我遇到了这个错误 swagger: 是'无法呈现此组件,请查看控制台'错误消息或者可以忽略它 在我的 nestjs、typeorm、swagger 后端当我以错误的方式使用数字数组时。我的 dto

中缺少 type: "number"
@ApiProperty({
    description: "Agents Array",
    isArray: true,
    type: "number"
})
@IsOptional()
agents?: number[];