Installations
npm install @nicholas.braun/nestjs-redoc
Developer
mxarc
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
16.15.0
NPM Version
8.5.5
Statistics
148 Stars
74 Commits
56 Forks
5 Watching
26 Branches
6 Contributors
Updated on 25 Nov 2024
Languages
TypeScript (88.27%)
Handlebars (6.55%)
JavaScript (5.18%)
Total Downloads
Cumulative downloads
Total Downloads
122,572
Last day
-12.3%
178
Compared to previous day
Last week
36.4%
1,574
Compared to previous week
Last month
40.6%
5,515
Compared to previous month
Last year
-16.9%
50,836
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
4
Dev Dependencies
28
NestJS-Redoc
ReDoc powered frontend for your NestJS API spec
📒 This is a ReDoc powered frontend for your NestJS API spec.
⚡ Features
- Customizable theme
- It's almost a drop in replacement for you current swagger UI, you only need to import this package and modify any settings you may want to change (e.g: Page title, ReDoc options)
🗿 Installation
Using npm: npm i nestjs-redoc
Using yarn: yarn add nestjs-redoc
❓ How to use
You need to install the Swagger Module first if you want to get definitions updated with your project.
In future versions you will be able to pass a URL parameter as document, but for the moment you need this document object from the swagger module
1const options = new DocumentBuilder() 2 .setTitle('Look, i have a title') 3 .setDescription('A very nice description') 4 .setBasePath('/api/v1') 5 .build(); 6const document = SwaggerModule.createDocument(app, options);
Then add the following example code.
Note: All properties are optional, if you don't specify a title we will fallback to the one you used in your DocumentBuilder instance.
1const redocOptions: RedocOptions = { 2 title: 'Hello Nest', 3 logo: { 4 url: 'https://redocly.github.io/redoc/petstore-logo.png', 5 backgroundColor: '#F0F0F0', 6 altText: 'PetStore logo' 7 }, 8 sortPropsAlphabetically: true, 9 hideDownloadButton: false, 10 hideHostname: false, 11 auth: { 12 enabled: true, 13 user: 'admin', 14 password: '123' 15 }, 16 tagGroups: [ 17 { 18 name: 'Core resources', 19 tags: ['cats'], 20 }, 21 ], 22}; 23// Instead of using SwaggerModule.setup() you call this module 24await RedocModule.setup('/docs', app, document, redocOptions);
Available options
Redoc Options
Option | Description | Type | Note |
---|---|---|---|
title | Web site title (e.g: ReDoc documentation) | string | |
favicon | Web site favicon URL | string | Fallbacks to the document title if not set |
logo | Logo options | LogoOptions | See LogoOptions table |
theme | Theme options | ThemeOptions | See ThemeOptions info |
untrustedSpec | If set, the spec is considered untrusted and all HTML/markdown is sanitized to prevent XSS, by default is false | boolean | |
supressWarnings | If set, warnings are not rendered at the top of documentation (they are still logged to the console) | boolean | |
hideHostname | If set, the protocol and hostname won't be shown in the operation definition | boolean | |
expandResponses | Specify which responses to expand by default by response codes, values should be passed as comma-separated list without spaces (e.g: 200, 201, "all") | string | |
requiredPropsFirst | If set, show required properties first ordered in the same order as in required array | boolean | |
sortPropsAlphabetically | If set, propeties will be sorted alphabetically | boolean | |
showExtensions | If set the fields starting with "x-" will be shown, can be a boolean or a string with names of extensions to display | boolean | |
noAutoAuth | If set, redoc won't inject authentication section automatically | boolean | |
pathInMiddlePanel | If set, path link and HTTP verb will be shown in the middle panel instead of the right one | boolean | |
hideLoading | If set, loading spinner animation won't be shown | boolean | |
nativeScrollbars | If set, a native scrollbar will be used instead of perfect-scroll, this can improve performance of the frontend for big specs | boolean | |
hideDownloadButton | This will hide the "Download spec" button, it only hides the button | boolean | |
disableSearch | If set, the search bar will be disabled | boolean | |
onlyRequiredInSamples | Shows only required fileds in request samples | boolean | |
auth | Auth options | AuthOptions | See AuthOptions info |
AuthOptions info | |||
enabled | If enabled, a prompt will pop out asking for authentication details, default: false | boolean | |
user | User name, default: admin | string | |
password | User password, default: 123 | string | |
tagGroups | Tag groups options | TagGroupOptions[] | See Tag Group options |
Tag Group options info | |||
name | Tag name | string | |
tags | Tag collection | string[] | |
redocVersion | Set an specific redoc version | string,number | By default it's "latest" |
Note: If you want to change your ReDoc theme settings, take a look at the official ReDoc documentation: https://github.com/Redocly/redoc/blob/master/src/theme.ts
Apply the properties defined in ResolvedThemeInterface to the key called "theme" in the redoc options
Logo options
Option | Description | Type | Example |
---|---|---|---|
url | The URL pointing to the spec Logo, must be in the format of a URL and an absolute URL | string | |
backgroundColor | Background color to be used, must be RGB color in hexadecimal format (e.g: #008080) | string | #F0F0F0 |
altText | Alt tag for Logo | string | PetStore |
href | href tag for Logo, it defaults to the host used for your API spec | string |
👨💻👩💻 Contributors
- Special thanks to Jay McDoniel (jmcdo29) who helped with code refactoring and unit tests! 👏
- @joemaidman
📜 Changelog
Bellow are a list of changes, some might go undocumented
- 1.0.0 - First release
- 1.1.0 - Minor changes, nothing too important
- 1.2.0 - Added unit tests, refactored code
- 1.2.1 - Updated to work with the latest version of nest swagger module
- 1.2.2 - Fixed issue with URL on windows
- 1.3.0 - Added favicon option (by @joemaidman)
- 2.0.0 - Added authentication option, fixed issues with CSP and nestjs version compatibility issues
- 2.1.0 - Added x-tagGroups extension property
- 2.1.1 - Fixed CSP issue on Safari browser
- 2.2.0 - Added version property, this way you can pin redoc to a specific version
- 2.2.2 - Updated to support Nest 8
📋 ToDo
- Add Fastify support
- Add the option to use a spec URL instead of document
- Fix tests
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 4/23 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 11 are checked with a SAST tool
Reason
55 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-4jpv-8r57-pv7j
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-4w2v-q235-vp99
- Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-h452-7996-h45h
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-wm7h-9275-46v2
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-fr76-2wp8-fp92
- Warn: Project is vulnerable to: GHSA-3fjj-p79j-c9hh
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1.9
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More