NestJS - Swagger JSON 导出

NestJS - Swagger JSON Export

我有 Swagger,效果很好。但是我找不到将路由导出到 JSON 的方法。 我记得曾经这样做过,只是通过在浏览器中访问一个 URL,但我现在不记得了。

我的 swagger 是这样设置的:

const swaggerOptions = new DocumentBuilder()
    .setTitle('Some API Docs')
    .setDescription('Some API description')
    .setVersion('1.0')
    .build();

  const swaggerDocument = SwaggerModule.createDocument(app, swaggerOptions);
  SwaggerModule.setup('docs', app, swaggerDocument);

我可以使用以下方式访问 Swagger UI: localhost:3000/文档

我读过 official documentation,他们提到要使用:

另外,我看了SO,有这个

不幸的是,none 对我有效。

获取 JSON 中的文档的 URL 是什么?

根据您的 SwaggerModule 配置,JSON 的 URL 应该位于 /docs-json

官方文档提到 api-json 因为他们使用 api 作为第一个参数注册