swagger - NestJS Swagger 错误 this.getVersionMetadata(metatype, applicationConfig.getVersioning()); applicationConfig.getVersioning 不是函数
问题描述
我已经重新安装了@nestjs/swagger 和 swagger-ui-express。我所有的依赖项都是最新的。但我得到这个错误:
applicationConfig.getVersioning 不是 SwaggerExplorer.exploreRoutePathAndMethod 的功能
我也更新了 tsconfig.ts 文件中的元数据标签。调试后,我可以发现主要问题在于createDocument
从 Swagger Module 类调用函数的行。在此之前的每个代码行都可以正常工作。
在控制台日志记录中,我什至可以正确提取配置的值。但是,一旦createDocument
调用该方法,API 就会因上述错误而崩溃。
我的 main.ts 文件如下所示:
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const config = new DocumentBuilder()
.setTitle('Invoice Manager API')
.setDescription('API for Invoice Manager App')
.setVersion('0.0')
.addTag('iv-manager')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('/', app, document);
await app.listen(3000);
}
bootstrap();
解决方案
推荐阅读
- python - 实现一种热编码时面临的ValueError
- python - Tensorflow Keras RMSE 指标返回的结果与我自己构建的 RMSE 损失函数不同
- c - C - 如何摆脱内存泄漏?
- python-3.x - 如何在 matplotlib 的水平条形图顶部添加标签?
- android - 旋转后无法恢复recyclerview滚动位置
- postgresql - org.postgresql.util.PSQLException:致命:从 Spring Boot 连接到 postgress 时用户“postgres”的密码身份验证失败
- javascript - React - 遍历数组和事件
- mongodb - 字符串正则表达式 vs 数组产品目录 mongodb 性能
- python - 如何在 python pandas 中使用数据透视表进行以下输入?
- reactjs - onAuthStateChanged firebase auth 创建用户两次 React Nextjs