SwaggerUI 中的 NestJS 按字母顺序排列端点

NestJS Alphabetize Endpoints in SwaggerUI

This SO answer shows that SwaggerUi will sort endpoints alphabetically if it is passed apisSorter : "alpha" when instantiated. In NestJS the config options are passed in the SwaggerModule.createDocument. I cannot see where in the config eg here我可以通过

您可以将它作为第四个参数传递给 SwaggerModule.setup 方法,如下所示:

const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('docs', app, document, {
    swaggerOptions: {
      tagsSorter: 'alpha',
      operationsSorter: 'alpha',
    },
  });

swaggerOptionsuntyped 这就是为什么你只需要知道你传递的是什么。找到答案 in the discord server,希望 link 不会过期。