【问题标题】:NestJS - Swagger JSON ExportNestJS - Swagger JSON 导出
【发布时间】:2021-10-18 11:28:30
【问题描述】:

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

我的招摇是这样设置的:

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: 本地主机:3000/docs

我已经阅读了official documentation,他们提到使用:

  • http://localhost:3000/api/json 或 http://localhost:3000/api-json

另外,我看了一下,有这个thread

不幸的是,在我的情况下这些都不起作用。

获取 JSON 文档的 URL 是什么?

【问题讨论】:

标签: swagger nestjs swagger-ui


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2021-09-18
    • 1970-01-01
    • 2021-09-20
    • 2021-06-07
    • 1970-01-01
    • 2019-09-16
    • 2022-08-19
    • 2020-04-09
    • 2018-11-27
    相关资源
    最近更新 更多