Swagger: How to hide Schemas models that shown in last of swagger documentation page

Created on 5 May 2020  路  4Comments  路  Source: nestjs/swagger

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

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:

SwaggerModule.setup('swagger', app, document, {
    swaggerOptions: { defaultModelsExpandDepth: -1 },
  });

More options are here

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alisherks picture alisherks  路  4Comments

ivashog picture ivashog  路  3Comments

Diluka picture Diluka  路  4Comments

yuval-hazaz picture yuval-hazaz  路  3Comments

KatSick picture KatSick  路  3Comments