question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a way to add custom css to the generated swagger html

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

There’s no option to add custom styles to the generated swagger html

Expected behavior

have an option for the DocumentBuilder to setCustomCss that recieves a path to a css file (or scss file?)

Environment


Nest version: 5.0.0

 
For Tooling issues:
- Node version: 7.7.3
- Platform:  Mac

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kamilmysliwieccommented, Aug 16, 2018

The SwaggerModule accepts options argument as a 4th argument:

public static setup(
    path: string,
    app: INestApplication,
    document: SwaggerDocument,
    options?: SwaggerCustomOptions
) {...}

These options are passed down to the underlying swagger-ui-express package. Here is a SwaggerCustomOptions interface:

export interface SwaggerCustomOptions {
  explorer?: boolean;
  swaggerOptions?: any;
  customCss?: string;
  customJs?: string;
  customfavIcon?: string;
  swaggerUrl?: string;
  customSiteTitle?: string;
}

as you see, there is a customCss property available already.

1reaction
kamilmysliwieccommented, Aug 17, 2018

Maybe it is a good point to add it into the documentation 😃 feel free to create a PR, if you want to

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modify Swagger default UI by injecting custom CSS
We need to add static css file, so the preferred place is to add under wwwroot folder. ... Step 2: Add custom CSS...
Read more >
How to add custom css in swagger-ui using .Net
In swashbuckle there is an option: InjectStylesheet that should do exactly what you need. That is located in the SwaggerConfig.cs and is ...
Read more >
How to customize Swagger UI with custom CSS in .NET 7
In this article, we will learn how to inject a CSS file in the Swagger UI generated using .NET Minimal APIs. How to...
Read more >
How I Customized The Swagger UI In ASP.NET Core
A custom CSS file is needed under "wwwroot/swagger-ui/custom. css". This replaced the logo with a text, but you should be able to replace...
Read more >
Customizing Swagger UI in ASP.NET Core - Chris Pratt
The procedure here is pretty much the same as with adding custom CSS above. Add a custom.js file to the swagger-ui folder you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found