diff --git a/README.md b/README.md index 6b77363..5c56adb 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,10 @@ await RedocModule.setup('/docs', app, document, redocOptions); | 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: @@ -154,6 +158,8 @@ Bellow are a list of changes, some might go undocumented - 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 diff --git a/package.json b/package.json index feb899b..b1337e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nestjs-redoc", - "version": "2.1.1", + "version": "2.2.2", "description": "NestJS ReDoc frontend", "repository": "https://github.com/mxarc/nestjs-redoc", "author": "Alfonso Reyes", @@ -22,25 +22,25 @@ "sample": "ts-node ./sample/main" }, "peerDependencies": { - "@nestjs/common": "^7.0.0", - "@nestjs/core": "^7.0.0", - "@nestjs/swagger": "^4.0.0", + "@nestjs/common": "^8.0.0", + "@nestjs/core": "^8.0.0", + "@nestjs/swagger": "^5.0.0", "reflect-metadata": "^0.1.12" }, "dependencies": { "@hapi/joi": "^17.1.1", - "@nestjs/common": "^7.0.0", - "@nestjs/swagger": "^4.0.0", + "@nestjs/common": "^8.0.0", + "@nestjs/swagger": "^5.0.0", "express-basic-auth": "^1.2.0", "express-handlebars": "^5.1.0" }, "devDependencies": { "@commitlint/cli": "^9.1.2", "@commitlint/config-conventional": "^9.1.2", - "@nestjs/core": "^7.0.0", - "@nestjs/platform-express": "^7.0.0", - "@nestjs/platform-fastify": "^7.0.0", - "@nestjs/testing": "^7.0.0", + "@nestjs/core": "^8.0.0", + "@nestjs/platform-express": "^8.0.0", + "@nestjs/platform-fastify": "^8.0.0", + "@nestjs/testing": "^8.0.0", "@types/express": "^4.17.8", "@types/express-handlebars": "^3.1.0", "@types/hapi__joi": "^17.1.6", @@ -62,11 +62,11 @@ "supertest": "^6.0.1", "ts-jest": "^26.4.3", "ts-node": "^9.0.0", - "typescript": "^4.0.5" + "typescript": "^4.3.5" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } } -} \ No newline at end of file +} 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 60694a2..c2a151e 100644 --- a/views/redoc.handlebars +++ b/views/redoc.handlebars @@ -24,7 +24,7 @@
- +