npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nestjs-redoc-try-out-extended

v1.0.3

Published

NestJS module for Redoc-try-it-out

Downloads

7

Readme

Description | Features | Installation | How to use | Available Options | Credits | Changelog | TODO

Description

NestJS-Redoc-Try-Out is an unofficial NestJS module for Redoc Try Out. It provides an easy way plugging in Redoc in a NestJS application.

Features

  • Provides a try out option implemented by Redoc Try Out
  • Automatic code snippet generation

Installation

npm i nestjs-redoc-try-out

How to use

Redoc it's just a fancy frontend for display OpenApi documentation. In order to get your api documented, SwaggerWrapper Module is required and the official NestJS OpenApi Guide must be followed.

...

import { RedocTryOutModule, RedocModuleOptions } from 'nestjs-redoc-try-out';

async function bootstrap() {
    ...
    const app = ... //create NestJS application
    const config = new DocumentBuilder() // documenting the api
    const document = SwaggerModule.createDocument(app, config);

    const options: RedocOptions = { /** see: available options */ };
    // Instead of using SwaggerModule.setup() you call this module
    await RedocTryOutModule.setup('/docs', app, document, options);
    ...
}

bootstrap();

Available options

RedocTryOutModule Setup Options

| Option | Description | Type | | ----------------------- | ------------------------------- | --------------------------------------------------------------------------------- | | path | The path to mount the Redoc UI | string | | app | An application instance | INestApplication | | document | URL swagger's spec file | OpenAPIObject | | options (optional) | Redoc try it out config options | RedocTryItOutOptions |

Redoc Options

RedocOptions extends RedocTryItOutOptions, documented on Redoc Try Out Documentation

export interface RedocModuleOptions extends RedocOptions {

  /**
   *  Web site title
   *  default: document.info.title || document.info.description || 'Online documentation'
   */
  title?: string;
  
  /** Web site favicon URL */
  favicon?: string;

  /** Name of the swagger json spec file. default: 'swagger' */
  docName?: string;

  /** Skip generation of code snippets: default: false */
  skipSnippetsGeneration?: boolean;

  /**
   *  Languages used on code generation snippets.
   *  default: ['javascript']
   *  Language = 'c'| 'c_libcurl'| 'clojure'| 'clojure_clj_http'| 'csharp'| 'csharp_restsharp'| 'csharp_httpclient'| 'go'| 'go_native'|'http'|'http_1.1'|'java'|'java_okhttp'|'java_unirest'|'java_asynchttp'|'java_nethttp'|'javascript'|'javascript_jquery'|'javascript_fetch'|'javascript_xhr'|'javascript_axios'|'kotlin'|'kotlin_okhttp'|'node'|'node_native'|'node_request'|'node_unirest'|'node_axios'|'node_fetch'|'objc'|'objc_nsurlsession'|'ocaml'|'ocaml_cohttp'|'php'|'php_curl'|'php_http1'|'php_http2'|'powershell'|'powershell_webrequest'|'powershell_restmethod'|'python'|'python_python3'|'python_requests'|'r'|'r_httr'|'ruby'|'ruby_native'|'shell'|'shell_curl'|'shell_httpie'|'shell_wget'|'swift'|'swift_nsurlsession'
   */
  codeSnippetsLanguages?: Language[];

  /** Authentication options - not implemented yet */
  auth?: {
    enabled: boolean;
    user: string;
    password: string;
  };
  
  /**
   * Group tags in categories in the side menu.
   * Tags not added to a group will not be displayed.
   * default: document.tags
   */
  tagGroups?: TagGroupOptions[];

  /** Logo Options */
  logo?: LogoOptions;
}

export interface LogoOptions {
  /** 
   * The URL pointing to the spec logo
   *  Format: Absolute URL
   */
  url?: string;
  
  /** Background color. Format: RGB color in hexadecimal format (e.g: #0000ff) */
  backgroundColor?: string;
  
  /** Alt tag for logo */
  altText?: string;
  
  /** href tag for logo. */
  href?: string;
}

export interface TagGroupOptions {
  name: string;
  tags: string[];
}

Credits

It's based on nestjs-redoc work.

Changelog

Bellow are a list of changes, some might go undocumented

  • 1.0.0 - First release
  • 1.0.1 - Fix codegen issue for authenticated spec
  • 1.0.2 - Fix docName undefinded error
  • 1.0.3 - Fix empty screen when option is not provided

TODO

  • Add Fastify support
  • Implement authentication
  • Refactoring code gen
  • Add custom language