Skip to content

Commit

Permalink
Merge branch 'mxarc:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mo4islona authored Aug 12, 2021
2 parents ba3fd00 + ddf551d commit e57d37b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/Redocly/redoc/blob/master/src/theme.ts>

Expand Down Expand Up @@ -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

Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
}
}
}
2 changes: 2 additions & 0 deletions src/interfaces/redocOptions.interface.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/model/options.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion src/redoc-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion views/redoc.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body>
<!-- we provide is specification here -->
<div id="redoc_container"></div>
<script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script>
<script src="https://cdn.jsdelivr.net/npm/redoc@{{data.redocVersion}}/bundles/redoc.standalone.js"> </script>
<script>
let themeJSON = '{{{ toJSON data.theme }}}';
if (themeJSON === '') { themeJSON = undefined }
Expand Down

0 comments on commit e57d37b

Please sign in to comment.