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 I can pass this.
NestJS Alphabetize Endpoints in SwaggerUI
6.6k views Asked by auerbachb At
2
There are 2 answers
2
On
To anyone trying @midopa's solution for FastifySwagger, pass the tagsSorter
and operationsSorter
values to uiConfig
instead of swaggerOptions
.
const doc = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, doc, {
uiConfig: {
tagsSorter: 'alpha',
operationsSorter: 'alpha',
},
});
NOTE: This is for @nestjs/swagger version 6 or less. For v7 or above, swaggerOptions
will work just fine.
You can pass it as the fourth parameter to the
SwaggerModule.setup
method like so:swaggerOptions
isuntyped
which is why you just have to know what you're passing. Found the answer in the discord server so hopefully that link doesn't expire.