Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brakebein/nestjs-redoc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brakebein/nestjs-redoc

NestJS ReDoc frontend

  • 2.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NestJS-Redoc

ReDoc powered frontend for your NestJS API spec
PRs welcome Nest Powered MIT license

⚡ Features | 🗿 Installation | ❓ How to use | 👨‍💻👩‍💻 Contributors | 📜 Changelog | 📋 ToDo

📒 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

const options = new DocumentBuilder()
  .setTitle('Look, i have a title')
  .setDescription('A very nice description')
  .setBasePath('/api/v1')
  .build();
const 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.

const redocOptions: RedocOptions = {
  title: 'Hello Nest',
  logo: {
    url: 'https://redocly.github.io/redoc/petstore-logo.png',
    backgroundColor: '#F0F0F0',
    altText: 'PetStore logo'
  },
  sortPropsAlphabetically: true,
  hideDownloadButton: false,
  hideHostname: false,
  auth: {
    enabled: true,
    user: 'admin',
    password: '123'
  },
  tagGroups: [
    {
      name: 'Core resources',
      tags: ['cats'],
    },
  ],
};
// Instead of using SwaggerModule.setup() you call this module
await RedocModule.setup('/docs', app, document, redocOptions);

Available options

Redoc Options

OptionDescriptionTypeNote
titleWeb site title (e.g: ReDoc documentation)string
faviconWeb site favicon URLstringFallbacks to the document title if not set
logoLogo optionsLogoOptionsSee LogoOptions table
themeTheme optionsThemeOptionsSee ThemeOptions info
untrustedSpecIf set, the spec is considered untrusted and all HTML/markdown is sanitized to prevent XSS, by default is falseboolean
supressWarningsIf set, warnings are not rendered at the top of documentation (they are still logged to the console)boolean
hideHostnameIf set, the protocol and hostname won't be shown in the operation definitionboolean
expandResponsesSpecify 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
requiredPropsFirstIf set, show required properties first ordered in the same order as in required arrayboolean
sortPropsAlphabeticallyIf set, propeties will be sorted alphabeticallyboolean
showExtensionsIf set the fields starting with "x-" will be shown, can be a boolean or a string with names of extensions to displayboolean
noAutoAuthIf set, redoc won't inject authentication section automaticallyboolean
pathInMiddlePanelIf set, path link and HTTP verb will be shown in the middle panel instead of the right oneboolean
hideLoadingIf set, loading spinner animation won't be shownboolean
nativeScrollbarsIf set, a native scrollbar will be used instead of perfect-scroll, this can improve performance of the frontend for big specsboolean
hideDownloadButtonThis will hide the "Download spec" button, it only hides the buttonboolean
disableSearchIf set, the search bar will be disabledboolean
onlyRequiredInSamplesShows only required fileds in request samplesboolean
authAuth optionsAuthOptionsSee AuthOptions info
AuthOptions info
enabledIf enabled, a prompt will pop out asking for authentication details, default: falseboolean
userUser name, default: adminstring
passwordUser password, default: 123string
tagGroupsTag groups optionsTagGroupOptions[]See Tag Group options
Tag Group options info
nameTag namestring
tagsTag collectionstring[]
redocVersionSet an specific redoc versionstring,numberBy 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

OptionDescriptionTypeExample
urlThe URL pointing to the spec Logo, must be in the format of a URL and an absolute URLstring
backgroundColorBackground color to be used, must be RGB color in hexadecimal format (e.g: #008080)string#F0F0F0
altTextAlt tag for LogostringPetStore
hrefhref tag for Logo, it defaults to the host used for your API specstring

👨‍💻👩‍💻 Contributors

📜 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
  • 2.3.0 - Updated to support Nest 9, removed padding from logo image

📋 ToDo

  • Add Fastify support
  • Add the option to use a spec URL instead of document
  • Fix tests

FAQs

Package last updated on 09 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc