UNPKG

nestjs-redox

Version:

This NestJS module enables to auto-generate beautiful API docs using Swagger and Redoc. It supports NestJS 10, ExpressJS and Fastify.

40 lines (39 loc) 1.88 kB
import { DynamicModule, INestApplication } from '@nestjs/common'; import { OpenAPIObject } from '@nestjs/swagger'; import { NestJSRedoxOptions, RedocOptions } from './types'; /** ------ * Disclaimer: some functions were extracted from https://github.com/nestjs/swagger/blob/master/lib/swagger-module.ts * and changed in that way it renders redoc instead of swagger ui. */ export declare class NestjsRedoxModule { protected static redocOptions: RedocOptions; protected static options: NestJSRedoxOptions; protected static preparedRedocJS?: string; protected static isFastifyBasicAuthRegistered: boolean; static register(options?: NestJSRedoxOptions, redocOptions?: RedocOptions): DynamicModule; /** * setups RedoxMdoule with generating and serving redoc html page using expressjs or fastify. * @param path URI path to the redoc page * @param app The nest application that is currently serving * @param documentOrURL The OpenAPI Object or a function that creates the object or a static URL * @param options NestJSRedoxOptions. If undefined default options are used. * @param redocOptions Officical options by redoc. */ static setup(path: string, app: INestApplication, documentOrURL: OpenAPIObject | (() => OpenAPIObject) | string, options?: NestJSRedoxOptions, redocOptions?: RedocOptions): void; private static serveStatic; private static serveDocuments; /** * Fixes content security policy issue * see issue #2 and #17 * @param httpAdapter * @param res * @private */ private static setContentSecurityHeader; /** * overwrites the HTTP header with that ones from RedoxOptions. * @param newHeaders foreach header use one attribute and value */ private static overwriteHeadersWith; private static applyRedocExtensions; }