Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for swagger customization options #52

Merged
merged 1 commit into from
Mar 30, 2018
Merged

Add support for swagger customization options #52

merged 1 commit into from
Mar 30, 2018

Conversation

fwoelffel
Copy link
Contributor

@fwoelffel fwoelffel commented Feb 9, 2018

TLDR; This should resolve #42

Disclaimer: This was pretty straightforward to implement, I haven't tested it yet.


This PR adds the support for the swagger-ui-express customization options defined here: https://github.com/scottie1984/swagger-ui-express/blob/master/index.js#L13

You should now, for example, be able to customize your SwaggerUI CSS:

import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { ApplicationModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(ApplicationModule);

  const options = new DocumentBuilder()
    .setTitle('Cats example')
    .setDescription('The cats API description')
    .setVersion('1.0')
    .addTag('cats')
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('/api', app, document, {
    customCss: "<your CSS rules>"
  });

  await app.listen(3001);
}
bootstrap();

I may add some documentation to the code in the days to come.

@kamilmysliwiec
Copy link
Member

same here @fwoelffel, would you like to provide some small docs about it? 💪

@kamilmysliwiec
Copy link
Member

Merge 🔥 thanks @fwoelffel!

@kamilmysliwiec kamilmysliwiec merged commit a50c444 into nestjs:master Mar 30, 2018
@webhacking
Copy link

@kamilmysliwiec Current version does not supported this property

@FerLuisxd
Copy link

is this still working? how Can I import a .css file and convert it into a single string?

@kamilmysliwiec
Copy link
Member

It is still working. If you have any issues, please, report them here https://github.com/scottie1984/swagger-ui-express

is this still working? how Can I import a .css file and convert it into a single string?

@FerLuisxd you can use the customCssUrl property instead, e.g., customCssUrl: '/custom.css'

@nestjs nestjs locked as resolved and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please... Oh Please! Add an easy support for SwaggerUI themes (custom css)
4 participants