From 547131edc529517d3558169e046db55588d5a217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20Vaha?= Date: Mon, 5 Apr 2021 22:09:55 +0300 Subject: [PATCH] feat: make ReDoc version configurable --- src/interfaces/redocOptions.interface.ts | 2 ++ src/model/options.model.ts | 1 + src/redoc-module.ts | 3 ++- views/redoc.handlebars | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/interfaces/redocOptions.interface.ts b/src/interfaces/redocOptions.interface.ts index 21671c1..95c50c2 100644 --- a/src/interfaces/redocOptions.interface.ts +++ b/src/interfaces/redocOptions.interface.ts @@ -1,4 +1,6 @@ export interface RedocOptions { + /** Version of ReDoc to use (e.g. next, latest, 2.0.0-rc.50), by default is latest */ + redocVersion?: string; /** Web site title (e.g: ReDoc documentation) */ title?: string; /** Web site favicon URL */ diff --git a/src/model/options.model.ts b/src/model/options.model.ts index 9c1b919..99c1206 100644 --- a/src/model/options.model.ts +++ b/src/model/options.model.ts @@ -3,6 +3,7 @@ import { OpenAPIObject } from '@nestjs/swagger'; export const schema = (document: OpenAPIObject) => Joi.object().keys({ + redocVersion: Joi.string().default('latest'), title: Joi.string() .optional() .default(document.info ? document.info.title : 'Swagger documentation'), diff --git a/src/redoc-module.ts b/src/redoc-module.ts index bece00e..4d1687c 100644 --- a/src/redoc-module.ts +++ b/src/redoc-module.ts @@ -98,13 +98,14 @@ export class RedocModule { }, }); // spread redoc options - const { title, favicon, theme, ...otherOptions } = options; + const { title, favicon, theme, redocVersion, ...otherOptions } = options; // create render object const renderData = { data: { title, docUrl, favicon, + redocVersion, options: otherOptions, ...(theme && { theme: { diff --git a/views/redoc.handlebars b/views/redoc.handlebars index 4681915..74ac418 100644 --- a/views/redoc.handlebars +++ b/views/redoc.handlebars @@ -24,7 +24,7 @@
- +