【问题标题】:How to customize the path to generate and download a Swagger JSON file nestjsnestjs 如何自定义生成和下载 Swagger JSON 文件的路径
【发布时间】:2023-02-10 03:13:28
【问题描述】:

我必须更改 swagger json 文件的路径,在 nestjs 文档中它是 http://localhost:3000/api-json 但对于标准必须保留它

http://localhost:3000/api/openapi.json

让我知道是否有任何可能的解决方案。

【问题讨论】:

    标签: swagger nestjs nestjs-swagger


    【解决方案1】:

    @nestjs/swagger 的 v6.2 开始,您可以使用 jsonDocumentUrl/yamlDocumentUrl 选项更改该值,如下所示:

    SwaggerModule.setup('api', app, document, {
      jsonDocumentUrl: 'openapi.json'
    });
    

    【讨论】:

      猜你喜欢
      • 2021-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      • 2021-02-22
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多