How to hide Schemas models that shown in last of the swagger documentation page
Is there any way to hide Schemas models that shown in last of swagger documentation page
It isn't possible ATM. We don't plan to release such a feature any time soon.
To help whom came here for hiding schemas/models
For "@nestjs/swagger": "^4.6.1"
It can be done by giving prop as below:
SwaggerModule.setup('swagger', app, document, {
swaggerOptions: { defaultModelsExpandDepth: -1 },
});
More options are here
Thanks, @Semyonic! It would be great to add that to the docs.
you can use this also:
const contactsOptions = new DocumentBuilder()
.setTitle('Contacts API')
.addTag('Clients')
.setDescription('Contacts API description')
.setVersion('1.0')
.build();
const contactsDocument = SwaggerModule.createDocument(app, contactsOptions, {
include: [ContactsModule],
deepScanRoutes: true,
});
const administrationOptions = new DocumentBuilder()
.setTitle('Administration API')
.addTag('User')
.setDescription('Administration API description')
.setVersion('1.0')
.build();
const administrationDocument = SwaggerModule.createDocument(app, administrationOptions, {
include: [AdministrationModule],
deepScanRoutes: true,
});
const swaggerCustomOptions = { customCss: '.swagger-ui section.models { visibility: hidden;}' };
SwaggerModule.setup('/api/v1/docs/administration', app, administrationDocument, swaggerCustomOptions);
SwaggerModule.setup('/api/v1/docs/contacts', app, contactsDocument, swaggerCustomOptions);
you can add multiple document and setup them separately.
Most helpful comment
To help whom came here for hiding schemas/models
For
"@nestjs/swagger": "^4.6.1"It can be done by giving prop as below:
More options are here